Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bda48318
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,发现更多精彩内容 >>
提交
bda48318
编写于
7月 29, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use simpler null checks
上级
32149eb8
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
33 addition
and
33 deletion
+33
-33
src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
+2
-2
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
+4
-4
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
...Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
+2
-2
src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs
...ompilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs
src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs
+2
-2
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+1
-1
src/Compilers/CSharp/Portable/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs
...le/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs
+1
-1
src/Compilers/CSharp/Portable/Errors/MessageID.cs
src/Compilers/CSharp/Portable/Errors/MessageID.cs
+1
-1
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
+3
-3
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs
...le/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs
...ers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs
.../CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
...ers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
...rp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
+3
-3
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs
...Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs
+1
-1
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
+1
-1
src/Compilers/Core/Portable/Compilation/Compilation.cs
src/Compilers/Core/Portable/Compilation/Compilation.cs
+1
-1
src/Compilers/Core/Portable/Operations/Operation.cs
src/Compilers/Core/Portable/Operations/Operation.cs
+1
-1
src/Workspaces/Core/Portable/Workspace/Host/SyntaxTreeFactory/AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs
...SyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs
+2
-2
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
浏览文件 @
bda48318
...
...
@@ -3072,7 +3072,7 @@ internal enum AddressKind
bool
peVerifyCompatEnabled
,
HashSet
<
LocalSymbol
>
stackLocalsOpt
)
{
Debug
.
Assert
(
!(
method
is
null
)
);
Debug
.
Assert
(
method
is
object
);
switch
(
expression
.
Kind
)
{
...
...
@@ -3199,7 +3199,7 @@ internal enum AddressKind
bool
peVerifyCompatEnabled
,
HashSet
<
LocalSymbol
>
stackLocalsOpt
)
{
Debug
.
Assert
(
!(
method
is
null
)
);
Debug
.
Assert
(
method
is
object
);
FieldSymbol
field
=
fieldAccess
.
FieldSymbol
;
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Attributes.cs
浏览文件 @
bda48318
...
...
@@ -166,7 +166,7 @@ private BoundAttribute BindAttributeCore(AttributeSyntax node, NamedTypeSymbol a
}
diagnostics
.
Add
(
node
,
useSiteDiagnostics
);
if
(
!(
attributeConstructor
is
null
)
)
if
(
attributeConstructor
is
object
)
{
ReportDiagnosticsIfObsolete
(
diagnostics
,
attributeConstructor
,
node
,
hasBaseReceiver
:
false
);
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
浏览文件 @
bda48318
...
...
@@ -2052,7 +2052,7 @@ private BoundExpression BindRangeExpression(RangeExpressionSyntax node, Diagnost
memberOpt
=
WellKnownMember
.
System_Range__StartAt
;
}
if
(
!(
memberOpt
is
null
)
)
if
(
memberOpt
is
object
)
{
symbolOpt
=
(
MethodSymbol
)
GetWellKnownTypeMember
(
Compilation
,
...
...
@@ -7048,7 +7048,7 @@ private BoundExpression ConvertToArrayIndex(BoundExpression index, SyntaxNode no
if
(
result
is
null
)
{
result
=
TryImplicitConversionToArrayIndex
(
index
,
WellKnownType
.
System_Range
,
node
,
diagnostics
);
if
(
!(
result
is
null
)
)
if
(
result
is
object
)
{
// This member is needed for lowering and should produce an error if not present
_
=
GetWellKnownTypeMember
(
...
...
@@ -7097,7 +7097,7 @@ private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr,
var
attemptDiagnostics
=
DiagnosticBag
.
GetInstance
();
var
result
=
TryImplicitConversionToArrayIndex
(
expr
,
type
,
node
,
attemptDiagnostics
);
if
(
!(
result
is
null
)
)
if
(
result
is
object
)
{
diagnostics
.
AddRange
(
attemptDiagnostics
);
}
...
...
@@ -7113,7 +7113,7 @@ private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr,
var
result
=
TryImplicitConversionToArrayIndex
(
expr
,
type
,
node
,
attemptDiagnostics
);
if
(
!(
result
is
null
)
)
if
(
result
is
object
)
{
diagnostics
.
AddRange
(
attemptDiagnostics
);
}
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
浏览文件 @
bda48318
...
...
@@ -689,7 +689,7 @@ private BoundStatement BindDeclarationStatementParts(LocalDeclarationStatementSy
/// <returns>The <see cref="MethodSymbol"/> of the Dispose method if one is found, otherwise null.</returns>
internal
MethodSymbol
TryFindDisposePatternMethod
(
BoundExpression
expr
,
SyntaxNode
syntaxNode
,
bool
hasAwait
,
DiagnosticBag
diagnostics
)
{
Debug
.
Assert
(
!(
expr
is
null
)
);
Debug
.
Assert
(
expr
is
object
);
Debug
.
Assert
(!(
expr
.
Type
is
null
));
Debug
.
Assert
(
expr
.
Type
.
IsRefLikeType
||
hasAwait
);
// pattern dispose lookup is only valid on ref structs or asynchronous usings
...
...
src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
浏览文件 @
bda48318
...
...
@@ -868,7 +868,7 @@ private void GetDisposalInfoForEnumerator(ref ForEachEnumeratorInfo.Builder buil
var
patternDisposeDiags
=
new
DiagnosticBag
();
var
receiver
=
new
BoundDisposableValuePlaceholder
(
_syntax
,
enumeratorType
);
MethodSymbol
disposeMethod
=
TryFindDisposePatternMethod
(
receiver
,
_syntax
,
isAsync
,
patternDisposeDiags
);
if
(
!(
disposeMethod
is
null
)
)
if
(
disposeMethod
is
object
)
{
builder
.
NeedsDisposal
=
true
;
builder
.
DisposeMethod
=
disposeMethod
;
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
浏览文件 @
bda48318
...
...
@@ -62,7 +62,7 @@ internal static class AccessCheck
/// </summary>
internal
static
bool
IsEffectivelyPublicOrInternal
(
Symbol
symbol
,
out
bool
isInternal
)
{
Debug
.
Assert
(
!(
symbol
is
null
)
);
Debug
.
Assert
(
symbol
is
object
);
switch
(
symbol
.
Kind
)
{
...
...
@@ -101,7 +101,7 @@ internal static bool IsEffectivelyPublicOrInternal(Symbol symbol, out bool isInt
symbol
=
symbol
.
ContainingType
;
}
while
(
!(
symbol
is
null
)
);
while
(
symbol
is
object
);
return
true
;
}
...
...
src/Compilers/CSharp/Portable/Binder/SwitchExpressionBinder.cs
浏览文件 @
bda48318
...
...
@@ -125,7 +125,7 @@ private TypeSymbol InferResultType(ImmutableArray<BoundSwitchExpressionArm> swit
foreach
(
var
@case
in
switchCases
)
{
var
type
=
@case
.
Value
.
Type
;
if
(
!(
type
is
null
)
&&
seenTypes
.
Add
(
type
))
if
(
type
is
object
&&
seenTypes
.
Add
(
type
))
{
typesInOrder
.
Add
(
type
);
}
...
...
src/Compilers/CSharp/Portable/Binder/UsingStatementBinder.cs
浏览文件 @
bda48318
...
...
@@ -189,14 +189,14 @@ bool populateDisposableConversionOrDisposeMethod(bool fromExpression)
// If this is a ref struct, or we're in a valid asynchronous using, try binding via pattern.
// We won't need to try and bind a second time if it fails, as async dispose can't be pattern based (ref structs are not allowed in async methods)
if
(
!(
type
is
null
)
&&
(
type
.
IsRefLikeType
||
hasAwait
))
if
(
type
is
object
&&
(
type
.
IsRefLikeType
||
hasAwait
))
{
BoundExpression
receiver
=
fromExpression
?
expressionOpt
:
new
BoundLocal
(
syntax
,
declarationsOpt
[
0
].
LocalSymbol
,
null
,
type
)
{
WasCompilerGenerated
=
true
};
disposeMethodOpt
=
originalBinder
.
TryFindDisposePatternMethod
(
receiver
,
syntax
,
hasAwait
,
diagnostics
);
if
(
!(
disposeMethodOpt
is
null
)
)
if
(
disposeMethodOpt
is
object
)
{
if
(
hasAwait
)
{
...
...
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
bda48318
...
...
@@ -3326,7 +3326,7 @@ internal bool EmitNullablePublicOnly
internal
bool
ShouldEmitNullableAttributes
(
Symbol
symbol
)
{
Debug
.
Assert
(
!(
symbol
is
null
)
);
Debug
.
Assert
(
symbol
is
object
);
Debug
.
Assert
(
symbol
.
IsDefinition
);
if
(
symbol
.
ContainingModule
!=
SourceModule
)
...
...
src/Compilers/CSharp/Portable/Errors/LazyMissingNonNullTypesContextDiagnosticInfo.cs
浏览文件 @
bda48318
...
...
@@ -36,7 +36,7 @@ private static void GetRawDiagnosticInfos(bool isNullableEnabled, CSharpParseOpt
{
const
MessageID
featureId
=
MessageID
.
IDS_FeatureNullableReferenceTypes
;
var
info
=
featureId
.
GetFeatureAvailabilityDiagnosticInfoOpt
(
options
);
if
(
!(
info
is
null
)
)
if
(
info
is
object
)
{
infos
.
Add
(
info
);
}
...
...
src/Compilers/CSharp/Portable/Errors/MessageID.cs
浏览文件 @
bda48318
...
...
@@ -233,7 +233,7 @@ internal static string RequiredFeature(this MessageID feature)
internal
static
bool
CheckFeatureAvailability
(
this
MessageID
feature
,
DiagnosticBag
diagnostics
,
Location
errorLocation
)
{
var
diag
=
GetFeatureAvailabilityDiagnosticInfoOpt
(
feature
,
(
CSharpParseOptions
)
errorLocation
.
SourceTree
.
Options
);
if
(
!(
diag
is
null
)
)
if
(
diag
is
object
)
{
diagnostics
.
Add
(
diag
,
errorLocation
);
return
false
;
...
...
src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
浏览文件 @
bda48318
...
...
@@ -412,7 +412,7 @@ protected override ImmutableArray<PendingBranch> Scan(ref bool badRegion)
{
ParameterSymbol
methodThisParameter
=
MethodThisParameter
;
EnterParameters
();
// assign parameters
if
(
!(
methodThisParameter
is
null
)
)
if
(
methodThisParameter
is
object
)
{
EnterParameter
(
methodThisParameter
,
methodThisParameter
.
TypeWithAnnotations
);
}
...
...
@@ -1869,7 +1869,7 @@ public override BoundNode VisitAnonymousObjectCreationExpression(BoundAnonymousO
TrackNullableStateForAssignment
(
argument
,
property
.
TypeWithAnnotations
,
GetOrCreateSlot
(
property
,
receiverSlot
),
argumentType
,
MakeSlot
(
argument
));
var
currentDeclaration
=
getDeclaration
(
node
,
property
,
ref
currentDeclarationIndex
);
if
(
!(
currentDeclaration
is
null
)
)
if
(
currentDeclaration
is
object
)
{
TakeIncrementalSnapshot
(
currentDeclaration
);
SetAnalyzedNullability
(
currentDeclaration
,
new
VisitResult
(
argumentType
,
property
.
TypeWithAnnotations
));
...
...
@@ -2509,7 +2509,7 @@ public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperato
TypeSymbol
getLeftResultType
(
TypeSymbol
leftType
,
TypeSymbol
rightType
)
{
Debug
.
Assert
(
!(
rightType
is
null
)
);
Debug
.
Assert
(
rightType
is
object
);
// If there was an identity conversion between the two operands (in short, if there
// is no implicit conversion on the right operand), then check nullable conversions
// in both directions since it's possible the right operand is the better result type.
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UsingStatement.cs
浏览文件 @
bda48318
...
...
@@ -424,7 +424,7 @@ private BoundExpression GenerateDisposeCall(SyntaxNode syntax, BoundExpression d
{
disposeCall
=
MakeCallWithNoExplicitArgument
(
syntax
,
disposedExpression
,
methodOpt
);
if
(
!(
awaitOpt
is
null
)
)
if
(
awaitOpt
is
object
)
{
// await local.DisposeAsync()
_sawAwaitInExceptionHandler
=
true
;
...
...
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEModuleSymbol.cs
浏览文件 @
bda48318
...
...
@@ -711,7 +711,7 @@ internal IEnumerable<NamedTypeSymbol> GetForwardedTypes()
internal
bool
ShouldDecodeNullableAttributes
(
Symbol
symbol
)
{
Debug
.
Assert
(
!(
symbol
is
null
)
);
Debug
.
Assert
(
symbol
is
object
);
Debug
.
Assert
(
symbol
.
IsDefinition
);
Debug
.
Assert
((
object
)
symbol
.
ContainingModule
==
this
);
...
...
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PENamedTypeSymbol.cs
浏览文件 @
bda48318
...
...
@@ -434,7 +434,7 @@ private NamedTypeSymbol GetDeclaredBaseType(bool skipTransformsIfNecessary)
if
(
ReferenceEquals
(
_lazyDeclaredBaseType
,
ErrorTypeSymbol
.
UnknownResultType
))
{
var
baseType
=
MakeDeclaredBaseType
();
if
(
!(
baseType
is
null
)
)
if
(
baseType
is
object
)
{
if
(
skipTransformsIfNecessary
)
{
...
...
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
浏览文件 @
bda48318
...
...
@@ -229,7 +229,7 @@ internal void ComputeReturnType()
// Skip some diagnostics when the local function is not associated with a compilation
// (specifically, local functions nested in expressions in the EE).
if
(
!(
compilation
is
null
)
)
if
(
compilation
is
object
)
{
if
(
this
.
IsAsync
)
{
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs
浏览文件 @
bda48318
...
...
@@ -3339,7 +3339,7 @@ private void AddAccessorIfAvailable(ArrayBuilder<Symbol> symbols, MethodSymbol a
var
builder
=
new
MostCommonNullableValueBuilder
();
var
baseType
=
BaseTypeNoUseSiteDiagnostics
;
if
(
!(
baseType
is
null
)
)
if
(
baseType
is
object
)
{
builder
.
AddValue
(
TypeWithAnnotations
.
Create
(
baseType
));
}
...
...
@@ -3366,7 +3366,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r
var
compilation
=
DeclaringCompilation
;
NamedTypeSymbol
baseType
=
this
.
BaseTypeNoUseSiteDiagnostics
;
if
(
!(
baseType
is
null
)
)
if
(
baseType
is
object
)
{
if
(
baseType
.
ContainsDynamic
())
{
...
...
@@ -3386,7 +3386,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeNullableContextAttribute
(
this
,
nullableContextValue
));
}
if
(
!(
baseType
is
null
)
)
if
(
baseType
is
object
)
{
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeNullableAttributeIfNecessary
(
this
,
nullableContextValue
,
TypeWithAnnotations
.
Create
(
baseType
)));
}
...
...
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_NullablePublicOnly.cs
浏览文件 @
bda48318
...
...
@@ -593,7 +593,7 @@ private static void AssertNullablePublicOnlyAttribute(ModuleSymbol module, bool
type
=
attribute
.
AttributeClass
;
}
}
if
(
!(
type
is
null
)
)
if
(
type
is
object
)
{
Assert
.
Equal
(
publicDefinition
?
Accessibility
.
Public
:
Accessibility
.
Internal
,
type
.
DeclaredAccessibility
);
}
...
...
src/Compilers/CSharp/Test/Emit/Emit/EndToEndTests.cs
浏览文件 @
bda48318
...
...
@@ -37,7 +37,7 @@ private static void RunInThread(Action action)
thread
.
Start
();
thread
.
Join
();
if
(
!(
exception
is
null
)
)
if
(
exception
is
object
)
{
throw
exception
;
}
...
...
src/Compilers/Core/Portable/Compilation/Compilation.cs
浏览文件 @
bda48318
...
...
@@ -1261,7 +1261,7 @@ public bool HasImplicitConversion(ITypeSymbol fromType, ITypeSymbol toType)
checkInCompilationReferences
(
symbol
,
nameof
(
symbol
));
checkInCompilationReferences
(
within
,
nameof
(
within
));
if
(
!(
throughType
is
null
)
)
if
(
throughType
is
object
)
{
checkInCompilationReferences
(
throughType
,
nameof
(
throughType
));
}
...
...
src/Compilers/Core/Portable/Operations/Operation.cs
浏览文件 @
bda48318
...
...
@@ -181,7 +181,7 @@ protected void SetParentOperation(IOperation parent)
[
Conditional
(
"DEBUG"
)]
internal
static
void
VerifyParentOperation
(
IOperation
parent
,
IOperation
child
)
{
if
(
!(
child
is
null
)
)
if
(
child
is
object
)
{
Debug
.
Assert
((
object
)
child
.
Parent
==
parent
);
}
...
...
src/Workspaces/Core/Portable/Workspace/Host/SyntaxTreeFactory/AbstractSyntaxTreeFactoryService.AbstractRecoverableSyntaxRoot.cs
浏览文件 @
bda48318
...
...
@@ -32,7 +32,7 @@ internal struct SyntaxTreeInfo
int
length
,
ImmutableDictionary
<
string
,
ReportDiagnostic
>
diagnosticOptions
)
{
Debug
.
Assert
(
!(
diagnosticOptions
is
null
)
);
Debug
.
Assert
(
diagnosticOptions
is
object
);
FilePath
=
filePath
??
string
.
Empty
;
Options
=
options
;
...
...
@@ -86,7 +86,7 @@ internal SyntaxTreeInfo WithOptionsAndLength(ParseOptions options, int length)
internal
SyntaxTreeInfo
WithDiagnosticOptions
(
ImmutableDictionary
<
string
,
ReportDiagnostic
>
options
)
{
Debug
.
Assert
(
!(
options
is
null
)
);
Debug
.
Assert
(
options
is
object
);
return
new
SyntaxTreeInfo
(
FilePath
,
Options
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录