Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e86980ee
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,发现更多精彩内容 >>
提交
e86980ee
编写于
2月 26, 2016
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Increase coverage to operators, constructors and destructors
上级
52c53962
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
17 deletion
+30
-17
src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs
src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs
+7
-6
src/Compilers/Test/Utilities/VisualBasic/CompilationTestUtils.vb
...pilers/Test/Utilities/VisualBasic/CompilationTestUtils.vb
+22
-10
src/Test/Utilities/Shared/Compilation/TestOperationWalker.cs
src/Test/Utilities/Shared/Compilation/TestOperationWalker.cs
+1
-1
未找到文件。
src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs
浏览文件 @
e86980ee
...
...
@@ -516,7 +516,7 @@ public static SyntaxTree ParseWithRoundTripCheck(string text, CSharpParseOptions
options
=
options
.
WithConcurrentBuild
(
false
);
}
#if T
EST_OPERATION
#if T
est_IOperation_Interface
// Create a compilation for the purpose of verifying operation tree only,
// so this won't interfere with test.
var
compilationForOperationWalking
=
CSharpCompilation
.
Create
(
...
...
@@ -541,26 +541,27 @@ public static SyntaxTree ParseWithRoundTripCheck(string text, CSharpParseOptions
CSharpParseOptions
parseOptions
=
null
)
{
var
trees
=
(
sources
==
null
)
?
null
:
sources
.
Select
(
s
=>
Parse
(
s
,
options
:
parseOptions
)).
ToArray
();
var
compilationOptions
=
options
??
TestOptions
.
ReleaseDll
;
#if T
EST_OPERATION
#if T
est_IOperation_Interface
// Create a compilation for the purpose of verifying operation tree only,
// so this won't interfere with test.
var
compilationForOperationWalking
=
CSharpCompilation
.
Create
(
identity
.
Name
,
options
:
options
??
TestOptions
.
ReleaseDll
,
options
:
compilationOptions
,
references
:
references
,
syntaxTrees
:
trees
);
WalkOperationTree
(
compilationForOperationWalking
);
#endif
var
c
=
CSharpCompilation
.
Create
(
identity
.
Name
,
options
:
options
??
TestOptions
.
ReleaseDll
,
references
:
references
,
syntaxTrees
:
trees
);
var
c
=
CSharpCompilation
.
Create
(
identity
.
Name
,
options
:
compilationOptions
,
references
:
references
,
syntaxTrees
:
trees
);
Assert
.
NotNull
(
c
.
Assembly
);
// force creation of SourceAssemblySymbol
((
SourceAssemblySymbol
)
c
.
Assembly
).
lazyAssemblyIdentity
=
identity
;
return
c
;
}
#if T
EST_OPERATION
#if T
est_IOperation_Interface
private
static
void
WalkOperationTree
(
CSharpCompilation
compilation
)
{
var
operationWalker
=
TestOperationWalker
.
GetInstance
();
...
...
@@ -571,7 +572,7 @@ private static void WalkOperationTree(CSharpCompilation compilation)
var
root
=
tree
.
GetRoot
();
// TODO: check other operation root as well (property, etc.)
foreach
(
MethodDeclarationSyntax
methodNode
in
root
.
DescendantNodesAndSelf
().
Where
(
n
=>
n
.
Kind
()
==
SyntaxKind
.
MethodDeclaration
))
foreach
(
BaseMethodDeclarationSyntax
methodNode
in
root
.
DescendantNodesAndSelf
().
OfType
<
BaseMethodDeclarationSyntax
>(
))
{
var
bodyNode
=
methodNode
.
Body
;
if
(
bodyNode
!=
null
)
...
...
src/Compilers/Test/Utilities/VisualBasic/CompilationTestUtils.vb
浏览文件 @
e86980ee
...
...
@@ -20,17 +20,30 @@ Friend Module CompilationUtils
Optional
options
As
VisualBasicCompilationOptions
=
Nothing
,
Optional
assemblyName
As
String
=
Nothing
,
Optional
parseOptions
As
VisualBasicParseOptions
=
Nothing
)
As
VisualBasicCompilation
#If TEST_OPERATION Then
Dim
compilationForOperationWalking
=
VisualBasicCompilation
.
Create
(
If
(
assemblyName
,
"TestOperation"
),
sourceTrees
.
Select
(
Function
(
s
)
VisualBasicSyntaxTree
.
ParseText
(
s
,
parseOptions
)),
If
(
references
Is
Nothing
,
{
MscorlibRef
},
{
MscorlibRef
}.
Concat
(
references
)),
options
)
Dim
syntaxTrees
=
sourceTrees
.
Select
(
Function
(
s
)
VisualBasicSyntaxTree
.
ParseText
(
s
,
parseOptions
))
Dim
metadataReferences
=
If
(
references
Is
Nothing
,
{
MscorlibRef
},
{
MscorlibRef
}.
Concat
(
references
))
#If Test_IOperation_Interface Then
Dim
compilationForOperationWalking
=
VisualBasicCompilation
.
Create
(
If
(
assemblyName
,
"TestOperation"
),
syntaxTrees
,
metadataReferences
,
options
)
WalkOperationTrees
(
compilationForOperationWalking
)
#End If
Return
VisualBasicCompilation
.
Create
(
If
(
assemblyName
,
"Test"
),
sourceTrees
.
Select
(
Function
(
s
)
VisualBasicSyntaxTree
.
ParseText
(
s
,
parseOptions
)),
If
(
references
Is
Nothing
,
{
MscorlibRef
},
{
MscorlibRef
}.
Concat
(
references
)),
options
)
Return
VisualBasicCompilation
.
Create
(
If
(
assemblyName
,
"Test"
),
syntaxTrees
,
metadataReferences
,
options
)
End
Function
Public
Function
CreateCompilationWithMscorlib
(
sourceTrees
As
IEnumerable
(
Of
SyntaxTree
),
Optional
references
As
IEnumerable
(
Of
MetadataReference
)
=
Nothing
,
Optional
options
As
VisualBasicCompilationOptions
=
Nothing
)
As
VisualBasicCompilation
Return
VisualBasicCompilation
.
Create
(
GetUniqueName
(),
sourceTrees
,
If
(
references
Is
Nothing
,
{
MscorlibRef
},
{
MscorlibRef
}.
Concat
(
references
)),
options
)
Dim
metadataReferences
=
If
(
references
Is
Nothing
,
{
MscorlibRef
},
{
MscorlibRef
}.
Concat
(
references
))
#If Test_IOperation_Interface Then
Dim
compilationForOperationWalking
=
VisualBasicCompilation
.
Create
(
GetUniqueName
(),
sourceTrees
,
metadataReferences
,
options
)
WalkOperationTrees
(
compilationForOperationWalking
)
#End If
Return
VisualBasicCompilation
.
Create
(
GetUniqueName
(),
sourceTrees
,
metadataReferences
,
options
)
End
Function
Public
Function
CreateCompilationWithMscorlib45
(
sourceTrees
As
IEnumerable
(
Of
SyntaxTree
),
...
...
@@ -227,7 +240,7 @@ Friend Module CompilationUtils
End
If
End
If
#If T
EST_OPERATION
Then
#If T
est_IOperation_Interface
Then
Dim
compilationForOperationWalking
=
VisualBasicCompilation
.
Create
(
If
(
assemblyName
,
GetUniqueName
()),
sourceTrees
,
references
,
options
)
WalkOperationTrees
(
compilationForOperationWalking
)
#End If
...
...
@@ -263,7 +276,7 @@ Friend Module CompilationUtils
Return
c
End
Function
#If T
EST_OPERATION
Then
#If T
est_IOperation_Interface
Then
Private
Sub
WalkOperationTrees
(
compilation
As
VisualBasicCompilation
)
Dim
operationWalker
=
TestOperationWalker
.
GetInstance
()
...
...
@@ -272,10 +285,9 @@ Friend Module CompilationUtils
Dim
root
=
tree
.
GetRoot
()
' need to check other operation root as well (property, etc)
For
Each
methodNode
As
MethodBlockSyntax
In
root
.
DescendantNodesAndSelf
().
Where
(
Function
(
n
)
Dim
kind
=
n
.
Kind
()
Return
kind
=
SyntaxKind
.
FunctionBlock
OrElse
kind
=
SyntaxKind
.
SubBlock
End
Function
)
For
Each
methodNode
As
MethodBlockBaseSyntax
In
root
.
DescendantNodesAndSelf
().
OfType
(
Of
MethodBlockBaseSyntax
)
' Have to iterate through statements because a bug:
' https://github.com/dotnet/roslyn/issues/8919
For
Each
statement
In
methodNode
.
Statements
Dim
operation
=
semanticModel
.
GetOperation
(
statement
)
operationWalker
.
Visit
(
operation
)
...
...
src/Test/Utilities/Shared/Compilation/TestOperationWalker.cs
浏览文件 @
e86980ee
...
...
@@ -22,7 +22,7 @@ public static TestOperationWalker GetInstance()
return
s_instance
;
}
#if T
EST_NONE_OPERATION
#if T
est_IOperation_None_Kind
internal
override
void
VisitNoneOperation
(
IOperation
operation
)
{
Assert
.
True
(
false
,
"Encountered an IOperation with `Kind == OperationKind.None` while walking the operation tree."
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录