Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
26701e9e
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,发现更多精彩内容 >>
未验证
提交
26701e9e
编写于
2月 28, 2020
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more tests, adjust existing baseline.
上级
c53fa479
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
118 addition
and
6 deletion
+118
-6
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenNullCoalescingAssignmentTests.cs
...Test/Emit/CodeGen/CodeGenNullCoalescingAssignmentTests.cs
+0
-3
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
...rp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
+118
-3
未找到文件。
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenNullCoalescingAssignmentTests.cs
浏览文件 @
26701e9e
...
...
@@ -2595,9 +2595,6 @@ void M(in object o1, out object o2)
}"
;
CreateCompilation
(
source
).
VerifyDiagnostics
(
// (4,10): error CS0177: The out parameter 'o2' must be assigned to before control leaves the current method
// void M(in object o1, out object o2)
Diagnostic
(
ErrorCode
.
ERR_ParamUnassigned
,
"M"
).
WithArguments
(
"o2"
).
WithLocation
(
4
,
10
),
// (6,9): error CS8331: Cannot assign to variable 'in object' because it is a readonly variable
// o1 ??= null;
Diagnostic
(
ErrorCode
.
ERR_AssignReadonlyNotField
,
"o1"
).
WithArguments
(
"variable"
,
"in object"
).
WithLocation
(
6
,
9
),
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
浏览文件 @
26701e9e
...
...
@@ -108754,12 +108754,12 @@ void M1(int? i)
[Fact]
[WorkItem(41273, "https://github.com/dotnet/roslyn/issues/41273")]
public void NullCoalescingAssignment_InTry
Finally
()
public void NullCoalescingAssignment_InTry
CatchFinally01
()
{
var source = @"
using System;
public class C
{
public class C
{
string x;
public C()
...
...
@@ -108779,6 +108779,121 @@ public C()
comp.VerifyDiagnostics();
}
[Fact]
[WorkItem(41273, "https://github.com/dotnet/roslyn/issues/41273")]
public void NullCoalescingAssignment_InTryCatchFinally02()
{
var source = @"
using System;
public class C
{
string x;
public C()
{
try
{
}
catch (Exception)
{
x ??= """";
}
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (7,12): warning CS8618: Non-nullable field 'x' is uninitialized. Consider declaring the field as nullable.
// public C()
Diagnostic(ErrorCode.WRN_UninitializedNonNullableField, "C").WithArguments("field", "x").WithLocation(7, 12)
);
}
[Fact]
[WorkItem(41273, "https://github.com/dotnet/roslyn/issues/41273")]
public void NullCoalescingAssignment_InTryCatchFinally03()
{
var source = @"
public class C {
string x;
public C()
{
try
{
}
finally
{
x ??= """";
}
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics();
}
[Fact]
[WorkItem(41273, "https://github.com/dotnet/roslyn/issues/41273")]
public void NullCoalescingAssignment_InTryCatchFinally04()
{
var source = @"
public class C
{
string x;
public C()
{
try
{
x = """";
}
finally
{
x ??= null;
}
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (14,19): warning CS8625: Cannot convert null literal to non-nullable reference type.
// x ??= null;
Diagnostic(ErrorCode.WRN_NullAsNonNullable, "null").WithLocation(14, 19)
);
}
[Fact]
[WorkItem(41273, "https://github.com/dotnet/roslyn/issues/41273")]
public void NullCoalescingAssignment_InTryCatchFinally05()
{
var source = @"
using System;
public class C
{
string x;
public C()
{
try
{
x = """";
}
catch (Exception)
{
x ??= null;
}
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (15,19): warning CS8625: Cannot convert null literal to non-nullable reference type.
// x ??= null;
Diagnostic(ErrorCode.WRN_NullAsNonNullable, "null").WithLocation(15, 19)
);
}
[Fact]
public void Deconstruction_01()
{
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录