Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9619d5ec
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
未验证
提交
9619d5ec
编写于
11月 07, 2017
作者:
M
Manish Vasani
提交者:
GitHub
11月 07, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23036 from mavasani/GetStandaloneNode
Do not invoke GetStandaloneNode helper in GetOperationWorker
上级
8ab9a128
496d082e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
74 addition
and
3 deletion
+74
-3
src/Compilers/CSharp/Portable/Compilation/SyntaxTreeSemanticModel.cs
...rs/CSharp/Portable/Compilation/SyntaxTreeSemanticModel.cs
+0
-3
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs
...pilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs
+40
-0
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb
...s/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb
+34
-0
未找到文件。
src/Compilers/CSharp/Portable/Compilation/SyntaxTreeSemanticModel.cs
浏览文件 @
9619d5ec
...
...
@@ -163,9 +163,6 @@ internal override Binder GetEnclosingBinderInternal(int position)
internal
override
IOperation
GetOperationWorker
(
CSharpSyntaxNode
node
,
CancellationToken
cancellationToken
)
{
// in case this is right side of a qualified name or member access (or part of a cref)
node
=
SyntaxFactory
.
GetStandaloneNode
(
node
);
var
model
=
this
.
GetMemberModel
(
node
);
if
(
model
!=
null
)
{
...
...
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests.cs
浏览文件 @
9619d5ec
...
...
@@ -159,5 +159,45 @@ public void TestParentOperations()
VerifyParentOperations
(
model
);
}
[
CompilerTrait
(
CompilerFeature
.
IOperation
)]
[
WorkItem
(
23001
,
"https://github.com/dotnet/roslyn/issues/23001"
)]
[
Fact
]
public
void
TestGetOperationForQualifiedName
()
{
var
text
=
@"using System;
public class Test
{
class A
{
public B b;
}
class B
{
}
void M(A a)
{
int x2 = /*<bind>*/a.b/*</bind>*/;
}
}
"
;
var
comp
=
CreateStandardCompilation
(
text
,
parseOptions
:
TestOptions
.
RegularWithIOperationFeature
);
var
tree
=
comp
.
SyntaxTrees
.
Single
();
var
model
=
comp
.
GetSemanticModel
(
tree
);
// Verify we return non-null operation only for topmost member access expression.
var
expr
=
(
MemberAccessExpressionSyntax
)
GetExprSyntaxForBinding
(
GetExprSyntaxList
(
tree
));
Assert
.
Equal
(
"a.b"
,
expr
.
ToString
());
var
operation
=
model
.
GetOperation
(
expr
);
Assert
.
NotNull
(
operation
);
Assert
.
Equal
(
OperationKind
.
FieldReference
,
operation
.
Kind
);
var
fieldOperation
=
(
IFieldReferenceOperation
)
operation
;
Assert
.
Equal
(
"b"
,
fieldOperation
.
Field
.
Name
);
// Verify we return null operation for child nodes of member access expression.
Assert
.
Null
(
model
.
GetOperation
(
expr
.
Name
));
}
}
}
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests.vb
浏览文件 @
9619d5ec
...
...
@@ -834,5 +834,39 @@ IAnonymousFunctionOperation (Symbol: Sub ()) (OperationKind.AnonymousFunction, T
VerifyOperationTreeAndDiagnosticsForTest
(
Of
MultiLineLambdaExpressionSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
End
Sub
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
Fact
,
WorkItem
(
23001
,
"https://github.com/dotnet/roslyn/issues/23001"
)
>
Public
Sub
TestGetOperationForQualifiedName
()
Dim
source
=
<
!
[
CDATA
[
Public
Class
Test
Private
Class
A
Public
b
As
B
End
Class
Private
Class
B
End
Class
Private
Sub
M
(
a
As
A
)
Dim
x2
As
Integer
=
a
.
b
'BIND:"a.b"
End
Sub
End
Class
]]
>
.
Value
Dim
comp
=
CreateVisualBasicCompilation
(
source
,
parseOptions
:
=
TestOptions
.
RegularWithIOperationFeature
)
Dim
tree
=
comp
.
SyntaxTrees
.
Single
()
Dim
model
=
comp
.
GetSemanticModel
(
tree
)
' Verify we return non-null operation only for topmost member access expression.
Dim
expr
=
CompilationUtils
.
FindBindingText
(
Of
MemberAccessExpressionSyntax
)(
comp
,
tree
.
FilePath
)
Assert
.
Equal
(
"a.b"
,
expr
.
ToString
())
Dim
operation
=
model
.
GetOperation
(
expr
)
Assert
.
NotNull
(
operation
)
Assert
.
Equal
(
OperationKind
.
FieldReference
,
operation
.
Kind
)
Dim
fieldOperation
=
DirectCast
(
operation
,
IFieldReferenceOperation
)
Assert
.
Equal
(
"b"
,
fieldOperation
.
Field
.
Name
)
' Verify we return null operation for child nodes of member access expression.
Assert
.
Null
(
model
.
GetOperation
(
expr
.
Name
))
End
Sub
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录