Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
07287fa4
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,发现更多精彩内容 >>
未验证
提交
07287fa4
编写于
6月 20, 2019
作者:
J
Jason Malinowski
提交者:
GitHub
6月 20, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #36605 from jasonmalinowski/add-tests-for-generate-type
Add some nullability tests for Generate Type and fix one bug
上级
e2bf2a91
3875c718
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
131 addition
and
1 deletion
+131
-1
src/EditorFeatures/CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs
.../CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs
+128
-0
src/Features/Core/Portable/GenerateType/AbstractGenerateTypeService.State.cs
...ortable/GenerateType/AbstractGenerateTypeService.State.cs
+3
-1
未找到文件。
src/EditorFeatures/CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs
浏览文件 @
07287fa4
...
...
@@ -444,6 +444,27 @@ private class Goo
index
:
2
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
TestGenerateClassFromNullableFieldDeclarationIntoSameType
()
{
await
TestInRegularAndScriptAsync
(
@"#nullable enable
class Class
{
[|Goo?|] f;
}"
,
@"#nullable enable
class Class
{
Goo? f;
private class Goo
{
}
}"
,
index
:
2
);
}
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
TestGenerateClassFromFieldDeclarationIntoGlobalNamespace
()
{
...
...
@@ -1385,6 +1406,78 @@ public T(int v1, string v2)
index
:
1
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
GenerateWithNullableParameter
()
{
await
TestInRegularAndScriptAsync
(
@"#nullable enable
class Class
{
void M()
{
string? s = null;
new [|T|](s);
}
}"
,
@"#nullable enable
class Class
{
void M()
{
string? s = null;
new [|T|](s);
}
}
internal class T
{
private string? s;
public T(string? s)
{
this.s = s;
}
}"
,
parseOptions
:
TestOptions
.
Regular8WithNullableAnalysis
,
index
:
1
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
GenerateWithNullableParameterThatIsNotNull
()
{
await
TestInRegularAndScriptAsync
(
@"#nullable enable
class Class
{
void M()
{
string? s = ""asdf"";
new [|T|](s);
}
}"
,
@"#nullable enable
class Class
{
void M()
{
string? s = ""asdf"";
new [|T|](s);
}
}
internal class T
{
private string s;
public T(string s)
{
this.s = s;
}
}"
,
parseOptions
:
TestOptions
.
Regular8WithNullableAnalysis
,
index
:
1
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
GenerateWithNamedParameter
()
{
...
...
@@ -2109,6 +2202,41 @@ protected Base(out int o)
index
:
1
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
GenerateWithDelegatingConstructorAssigningToNullableField
()
{
await
TestInRegularAndScriptAsync
(
@"#nullable enable
class Class
{
void M()
{
Base? b = new [|T|]();
}
}
class Base
{
}"
,
@"#nullable enable
class Class
{
void M()
{
Base? b = new [|T|]();
}
}
internal class T : Base
{
}
class Base
{
}"
,
index
:
1
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsGenerateType
)]
public
async
Task
GenerateWithNonDelegatingConstructor1
()
{
...
...
src/Features/Core/Portable/GenerateType/AbstractGenerateTypeService.State.cs
浏览文件 @
07287fa4
...
...
@@ -245,7 +245,9 @@ private void SetBaseType(INamedTypeSymbol baseType)
return
;
}
this
.
BaseTypeOrInterfaceOpt
=
baseType
;
// Strip off top-level nullability since we can't put top-level nullability into the base list. We will still include nested nullability
// if you're deriving some interface like IEnumerable<string?>.
this
.
BaseTypeOrInterfaceOpt
=
baseType
.
WithNullability
(
NullableAnnotation
.
NotApplicable
);
}
private
bool
GenerateStruct
(
TService
service
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录