Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
5bb48dbd
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,发现更多精彩内容 >>
未验证
提交
5bb48dbd
编写于
10月 19, 2018
作者:
C
Charles Stoner
提交者:
GitHub
10月 19, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set null state on dereference (#30564)
上级
c20eae14
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
803 addition
and
208 deletion
+803
-208
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
+22
-0
src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs
...s/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs
+1
-1
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
...rp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
+779
-206
src/Features/CSharp/Portable/ConvertForEachToFor/CSharpConvertForEachToForCodeRefactoringProvider.cs
...ToFor/CSharpConvertForEachToForCodeRefactoringProvider.cs
+1
-1
未找到文件。
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
浏览文件 @
5bb48dbd
...
@@ -1354,6 +1354,8 @@ public override BoundNode VisitArrayAccess(BoundArrayAccess node)
...
@@ -1354,6 +1354,8 @@ public override BoundNode VisitArrayAccess(BoundArrayAccess node)
Debug
.
Assert
(!
IsConditionalState
);
Debug
.
Assert
(!
IsConditionalState
);
Debug
.
Assert
(!
node
.
Expression
.
Type
.
IsValueType
);
Debug
.
Assert
(!
node
.
Expression
.
Type
.
IsValueType
);
// https://github.com/dotnet/roslyn/issues/30598: Mark receiver as not null
// after indices have been visited, and only if the receiver has not changed.
CheckPossibleNullReceiver
(
node
.
Expression
);
CheckPossibleNullReceiver
(
node
.
Expression
);
var
type
=
_resultType
.
TypeSymbol
as
ArrayTypeSymbol
;
var
type
=
_resultType
.
TypeSymbol
as
ArrayTypeSymbol
;
...
@@ -1943,6 +1945,8 @@ public override BoundNode VisitCall(BoundCall node)
...
@@ -1943,6 +1945,8 @@ public override BoundNode VisitCall(BoundCall node)
if
(
receiverOpt
!=
null
&&
method
.
MethodKind
!=
MethodKind
.
Constructor
)
if
(
receiverOpt
!=
null
&&
method
.
MethodKind
!=
MethodKind
.
Constructor
)
{
{
VisitRvalue
(
receiverOpt
);
VisitRvalue
(
receiverOpt
);
// https://github.com/dotnet/roslyn/issues/30598: Mark receiver as not null
// after arguments have been visited, and only if the receiver has not changed.
CheckPossibleNullReceiver
(
receiverOpt
);
CheckPossibleNullReceiver
(
receiverOpt
);
// Update method based on inferred receiver type: see https://github.com/dotnet/roslyn/issues/29605.
// Update method based on inferred receiver type: see https://github.com/dotnet/roslyn/issues/29605.
}
}
...
@@ -3303,6 +3307,10 @@ public override BoundNode VisitMethodGroup(BoundMethodGroup node)
...
@@ -3303,6 +3307,10 @@ public override BoundNode VisitMethodGroup(BoundMethodGroup node)
if
(
receiverOpt
!=
null
)
if
(
receiverOpt
!=
null
)
{
{
VisitRvalue
(
receiverOpt
);
VisitRvalue
(
receiverOpt
);
// https://github.com/dotnet/roslyn/issues/30563: Should not check receiver here.
// That check should be handled when applying the method group conversion,
// when we have a specific method, to avoid reporting null receiver warnings
// for extension method delegates.
CheckPossibleNullReceiver
(
receiverOpt
);
CheckPossibleNullReceiver
(
receiverOpt
);
}
}
...
@@ -3672,6 +3680,8 @@ public override BoundNode VisitIndexerAccess(BoundIndexerAccess node)
...
@@ -3672,6 +3680,8 @@ public override BoundNode VisitIndexerAccess(BoundIndexerAccess node)
{
{
var
receiverOpt
=
node
.
ReceiverOpt
;
var
receiverOpt
=
node
.
ReceiverOpt
;
VisitRvalue
(
receiverOpt
);
VisitRvalue
(
receiverOpt
);
// https://github.com/dotnet/roslyn/issues/30598: Mark receiver as not null
// after indices have been visited, and only if the receiver has not changed.
CheckPossibleNullReceiver
(
receiverOpt
);
CheckPossibleNullReceiver
(
receiverOpt
);
// https://github.com/dotnet/roslyn/issues/29964 Update indexer based on inferred receiver type.
// https://github.com/dotnet/roslyn/issues/29964 Update indexer based on inferred receiver type.
...
@@ -3698,6 +3708,8 @@ private void VisitMemberAccess(BoundExpression receiverOpt, Symbol member, bool
...
@@ -3698,6 +3708,8 @@ private void VisitMemberAccess(BoundExpression receiverOpt, Symbol member, bool
if
(!
member
.
IsStatic
)
if
(!
member
.
IsStatic
)
{
{
member
=
AsMemberOfResultType
(
member
);
member
=
AsMemberOfResultType
(
member
);
// https://github.com/dotnet/roslyn/issues/30598: For l-values, mark receiver as not null
// after RHS has been visited, and only if the receiver has not changed.
CheckPossibleNullReceiver
(
receiverOpt
);
CheckPossibleNullReceiver
(
receiverOpt
);
}
}
...
@@ -4206,6 +4218,8 @@ public override BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOpera
...
@@ -4206,6 +4218,8 @@ public override BoundNode VisitEventAssignmentOperator(BoundEventAssignmentOpera
var
receiverOpt
=
node
.
ReceiverOpt
;
var
receiverOpt
=
node
.
ReceiverOpt
;
if
(!
node
.
Event
.
IsStatic
)
if
(!
node
.
Event
.
IsStatic
)
{
{
// https://github.com/dotnet/roslyn/issues/30598: Mark receiver as not null
// after arguments have been visited, and only if the receiver has not changed.
CheckPossibleNullReceiver
(
receiverOpt
);
CheckPossibleNullReceiver
(
receiverOpt
);
}
}
VisitRvalue
(
node
.
Argument
);
VisitRvalue
(
node
.
Argument
);
...
@@ -4294,6 +4308,8 @@ public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess no
...
@@ -4294,6 +4308,8 @@ public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess no
{
{
var
receiver
=
node
.
ReceiverOpt
;
var
receiver
=
node
.
ReceiverOpt
;
VisitRvalue
(
receiver
);
VisitRvalue
(
receiver
);
// https://github.com/dotnet/roslyn/issues/30598: Mark receiver as not null
// after indices have been visited, and only if the receiver has not changed.
CheckPossibleNullReceiver
(
receiver
);
CheckPossibleNullReceiver
(
receiver
);
VisitArgumentsEvaluate
(
node
.
Arguments
,
node
.
ArgumentRefKindsOpt
);
VisitArgumentsEvaluate
(
node
.
Arguments
,
node
.
ArgumentRefKindsOpt
);
...
@@ -4309,6 +4325,7 @@ public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess no
...
@@ -4309,6 +4325,7 @@ public override BoundNode VisitDynamicIndexerAccess(BoundDynamicIndexerAccess no
private
void
CheckPossibleNullReceiver
(
BoundExpression
receiverOpt
)
private
void
CheckPossibleNullReceiver
(
BoundExpression
receiverOpt
)
{
{
Debug
.
Assert
(!
this
.
IsConditionalState
);
if
(
receiverOpt
!=
null
&&
this
.
State
.
Reachable
)
if
(
receiverOpt
!=
null
&&
this
.
State
.
Reachable
)
{
{
#if DEBUG
#if DEBUG
...
@@ -4320,6 +4337,11 @@ private void CheckPossibleNullReceiver(BoundExpression receiverOpt)
...
@@ -4320,6 +4337,11 @@ private void CheckPossibleNullReceiver(BoundExpression receiverOpt)
!
resultType
.
IsValueType
)
!
resultType
.
IsValueType
)
{
{
ReportDiagnostic
(
ErrorCode
.
WRN_NullReferenceReceiver
,
receiverOpt
.
Syntax
);
ReportDiagnostic
(
ErrorCode
.
WRN_NullReferenceReceiver
,
receiverOpt
.
Syntax
);
int
slot
=
MakeSlot
(
receiverOpt
);
if
(
slot
>
0
)
{
this
.
State
[
slot
]
=
true
;
}
}
}
}
}
}
}
...
...
src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs
浏览文件 @
5bb48dbd
...
@@ -312,7 +312,7 @@ protected override bool ConvertInsufficientExecutionStackExceptionToCancelledByS
...
@@ -312,7 +312,7 @@ protected override bool ConvertInsufficientExecutionStackExceptionToCancelledByS
/// <summary>
/// <summary>
/// A pending branch. These are created for a return, break, continue, goto statement,
/// A pending branch. These are created for a return, break, continue, goto statement,
/// yield return, yield break, await expression, await foreach/using, and if PreciseAbstractFlowPass.trackExceptions
/// yield return, yield break, await expression, await foreach/using, and if PreciseAbstractFlowPass.
_
trackExceptions
/// is true for other
/// is true for other
/// constructs that can cause an exception to be raised such as a throw statement or method
/// constructs that can cause an exception to be raised such as a throw statement or method
/// invocation.
/// invocation.
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
浏览文件 @
5bb48dbd
此差异已折叠。
点击以展开。
src/Features/CSharp/Portable/ConvertForEachToFor/CSharpConvertForEachToForCodeRefactoringProvider.cs
浏览文件 @
5bb48dbd
...
@@ -25,7 +25,7 @@ internal sealed class CSharpConvertForEachToForCodeRefactoringProvider :
...
@@ -25,7 +25,7 @@ internal sealed class CSharpConvertForEachToForCodeRefactoringProvider :
protected
override
ForEachStatementSyntax
GetForEachStatement
(
TextSpan
selection
,
SyntaxToken
token
)
protected
override
ForEachStatementSyntax
GetForEachStatement
(
TextSpan
selection
,
SyntaxToken
token
)
{
{
var
foreachStatement
=
token
.
Parent
.
FirstAncestorOrSelf
<
ForEachStatementSyntax
>();
var
foreachStatement
=
token
.
Parent
.
FirstAncestorOrSelf
<
ForEachStatementSyntax
>();
//
PROTOTYPE(async-streams)
: Add tests for this scenario
//
https://github.com/dotnet/roslyn/issues/30584
: Add tests for this scenario
if
(
foreachStatement
==
null
||
foreachStatement
.
AwaitKeyword
!=
default
)
if
(
foreachStatement
==
null
||
foreachStatement
.
AwaitKeyword
!=
default
)
{
{
return
null
;
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录