Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET
Roslyn
提交
e758b536
R
Roslyn
项目概览
dotNET
/
Roslyn
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e758b536
编写于
6月 01, 2017
作者:
M
Manish Vasani
提交者:
GitHub
6月 01, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19906 from mavasani/FixLocalFunctionStatement
Ensure that IOperations nodes within a C# local function are part of …
上级
b1a32b9f
1288d3f1
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
48 addition
and
21 deletion
+48
-21
src/Compilers/CSharp/Portable/BoundTree/Statement.cs
src/Compilers/CSharp/Portable/BoundTree/Statement.cs
+5
-3
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs
...peration/IOperationTests_IParameterReferenceExpression.cs
+43
-0
src/Compilers/Core/Portable/Operations/OperationVisitor.cs
src/Compilers/Core/Portable/Operations/OperationVisitor.cs
+0
-10
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
+0
-2
src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs
...t/Utilities/Portable/Compilation/OperationTreeVerifier.cs
+0
-6
未找到文件。
src/Compilers/CSharp/Portable/BoundTree/Statement.cs
浏览文件 @
e758b536
...
...
@@ -854,16 +854,18 @@ public override void Accept(OperationVisitor visitor)
partial
class
BoundLocalFunctionStatement
{
protected
override
OperationKind
StatementKind
=>
OperationKind
.
LocalFunctionStatement
;
protected
override
OperationKind
StatementKind
=>
OperationKind
.
None
;
protected
override
ImmutableArray
<
IOperation
>
Children
=>
ImmutableArray
.
Create
<
IOperation
>(
this
.
Body
);
public
override
void
Accept
(
OperationVisitor
visitor
)
{
visitor
.
Visit
LocalFunctionStatement
(
this
);
visitor
.
Visit
NoneOperation
(
this
);
}
public
override
TResult
Accept
<
TArgument
,
TResult
>(
OperationVisitor
<
TArgument
,
TResult
>
visitor
,
TArgument
argument
)
{
return
visitor
.
Visit
LocalFunctionStatement
(
this
,
argument
);
return
visitor
.
Visit
NoneOperation
(
this
,
argument
);
}
}
...
...
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IParameterReferenceExpression.cs
浏览文件 @
e758b536
...
...
@@ -850,5 +850,48 @@ public void Method1(object x)
VerifyOperationTreeAndDiagnosticsForTest
<
IsPatternExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
[
Fact
,
WorkItem
(
19902
,
"https://github.com/dotnet/roslyn/issues/19902"
)]
public
void
ParameterReference_LocalFunctionStatement
()
{
string
source
=
@"
using System;
using System.Collections.Generic;
class Class
{
static IEnumerable<T> MyIterator<T>(IEnumerable<T> source, Func<T, bool> predicate)
{
/*<bind>*/IEnumerable<T> Iterator()
{
foreach (var element in source)
if (predicate(element))
yield return element;
}/*</bind>*/
return Iterator();
}
}
"
;
string
expectedOperationTree
=
@"
IOperation: (OperationKind.None) (Syntax: 'IEnumerable ... }')
Children(1): IBlockStatement (2 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IForEachLoopStatement (Iteration variable: T element) (LoopKind.ForEach) (OperationKind.LoopStatement) (Syntax: 'foreach (va ... rn element;')
Collection: IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Collections.Generic.IEnumerable<T>) (Syntax: 'source')
IParameterReferenceExpression: source (OperationKind.ParameterReferenceExpression, Type: System.Collections.Generic.IEnumerable<T>) (Syntax: 'source')
Body: IIfStatement (OperationKind.IfStatement) (Syntax: 'if (predica ... rn element;')
Condition: IInvocationExpression (virtual System.Boolean System.Func<T, System.Boolean>.Invoke(T arg)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'predicate(element)')
Instance Receiver: IParameterReferenceExpression: predicate (OperationKind.ParameterReferenceExpression, Type: System.Func<T, System.Boolean>) (Syntax: 'predicate')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: arg) (OperationKind.Argument) (Syntax: 'element')
ILocalReferenceExpression: element (OperationKind.LocalReferenceExpression, Type: T) (Syntax: 'element')
IfTrue: IReturnStatement (OperationKind.YieldReturnStatement) (Syntax: 'yield return element;')
ILocalReferenceExpression: element (OperationKind.LocalReferenceExpression, Type: T) (Syntax: 'element')
YieldBreakStatement (OperationKind.YieldBreakStatement) (Syntax: '{ ... }')
"
;
var
expectedDiagnostics
=
DiagnosticDescription
.
None
;
VerifyOperationTreeAndDiagnosticsForTest
<
LocalFunctionStatementSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
}
}
\ No newline at end of file
src/Compilers/Core/Portable/Operations/OperationVisitor.cs
浏览文件 @
e758b536
...
...
@@ -389,11 +389,6 @@ public virtual void VisitInvalidExpression(IInvalidExpression operation)
{
DefaultVisit
(
operation
);
}
public
virtual
void
VisitLocalFunctionStatement
(
IOperation
operation
)
{
DefaultVisit
(
operation
);
}
}
/// <summary>
...
...
@@ -789,10 +784,5 @@ public virtual TResult VisitInvalidExpression(IInvalidExpression operation, TArg
{
return
DefaultVisit
(
operation
,
argument
);
}
public
virtual
TResult
VisitLocalFunctionStatement
(
IOperation
operation
,
TArgument
argument
)
{
return
DefaultVisit
(
operation
,
argument
);
}
}
}
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
浏览文件 @
e758b536
...
...
@@ -804,7 +804,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLabelStatement(Mi
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLambdaExpression(Microsoft.CodeAnalysis.Semantics.ILambdaExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLateBoundMemberReferenceExpression(Microsoft.CodeAnalysis.Semantics.ILateBoundMemberReferenceExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLiteralExpression(Microsoft.CodeAnalysis.Semantics.ILiteralExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.IOperation operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLocalReferenceExpression(Microsoft.CodeAnalysis.Semantics.ILocalReferenceExpression operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitLockStatement(Microsoft.CodeAnalysis.Semantics.ILockStatement operation) -> void
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation) -> void
...
...
@@ -880,7 +879,6 @@ virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.Vi
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitLambdaExpression(Microsoft.CodeAnalysis.Semantics.ILambdaExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitLateBoundMemberReferenceExpression(Microsoft.CodeAnalysis.Semantics.ILateBoundMemberReferenceExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitLiteralExpression(Microsoft.CodeAnalysis.Semantics.ILiteralExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitLocalFunctionStatement(Microsoft.CodeAnalysis.IOperation operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitLocalReferenceExpression(Microsoft.CodeAnalysis.Semantics.ILocalReferenceExpression operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitLockStatement(Microsoft.CodeAnalysis.Semantics.ILockStatement operation, TArgument argument) -> TResult
virtual Microsoft.CodeAnalysis.Semantics.OperationVisitor<TArgument, TResult>.VisitMethodBindingExpression(Microsoft.CodeAnalysis.Semantics.IMethodBindingExpression operation, TArgument argument) -> TResult
...
...
src/Test/Utilities/Portable/Compilation/OperationTreeVerifier.cs
浏览文件 @
e758b536
...
...
@@ -1058,12 +1058,6 @@ public override void VisitIfStatement(IIfStatement operation)
Visit
(
operation
.
IfFalseStatement
,
"IfFalse"
);
}
public
override
void
VisitLocalFunctionStatement
(
IOperation
operation
)
{
LogString
(
nameof
(
VisitLocalFunctionStatement
));
LogCommonPropertiesAndNewLine
(
operation
);
}
private
void
LogCaseClauseCommon
(
ICaseClause
operation
)
{
var
kindStr
=
$"
{
nameof
(
CaseKind
)}
.
{
operation
.
CaseKind
}
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录