Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6f80480d
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,发现更多精彩内容 >>
未验证
提交
6f80480d
编写于
8月 19, 2019
作者:
A
Andrew Hall
提交者:
GitHub
8月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for C# simplification around NRT (#36878)
上级
e4d465e2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
151 addition
and
17 deletion
+151
-17
src/EditorFeatures/Test2/Simplification/AbstractSimplificationTests.vb
...tures/Test2/Simplification/AbstractSimplificationTests.vb
+29
-17
src/EditorFeatures/Test2/Simplification/CastSimplificationTests.vb
...rFeatures/Test2/Simplification/CastSimplificationTests.vb
+122
-0
未找到文件。
src/EditorFeatures/Test2/Simplification/AbstractSimplificationTests.vb
浏览文件 @
6f80480d
...
...
@@ -2,6 +2,7 @@
Imports
System.Collections.Immutable
Imports
Microsoft.CodeAnalysis
Imports
Microsoft.CodeAnalysis.CSharp
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports
Microsoft.CodeAnalysis.Options
...
...
@@ -13,30 +14,41 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Simplification
<
[
UseExportProvider
]
>
Public
MustInherit
Class
AbstractSimplificationTests
Protected
Async
Function
TestAsync
(
definition
As
XElement
,
expected
As
XElement
,
Optional
options
As
Dictionary
(
Of
OptionKey
,
Object
)
=
Nothing
)
As
System
.
Threading
.
Tasks
.
Task
Protected
Async
Function
TestAsync
(
definition
As
XElement
,
expected
As
XElement
,
Optional
options
As
Dictionary
(
Of
OptionKey
,
Object
)
=
Nothing
,
Optional
csharpParseOptions
As
CSharpParseOptions
=
Nothing
)
As
System
.
Threading
.
Tasks
.
Task
Using
workspace
=
TestWorkspace
.
Create
(
definition
)
Dim
hostDocument
=
workspace
.
Documents
.
Single
()
Dim
finalWorkspace
=
workspace
Dim
spansToAddSimplifierAnnotation
=
hostDocument
.
AnnotatedSpans
.
Where
(
Function
(
kvp
)
kvp
.
Key
.
StartsWith
(
"Simplify"
,
StringComparison
.
Ordinal
))
Dim
explicitSpanToSimplifyAnnotatedSpans
=
hostDocument
.
AnnotatedSpans
.
Where
(
Function
(
kvp
)
Not
spansToAddSimplifierAnnotation
.
Contains
(
kvp
))
If
explicitSpanToSimplifyAnnotatedSpans
.
Count
<>
1
OrElse
explicitSpanToSimplifyAnnotatedSpans
.
Single
().
Key
<>
"SpanToSimplify"
Then
For
Each
span
In
explicitSpanToSimplifyAnnotatedSpans
If
span
.
Key
<>
"SpanToSimplify"
Then
Assert
.
True
(
False
,
"Encountered unexpected span annotation: "
+
span
.
Key
)
End
If
If
csharpParseOptions
IsNot
Nothing
Then
For
Each
project
In
workspace
.
CurrentSolution
.
Projects
finalWorkspace
.
ChangeSolution
(
finalWorkspace
.
CurrentSolution
.
WithProjectParseOptions
(
project
.
Id
,
csharpParseOptions
))
Next
End
If
Dim
explicitSpansToSimplifyWithin
=
If
(
explicitSpanToSimplifyAnnotatedSpans
.
Any
(),
explicitSpanToSimplifyAnnotatedSpans
.
Single
().
Value
,
Nothing
)
Await
TestAsync
(
workspace
,
spansToAddSimplifierAnnotation
,
explicitSpansToSimplifyWithin
,
expected
,
options
)
Await
TestAsync
(
finalWorkspace
,
expected
,
options
).
ConfigureAwait
(
False
)
End
Using
End
Function
Protected
Async
Function
TestAsync
(
workspace
As
TestWorkspace
,
expected
As
XElement
,
Optional
options
As
Dictionary
(
Of
OptionKey
,
Object
)
=
Nothing
)
As
System
.
Threading
.
Tasks
.
Task
Dim
hostDocument
=
workspace
.
Documents
.
Single
()
Dim
spansToAddSimplifierAnnotation
=
hostDocument
.
AnnotatedSpans
.
Where
(
Function
(
kvp
)
kvp
.
Key
.
StartsWith
(
"Simplify"
,
StringComparison
.
Ordinal
))
Dim
explicitSpanToSimplifyAnnotatedSpans
=
hostDocument
.
AnnotatedSpans
.
Where
(
Function
(
kvp
)
Not
spansToAddSimplifierAnnotation
.
Contains
(
kvp
))
If
explicitSpanToSimplifyAnnotatedSpans
.
Count
<>
1
OrElse
explicitSpanToSimplifyAnnotatedSpans
.
Single
().
Key
<>
"SpanToSimplify"
Then
For
Each
span
In
explicitSpanToSimplifyAnnotatedSpans
If
span
.
Key
<>
"SpanToSimplify"
Then
Assert
.
True
(
False
,
"Encountered unexpected span annotation: "
+
span
.
Key
)
End
If
Next
End
If
Dim
explicitSpansToSimplifyWithin
=
If
(
explicitSpanToSimplifyAnnotatedSpans
.
Any
(),
explicitSpanToSimplifyAnnotatedSpans
.
Single
().
Value
,
Nothing
)
Await
TestAsync
(
workspace
,
spansToAddSimplifierAnnotation
,
explicitSpansToSimplifyWithin
,
expected
,
options
)
End
Function
Private
Async
Function
TestAsync
(
workspace
As
Workspace
,
...
...
src/EditorFeatures/Test2/Simplification/CastSimplificationTests.vb
浏览文件 @
6f80480d
...
...
@@ -5035,6 +5035,128 @@ class C
Await
TestAsync
(
input
,
expected
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Simplification
)
>
Public
Async
Function
TestCSharp_DoNotSimplifyNullableGeneric
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
><
!
[
CDATA
[
#
nullable
enable
using
System
.
Threading
.
Tasks
;
class
Program
{
Task
<
string
?
>
M
()
{
string
s1
=
"test"
;
return
{
|
Simplify
:
Task
.
FromResult
<
string
?
>
|
}(
s1
)
;
}
}
]]
>
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
code
><
!
[
CDATA
[
#
nullable
enable
using
System
.
Threading
.
Tasks
;
class
Program
{
Task
<
string
?
>
M
()
{
string
s1
=
"test"
;
return
Task
.
FromResult
<
string
?
>
(
s1
)
;
}
}
]]
>
</
code
>
Await
TestAsync
(
input
,
expected
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Simplification
)
>
Public
Async
Function
TestCSharp_SimplifyNullableWithNullableSuppressionOperator
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
><
!
[
CDATA
[
#
nullable
enable
class
Program
{
void
M
()
{
string
?
s1
=
null
;
string
s2
=
{
|
Simplify
:
M1
<
string
>
|
}(
s1!
,
"hello"
)
;
}
static
T
M1
<
T
>
(
T
t1
,
T
t2
)
where
T
:
class
?
=>
t1
??
t2
;
}
]]
>
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
code
><
!
[
CDATA
[
#
nullable
enable
class
Program
{
void
M
()
{
string
?
s1
=
null
;
string
s2
=
M1
(
s1!
,
"hello"
)
;
}
static
T
M1
<
T
>
(
T
t1
,
T
t2
)
where
T
:
class
?
=>
t1
??
t2
;
}
]]
>
</
code
>
Await
TestAsync
(
input
,
expected
)
End
Function
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/36884"
),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Simplification
)
>
Public
Async
Function
TestCSharp_SimplifyNullableMethodTypeArgument
()
As
Task
Dim
input
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
><
!
[
CDATA
[
#
nullable
enable
class
Program
{
void
M
()
{
string
?
s1
=
null
;
string
?
s2
=
{
|
Simplify
:
M1
<
string
?
>
|
}(
s1
)
;
}
static
T
M1
<
T
>
(
T
t
)
where
T
:
class
?
=>
t
;
}
]]
>
</
Document
>
</
Project
>
</
Workspace
>
Dim
expected
=
<
code
><
!
[
CDATA
[
#
nullable
enable
class
Program
{
void
M
()
{
string
?
s1
=
null
;
string
?
s2
=
M1
(
s1
)
;
}
static
T
M1
<
T
>
(
T
t
)
where
T
:
class
?
=>
t
;
}
]]
>
</
code
>
Await
TestAsync
(
input
,
expected
)
End
Function
#End Region
#Region "Visual Basic tests"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录