Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4799748a
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,发现更多精彩内容 >>
未验证
提交
4799748a
编写于
6月 27, 2019
作者:
J
Joey Robichaud
提交者:
GitHub
6月 27, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #36821 from dotnet/merges/release/dev16.3-preview1-to-master
Merge release/dev16.3-preview1 to master
上级
ea4ab12b
e56d7421
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
159 addition
and
4 deletion
+159
-4
src/Compilers/CSharp/Portable/Symbols/TypeWithAnnotations.cs
src/Compilers/CSharp/Portable/Symbols/TypeWithAnnotations.cs
+6
-4
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Nullable.cs
...rs/CSharp/Test/Emit/Attributes/AttributeTests_Nullable.cs
+153
-0
未找到文件。
src/Compilers/CSharp/Portable/Symbols/TypeWithAnnotations.cs
浏览文件 @
4799748a
...
...
@@ -642,13 +642,15 @@ public bool ApplyNullableTransforms(byte defaultTransformFlag, ImmutableArray<by
TypeSymbol
oldTypeSymbol
=
Type
;
byte
transformFlag
;
if
(
transforms
.
IsDefault
)
// Check SkipNullableTransform first to avoid
// applying transforms to simple value types.
if
(
SkipNullableTransform
(
oldTypeSymbol
))
{
transformFlag
=
defaultTransformFlag
;
transformFlag
=
NullableAnnotationExtensions
.
ObliviousAttributeValue
;
}
else
if
(
SkipNullableTransform
(
oldTypeSymbol
)
)
else
if
(
transforms
.
IsDefault
)
{
transformFlag
=
NullableAnnotationExtensions
.
ObliviousAttributeValue
;
transformFlag
=
defaultTransformFlag
;
}
else
if
(
position
<
transforms
.
Length
)
{
...
...
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Nullable.cs
浏览文件 @
4799748a
...
...
@@ -3263,6 +3263,159 @@ private static void VerifyBytes(TypeWithAnnotations type, byte[] expectedPreviou
}
}
[
Fact
]
public
void
EmitAttribute_ValueTypes_09
()
{
var
source1
=
@"#nullable enable
public interface I
{
void M1(int x);
void M2(int[]? x);
void M3(int x, object? y);
}"
;
var
comp
=
CreateCompilation
(
source1
);
var
expected1
=
@"[NullableContext(2)] I
void M1(System.Int32 x)
System.Int32 x
void M2(System.Int32[]? x)
System.Int32[]? x
void M3(System.Int32 x, System.Object? y)
System.Int32 x
System.Object? y
"
;
AssertNullableAttributes
(
comp
,
expected1
);
var
ref0
=
comp
.
EmitToImageReference
();
var
source2
=
@"#nullable enable
class C : I
{
public void M1(int x) { }
public void M2(int[]? x) { }
public void M3(int x, object? y) { }
}"
;
comp
=
CreateCompilation
(
source2
,
references
:
new
[]
{
ref0
});
comp
.
VerifyDiagnostics
();
}
[
Fact
]
public
void
EmitAttribute_ValueTypes_10
()
{
var
source1
=
@"#nullable enable
public class C<T> { }
public interface I1
{
void M(int x, object? y, object? z);
}
public interface I2
{
void M(C<int>? x, object? y, object? z);
}"
;
var
comp
=
CreateCompilation
(
source1
);
var
expected1
=
@"C<T>
[Nullable(2)] T
[NullableContext(2)] I1
void M(System.Int32 x, System.Object? y, System.Object? z)
System.Int32 x
System.Object? y
System.Object? z
[NullableContext(2)] I2
void M(C<System.Int32>? x, System.Object? y, System.Object? z)
C<System.Int32>? x
System.Object? y
System.Object? z
"
;
AssertNullableAttributes
(
comp
,
expected1
);
var
ref0
=
comp
.
EmitToImageReference
();
var
source2
=
@"#nullable enable
class C1 : I1
{
public void M(int x, object? y, object? z) { }
}
class C2 : I2
{
public void M(C<int>? x, object? y, object? z) { }
}"
;
comp
=
CreateCompilation
(
source2
,
references
:
new
[]
{
ref0
});
comp
.
VerifyDiagnostics
();
}
[
Fact
]
public
void
EmitAttribute_ValueTypes_11
()
{
var
source1
=
@"#nullable enable
public interface I1<T>
{
void M(T x, object? y, object? z);
}
public interface I2<T> where T : class
{
void M(T? x, object? y, object? z);
}
public interface I3<T> where T : struct
{
void M(T x, object? y, object? z);
}"
;
var
comp
=
CreateCompilation
(
source1
);
var
expected1
=
@"[NullableContext(2)] I1<T>
T
void M(T x, System.Object? y, System.Object? z)
[Nullable(1)] T x
System.Object? y
System.Object? z
[NullableContext(1)] I2<T> where T : class!
T
[NullableContext(2)] void M(T? x, System.Object? y, System.Object? z)
T? x
System.Object? y
System.Object? z
I3<T> where T : struct
[NullableContext(2)] void M(T x, System.Object? y, System.Object? z)
[Nullable(0)] T x
System.Object? y
System.Object? z
"
;
AssertNullableAttributes
(
comp
,
expected1
);
var
ref0
=
comp
.
EmitToImageReference
();
var
source2
=
@"#nullable enable
class C1A<T> : I1<T> where T : struct
{
public void M(T x, object? y, object? z) { }
}
class C1B : I1<int>
{
public void M(int x, object? y, object? z) { }
}
class C2A<T> : I2<T> where T : class
{
public void M(T? x, object? y, object? z) { }
}
class C2B : I2<string>
{
public void M(string? x, object? y, object? z) { }
}
class C3A<T> : I3<T> where T : struct
{
public void M(T x, object? y, object? z) { }
}
class C3B : I3<int>
{
public void M(int x, object? y, object? z) { }
}"
;
comp
=
CreateCompilation
(
source2
,
references
:
new
[]
{
ref0
});
comp
.
VerifyDiagnostics
();
}
[
Fact
]
public
void
UseSiteError_LambdaReturnType
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录