Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
6bcf048a
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,发现更多精彩内容 >>
提交
6bcf048a
编写于
7月 10, 2018
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Misc.
上级
aacb8bc6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
19 deletion
+43
-19
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
+14
-14
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
...rp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
+25
-1
src/Compilers/Core/Portable/Operations/OperationKind.cs
src/Compilers/Core/Portable/Operations/OperationKind.cs
+2
-2
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
+1
-1
src/VisualStudio/Core/Test/ObjectBrowser/CSharp/ObjectBrowerTests.vb
...tudio/Core/Test/ObjectBrowser/CSharp/ObjectBrowerTests.vb
+1
-1
未找到文件。
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
浏览文件 @
6bcf048a
...
@@ -616,16 +616,16 @@ private void InheritNullableStateOfTrackableStruct(TypeSymbol targetType, int ta
...
@@ -616,16 +616,16 @@ private void InheritNullableStateOfTrackableStruct(TypeSymbol targetType, int ta
// See ModifyMembers_StructPropertyNoBackingField and PropertyCycle_Struct tests.
// See ModifyMembers_StructPropertyNoBackingField and PropertyCycle_Struct tests.
foreach
(
var
field
in
_emptyStructTypeCache
.
GetStructInstanceFields
(
targetType
))
foreach
(
var
field
in
_emptyStructTypeCache
.
GetStructInstanceFields
(
targetType
))
{
{
InheritNullableStateOf
FieldOrProperty
(
targetSlot
,
valueSlot
,
field
,
isByRefTarget
,
slotWatermark
);
InheritNullableStateOf
Member
(
targetSlot
,
valueSlot
,
field
,
isByRefTarget
,
slotWatermark
);
}
}
}
}
// 'slotWatermark' is used to avoid inheriting members from inherited members.
// 'slotWatermark' is used to avoid inheriting members from inherited members.
private
void
InheritNullableStateOf
FieldOrProperty
(
int
targetContainerSlot
,
int
valueContainerSlot
,
Symbol
fieldOrProperty
,
bool
isByRefTarget
,
int
slotWatermark
)
private
void
InheritNullableStateOf
Member
(
int
targetContainerSlot
,
int
valueContainerSlot
,
Symbol
member
,
bool
isByRefTarget
,
int
slotWatermark
)
{
{
Debug
.
Assert
(
valueContainerSlot
<=
slotWatermark
);
Debug
.
Assert
(
valueContainerSlot
<=
slotWatermark
);
TypeSymbolWithAnnotations
fieldOrPropertyType
=
fieldOrProperty
.
GetTypeOrReturnType
();
TypeSymbolWithAnnotations
fieldOrPropertyType
=
member
.
GetTypeOrReturnType
();
if
(
fieldOrPropertyType
.
IsReferenceType
)
if
(
fieldOrPropertyType
.
IsReferenceType
)
{
{
...
@@ -633,17 +633,17 @@ private void InheritNullableStateOfFieldOrProperty(int targetContainerSlot, int
...
@@ -633,17 +633,17 @@ private void InheritNullableStateOfFieldOrProperty(int targetContainerSlot, int
// Declaration information takes priority.
// Declaration information takes priority.
if
(
fieldOrPropertyType
.
IsNullable
!=
false
)
if
(
fieldOrPropertyType
.
IsNullable
!=
false
)
{
{
int
targetMemberSlot
=
GetOrCreateSlot
(
fieldOrProperty
,
targetContainerSlot
);
int
targetMemberSlot
=
GetOrCreateSlot
(
member
,
targetContainerSlot
);
bool
?
value
=
!
fieldOrPropertyType
.
IsNullable
;
bool
?
value
=
!
fieldOrPropertyType
.
IsNullable
;
if
(
isByRefTarget
)
if
(
isByRefTarget
)
{
{
// This is a
property/field
access through a by ref entity and it isn't considered declared as not-nullable.
// This is a
member
access through a by ref entity and it isn't considered declared as not-nullable.
// Since reference can point to the heap, we cannot assume the
property/field doesn't have null value after this assignment,
// Since reference can point to the heap, we cannot assume the
member doesn't have null value
// regardless of what value is being assigned.
//
after this assignment,
regardless of what value is being assigned.
}
}
else
if
(
valueContainerSlot
>
0
)
else
if
(
valueContainerSlot
>
0
)
{
{
int
valueMemberSlot
=
VariableSlot
(
fieldOrProperty
,
valueContainerSlot
);
int
valueMemberSlot
=
VariableSlot
(
member
,
valueContainerSlot
);
value
=
valueMemberSlot
>
0
&&
valueMemberSlot
<
this
.
State
.
Capacity
?
value
=
valueMemberSlot
>
0
&&
valueMemberSlot
<
this
.
State
.
Capacity
?
this
.
State
[
valueMemberSlot
]
:
this
.
State
[
valueMemberSlot
]
:
null
;
null
;
...
@@ -654,23 +654,23 @@ private void InheritNullableStateOfFieldOrProperty(int targetContainerSlot, int
...
@@ -654,23 +654,23 @@ private void InheritNullableStateOfFieldOrProperty(int targetContainerSlot, int
if
(
valueContainerSlot
>
0
)
if
(
valueContainerSlot
>
0
)
{
{
int
valueMemberSlot
=
VariableSlot
(
fieldOrProperty
,
valueContainerSlot
);
int
valueMemberSlot
=
VariableSlot
(
member
,
valueContainerSlot
);
if
(
valueMemberSlot
>
0
&&
valueMemberSlot
<=
slotWatermark
)
if
(
valueMemberSlot
>
0
&&
valueMemberSlot
<=
slotWatermark
)
{
{
int
targetMemberSlot
=
GetOrCreateSlot
(
fieldOrProperty
,
targetContainerSlot
);
int
targetMemberSlot
=
GetOrCreateSlot
(
member
,
targetContainerSlot
);
InheritNullableStateOfTrackableType
(
targetMemberSlot
,
valueMemberSlot
,
isByRefTarget
,
slotWatermark
);
InheritNullableStateOfTrackableType
(
targetMemberSlot
,
valueMemberSlot
,
isByRefTarget
,
slotWatermark
);
}
}
}
}
}
}
else
if
(
EmptyStructTypeCache
.
IsTrackableStructType
(
fieldOrPropertyType
.
TypeSymbol
))
else
if
(
EmptyStructTypeCache
.
IsTrackableStructType
(
fieldOrPropertyType
.
TypeSymbol
))
{
{
int
targetMemberSlot
=
GetOrCreateSlot
(
fieldOrProperty
,
targetContainerSlot
);
int
targetMemberSlot
=
GetOrCreateSlot
(
member
,
targetContainerSlot
);
if
(
targetMemberSlot
>
0
)
if
(
targetMemberSlot
>
0
)
{
{
int
valueMemberSlot
=
-
1
;
int
valueMemberSlot
=
-
1
;
if
(
valueContainerSlot
>
0
)
if
(
valueContainerSlot
>
0
)
{
{
int
slot
=
GetOrCreateSlot
(
fieldOrProperty
,
valueContainerSlot
);
int
slot
=
GetOrCreateSlot
(
member
,
valueContainerSlot
);
if
(
slot
<
slotWatermark
)
if
(
slot
<
slotWatermark
)
{
{
valueMemberSlot
=
slot
;
valueMemberSlot
=
slot
;
...
@@ -712,8 +712,8 @@ private void InheritNullableStateOfTrackableType(int targetSlot, int valueSlot,
...
@@ -712,8 +712,8 @@ private void InheritNullableStateOfTrackableType(int targetSlot, int valueSlot,
continue
;
continue
;
}
}
var
member
=
variable
.
Symbol
;
var
member
=
variable
.
Symbol
;
Debug
.
Assert
(
member
.
Kind
==
SymbolKind
.
Field
||
member
.
Kind
==
SymbolKind
.
Property
);
Debug
.
Assert
(
member
.
Kind
==
SymbolKind
.
Field
||
member
.
Kind
==
SymbolKind
.
Property
||
member
.
Kind
==
SymbolKind
.
Event
);
InheritNullableStateOf
FieldOrProperty
(
targetSlot
,
valueSlot
,
member
,
isByRefTarget
,
slotWatermark
);
InheritNullableStateOf
Member
(
targetSlot
,
valueSlot
,
member
,
isByRefTarget
,
slotWatermark
);
}
}
}
}
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
浏览文件 @
6bcf048a
...
@@ -238,7 +238,7 @@ class C
...
@@ -238,7 +238,7 @@ class C
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "int").WithArguments("System.Int32").WithLocation(4, 17));
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "int").WithArguments("System.Int32").WithLocation(4, 17));
}
}
[
Fact
]
[
ConditionalFact(typeof(DesktopOnly))
]
public void UnannotatedAssemblies_WithSomeExtraAnnotations()
public void UnannotatedAssemblies_WithSomeExtraAnnotations()
{
{
// PROTOTYPE(NullableReferenceTypes): external annotations should be removed or fully designed/productized
// PROTOTYPE(NullableReferenceTypes): external annotations should be removed or fully designed/productized
...
@@ -33885,6 +33885,30 @@ static void F()
...
@@ -33885,6 +33885,30 @@ static void F()
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "b.Q.P2").WithLocation(25, 9));
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "b.Q.P2").WithLocation(25, 9));
}
}
[Fact]
public void Members_ObjectInitializer_Events()
{
var source =
@"delegate void D();
class C
{
event D? E;
static void F()
{
C c;
c = new C() { };
c.E.Invoke(); // warning
c = new C() { E = F };
c.E.Invoke();
}
}";
var comp = CreateCompilation(source, parseOptions: TestOptions.Regular8);
comp.VerifyDiagnostics(
// (9,9): warning CS8602: Possible dereference of a null reference.
// c.E.Invoke(); // warning
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "c.E").WithLocation(9, 9));
}
// PROTOTYPE(NullableReferenceTypes): Support assignment of derived type instances.
// PROTOTYPE(NullableReferenceTypes): Support assignment of derived type instances.
[Fact(Skip = "TODO")]
[Fact(Skip = "TODO")]
public void Members_ObjectInitializer_DerivedType()
public void Members_ObjectInitializer_DerivedType()
src/Compilers/Core/Portable/Operations/OperationKind.cs
浏览文件 @
6bcf048a
...
@@ -192,8 +192,6 @@ public enum OperationKind
...
@@ -192,8 +192,6 @@ public enum OperationKind
ConstructorBodyOperation
=
0x59
,
ConstructorBodyOperation
=
0x59
,
/// <summary>Indicates an <see cref="IDiscardOperation"/>.</summary>
/// <summary>Indicates an <see cref="IDiscardOperation"/>.</summary>
Discard
=
0x5A
,
Discard
=
0x5A
,
/// <summary>Indicates an <see cref="ISuppressNullableWarningOperation"/>.</summary>
SuppressNullableWarning
=
0x5B
,
/// <summary>Indicates an <see cref="IFlowCaptureOperation"/>.</summary>
/// <summary>Indicates an <see cref="IFlowCaptureOperation"/>.</summary>
FlowCapture
=
0x5B
,
FlowCapture
=
0x5B
,
...
@@ -207,6 +205,8 @@ public enum OperationKind
...
@@ -207,6 +205,8 @@ public enum OperationKind
StaticLocalInitializationSemaphore
=
0x5F
,
StaticLocalInitializationSemaphore
=
0x5F
,
/// <summary>Indicates an <see cref="IFlowAnonymousFunctionOperation"/>.</summary>
/// <summary>Indicates an <see cref="IFlowAnonymousFunctionOperation"/>.</summary>
FlowAnonymousFunction
=
0x60
,
FlowAnonymousFunction
=
0x60
,
/// <summary>Indicates an <see cref="ISuppressNullableWarningOperation"/>.</summary>
SuppressNullableWarning
=
0x61
,
// /// <summary>Indicates an <see cref="IFixedOperation"/>.</summary>
// /// <summary>Indicates an <see cref="IFixedOperation"/>.</summary>
// https://github.com/dotnet/roslyn/issues/21281
// https://github.com/dotnet/roslyn/issues/21281
...
...
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
浏览文件 @
6bcf048a
...
@@ -15,7 +15,7 @@ Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation.Operand.get -> Microsoft.Co
...
@@ -15,7 +15,7 @@ Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation.Operand.get -> Microsoft.Co
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation.Local.get -> Microsoft.CodeAnalysis.ILocalSymbol
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation.Local.get -> Microsoft.CodeAnalysis.ILocalSymbol
Microsoft.CodeAnalysis.IOperation.SemanticModel.get -> Microsoft.CodeAnalysis.SemanticModel
Microsoft.CodeAnalysis.IOperation.SemanticModel.get -> Microsoft.CodeAnalysis.SemanticModel
Microsoft.CodeAnalysis.OperationKind.SuppressNullableWarning = 9
1
-> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.OperationKind.SuppressNullableWarning = 9
7
-> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.Operations.CommonConversion.IsImplicit.get -> bool
Microsoft.CodeAnalysis.Operations.CommonConversion.IsImplicit.get -> bool
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation.Expression.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation.Expression.get -> Microsoft.CodeAnalysis.IOperation
...
...
src/VisualStudio/Core/Test/ObjectBrowser/CSharp/ObjectBrowerTests.vb
浏览文件 @
6bcf048a
...
@@ -141,7 +141,7 @@ namespace N
...
@@ -141,7 +141,7 @@ namespace N
Using
state
=
CreateLibraryManager
(
GetWorkspaceDefinition
(
code
,
metaDatacode
,
False
))
Using
state
=
CreateLibraryManager
(
GetWorkspaceDefinition
(
code
,
metaDatacode
,
False
))
Dim
library
=
state
.
GetLibrary
()
Dim
library
=
state
.
GetLibrary
()
Dim
list
=
library
.
GetProjectList
().
GetReferenceList
(
0
).
GetNamespaceList
(
0
).
GetTypeList
(
0
)
Dim
list
=
library
.
GetProjectList
().
GetReferenceList
(
0
).
GetNamespaceList
(
0
).
GetTypeList
(
1
)
list
.
VerifyNames
(
"C"
,
"C.PublicEnumTest"
)
list
.
VerifyNames
(
"C"
,
"C.PublicEnumTest"
)
End
Using
End
Using
End
Sub
End
Sub
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录