Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c1a0658e
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,发现更多精彩内容 >>
提交
c1a0658e
编写于
7月 11, 2017
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Misc. changes following merge 'upstream/master'
上级
037ce5aa
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
146 addition
and
138 deletion
+146
-138
src/Compilers/CSharp/Portable/BoundTree/Expression.cs
src/Compilers/CSharp/Portable/BoundTree/Expression.cs
+1
-1
src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs
src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs
+1
-1
src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs
src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs
+48
-57
src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
...mpilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
+0
-3
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_FixedStatement.cs
...le/Lowering/LocalRewriter/LocalRewriter_FixedStatement.cs
+2
-2
src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.cs
...p/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/DynamicTypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/DynamicTypeSymbol.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs
...pilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/PointerTypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/PointerTypeSymbol.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
...Sharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
+44
-42
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
...arp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
+36
-25
src/Compilers/CSharp/Portable/Symbols/Source/SourceTypeParameterSymbol.cs
...harp/Portable/Symbols/Source/SourceTypeParameterSymbol.cs
+2
-2
src/Compilers/CSharp/Portable/Symbols/SubstitutedTypeParameterSymbol.cs
...CSharp/Portable/Symbols/SubstitutedTypeParameterSymbol.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs
...ompilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedAccessorValueParameterSymbol.cs
...ls/Synthesized/SynthesizedAccessorValueParameterSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs
...rtable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs
+3
-3
src/Compilers/CSharp/Portable/Symbols/TypeParameterSymbol.cs
src/Compilers/CSharp/Portable/Symbols/TypeParameterSymbol.cs
+1
-0
src/Compilers/CSharp/Test/Semantic/FlowAnalysis/FlowTests.cs
src/Compilers/CSharp/Test/Semantic/FlowAnalysis/FlowTests.cs
+1
-1
未找到文件。
src/Compilers/CSharp/Portable/BoundTree/Expression.cs
浏览文件 @
c1a0658e
...
...
@@ -124,7 +124,7 @@ internal static IArgument CreateArgumentOperation(ArgumentKind kind, IParameterS
// is undefined.
if
((
object
)
optionalParametersMethod
==
null
||
n
.
HasAnyErrors
||
parameters
.
Any
(
p
=>
p
.
Type
.
IsErrorType
())
||
parameters
.
Any
(
p
=>
p
.
Type
.
TypeSymbol
.
IsErrorType
())
||
optionalParametersMethod
.
GetUseSiteDiagnostic
()?.
DefaultSeverity
==
DiagnosticSeverity
.
Error
)
{
// optionalParametersMethod can be null if we are writing to a readonly indexer or reading from an writeonly indexer,
...
...
src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs
浏览文件 @
c1a0658e
...
...
@@ -382,7 +382,7 @@ private static MethodSymbol DelegateInvokeMethod(NamedTypeSymbol delegateType)
return
delegateType
.
GetDelegateType
()?.
DelegateInvokeMethod
;
}
private
static
TypeSymbolWithAnnotations
DelegateReturnType
(
MethodSymbol
invokeMethod
,
out
RefKind
refKind
)
private
TypeSymbolWithAnnotations
DelegateReturnType
(
MethodSymbol
invokeMethod
,
out
RefKind
refKind
)
{
if
((
object
)
invokeMethod
==
null
)
{
...
...
src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs
浏览文件 @
c1a0658e
...
...
@@ -2523,56 +2523,6 @@ protected override void AfterLeftChildHasBeenVisited(BoundBinaryOperator binary)
}
}
public
override
BoundNode
VisitFixedLocalCollectionInitializer
(
BoundFixedLocalCollectionInitializer
node
)
{
var
initializer
=
node
.
Expression
;
if
(
initializer
.
Kind
==
BoundKind
.
AddressOfOperator
)
{
initializer
=
((
BoundAddressOfOperator
)
initializer
).
Operand
;
}
// If the node is a fixed statement address-of operator (e.g. fixed(int *p = &...)),
// then we don't need to consider it for membership in unsafeAddressTakenVariables,
// because it is either not a local/parameter/range variable (if the variable is
// non-moveable) or it is and it has a RefKind other than None, in which case it can't
// be referred to in a lambda (i.e. can't be captured).
VisitAddressOfOperand
(
initializer
,
shouldReadOperand
:
false
);
return
null
;
}
public
override
BoundNode
VisitAddressOfOperator
(
BoundAddressOfOperator
node
)
{
BoundExpression
operand
=
node
.
Operand
;
bool
shouldReadOperand
=
false
;
Symbol
variable
=
UseNonFieldSymbolUnsafely
(
operand
);
if
((
object
)
variable
!=
null
)
{
// The goal here is to treat address-of as a read in cases where
// we (a) care about a read happening (e.g. for DataFlowsIn) and
// (b) have information indicating that this will not result in
// a read to an unassigned variable (i.e. the operand is definitely
// assigned).
if
(
_unassignedVariableAddressOfSyntaxes
?.
Contains
(
node
.
Syntax
as
PrefixUnaryExpressionSyntax
)
==
false
)
{
shouldReadOperand
=
true
;
}
if
(!
_unsafeAddressTakenVariables
.
ContainsKey
(
variable
))
{
_unsafeAddressTakenVariables
.
Add
(
variable
,
node
.
Syntax
.
Location
);
}
}
else
{
VisitAddressOfOperand
(
node
.
Operand
,
shouldReadOperand
);
}
SetUnknownResultNullability
();
return
null
;
}
private
static
BoundExpression
SkipReferenceConversions
(
BoundExpression
possiblyConversion
)
{
while
(
possiblyConversion
.
Kind
==
BoundKind
.
Conversion
)
...
...
@@ -3256,6 +3206,54 @@ public override BoundNode VisitCompoundAssignmentOperator(BoundCompoundAssignmen
return
null
;
}
public
override
BoundNode
VisitFixedLocalCollectionInitializer
(
BoundFixedLocalCollectionInitializer
node
)
{
var
initializer
=
node
.
Expression
;
if
(
initializer
.
Kind
==
BoundKind
.
AddressOfOperator
)
{
initializer
=
((
BoundAddressOfOperator
)
initializer
).
Operand
;
}
// If the node is a fixed statement address-of operator (e.g. fixed(int *p = &...)),
// then we don't need to consider it for membership in unsafeAddressTakenVariables,
// because it is either not a local/parameter/range variable (if the variable is
// non-moveable) or it is and it has a RefKind other than None, in which case it can't
// be referred to in a lambda (i.e. can't be captured).
VisitAddressOfOperand
(
initializer
,
shouldReadOperand
:
false
);
return
null
;
}
public
override
BoundNode
VisitAddressOfOperator
(
BoundAddressOfOperator
node
)
{
BoundExpression
operand
=
node
.
Operand
;
bool
shouldReadOperand
=
false
;
Symbol
variable
=
UseNonFieldSymbolUnsafely
(
operand
);
if
((
object
)
variable
!=
null
)
{
// The goal here is to treat address-of as a read in cases where
// we (a) care about a read happening (e.g. for DataFlowsIn) and
// (b) have information indicating that this will not result in
// a read to an unassigned variable (i.e. the operand is definitely
// assigned).
if
(
_unassignedVariableAddressOfSyntaxes
?.
Contains
(
node
.
Syntax
as
PrefixUnaryExpressionSyntax
)
==
false
)
{
shouldReadOperand
=
true
;
}
if
(!
_unsafeAddressTakenVariables
.
ContainsKey
(
variable
))
{
_unsafeAddressTakenVariables
.
Add
(
variable
,
node
.
Syntax
.
Location
);
}
}
VisitAddressOfOperand
(
node
.
Operand
,
shouldReadOperand
);
SetUnknownResultNullability
();
return
null
;
}
protected
override
void
VisitArgumentAsRvalue
(
BoundExpression
argument
,
ParameterSymbol
parameter
,
bool
expanded
)
{
base
.
VisitArgumentAsRvalue
(
argument
,
parameter
,
expanded
);
...
...
@@ -4063,13 +4061,6 @@ public override BoundNode VisitArgListOperator(BoundArgListOperator node)
return
result
;
}
public
override
BoundNode
VisitFixedLocalCollectionInitializer
(
BoundFixedLocalCollectionInitializer
node
)
{
var
result
=
base
.
VisitFixedLocalCollectionInitializer
(
node
);
SetUnknownResultNullability
();
return
result
;
}
public
override
BoundNode
VisitLiteral
(
BoundLiteral
node
)
{
var
result
=
base
.
VisitLiteral
(
node
);
...
...
src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
浏览文件 @
c1a0658e
...
...
@@ -175,7 +175,6 @@ public static bool IsWarning(ErrorCode code)
case
ErrorCode
.
WRN_TupleLiteralNameMismatch
:
case
ErrorCode
.
WRN_Experimental
:
case
ErrorCode
.
WRN_DefaultInSwitch
:
<<<<<<<
HEAD
case
ErrorCode
.
WRN_NullReferenceAssignment
:
case
ErrorCode
.
WRN_NullReferenceReceiver
:
case
ErrorCode
.
WRN_NullReferenceReturn
:
...
...
@@ -194,9 +193,7 @@ <<<<<<< HEAD
case
ErrorCode
.
WRN_NullabilityMismatchInArgument
:
case
ErrorCode
.
WRN_NullabilityMismatchInReturnTypeOfTargetDelegate
:
case
ErrorCode
.
WRN_NullabilityMismatchInParameterTypeOfTargetDelegate
:
=======
case
ErrorCode
.
WRN_UnreferencedLocalFunction
:
>>>>>>>
upstream
/
master
return
true
;
default
:
return
false
;
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_FixedStatement.cs
浏览文件 @
c1a0658e
...
...
@@ -233,7 +233,7 @@ public override BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCo
SyntheticBoundNodeFactory
factory
,
out
LocalSymbol
pinnedTemp
)
{
TypeSymbol
localType
=
localSymbol
.
Type
;
TypeSymbol
localType
=
localSymbol
.
Type
.
TypeSymbol
;
BoundExpression
initializerExpr
=
VisitExpression
(
fixedInitializer
.
Expression
);
// initializer expr should be either an address(&) of something or a fixed field access.
...
...
@@ -374,7 +374,7 @@ public override BoundNode VisitFixedLocalCollectionInitializer(BoundFixedLocalCo
pinnedTemp
=
factory
.
SynthesizedLocal
(
initializerType
,
isPinned
:
true
);
ArrayTypeSymbol
arrayType
=
(
ArrayTypeSymbol
)
pinnedTemp
.
Type
.
TypeSymbol
;
TypeSymbol
arrayElementType
=
arrayType
.
ElementType
.
TypeSymbol
;
TypeSymbol
WithAnnotations
arrayElementType
=
arrayType
.
ElementType
;
// NOTE: we pin the array, not the pointer.
Debug
.
Assert
(
pinnedTemp
.
IsPinned
);
...
...
src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.cs
浏览文件 @
c1a0658e
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Symbols
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
...
...
src/Compilers/CSharp/Portable/Symbols/DynamicTypeSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -3,6 +3,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
...
...
src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs
浏览文件 @
c1a0658e
...
...
@@ -4,6 +4,7 @@
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Linq
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
...
...
src/Compilers/CSharp/Portable/Symbols/PointerTypeSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -5,6 +5,7 @@
using
System.Collections.Immutable
;
using
Roslyn.Utilities
;
using
System.Diagnostics
;
using
Microsoft.CodeAnalysis.PooledObjects
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
{
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -206,7 +206,7 @@ protected SourceMemberMethodSymbol(NamedTypeSymbol containingType, SyntaxReferen
this
.
locations
=
locations
;
}
protected
void
CheckEffectiveAccessibility
(
TypeSymbol
returnType
,
ImmutableArray
<
ParameterSymbol
>
parameters
,
DiagnosticBag
diagnostics
)
protected
void
CheckEffectiveAccessibility
(
TypeSymbol
WithAnnotations
returnType
,
ImmutableArray
<
ParameterSymbol
>
parameters
,
DiagnosticBag
diagnostics
)
{
if
(
this
.
DeclaredAccessibility
<=
Accessibility
.
Private
)
{
...
...
@@ -221,7 +221,7 @@ protected void CheckEffectiveAccessibility(TypeSymbol returnType, ImmutableArray
if
(!
this
.
IsNoMoreVisibleThan
(
returnType
,
ref
useSiteDiagnostics
))
{
// Inconsistent accessibility: return type '{1}' is less accessible than method '{0}'
diagnostics
.
Add
(
code
,
Locations
[
0
],
this
,
returnType
);
diagnostics
.
Add
(
code
,
Locations
[
0
],
this
,
returnType
.
TypeSymbol
);
}
code
=
(
this
.
MethodKind
==
MethodKind
.
Conversion
||
this
.
MethodKind
==
MethodKind
.
UserDefinedOperator
)
?
...
...
@@ -233,7 +233,7 @@ protected void CheckEffectiveAccessibility(TypeSymbol returnType, ImmutableArray
if
(!
parameter
.
Type
.
IsAtLeastAsVisibleAs
(
this
,
ref
useSiteDiagnostics
))
{
// Inconsistent accessibility: parameter type '{1}' is less accessible than method '{0}'
diagnostics
.
Add
(
code
,
Locations
[
0
],
this
,
parameter
.
Type
);
diagnostics
.
Add
(
code
,
Locations
[
0
],
this
,
parameter
.
Type
.
TypeSymbol
);
}
}
...
...
@@ -595,14 +595,6 @@ public override string GetDocumentationCommentXml(CultureInfo preferredCulture =
#
endregion
public
override
ImmutableArray
<
CustomModifier
>
ReturnTypeCustomModifiers
{
get
{
return
ImmutableArray
<
CustomModifier
>.
Empty
;
}
}
public
override
ImmutableArray
<
CustomModifier
>
RefCustomModifiers
{
get
...
...
@@ -611,11 +603,11 @@ public override ImmutableArray<CustomModifier> RefCustomModifiers
}
}
public
sealed
override
ImmutableArray
<
TypeSymbol
>
TypeArguments
public
sealed
override
ImmutableArray
<
TypeSymbol
WithAnnotations
>
TypeArguments
{
get
{
return
TypeParameters
.
Cast
<
TypeParameterSymbol
,
TypeSymbol
>(
);
return
TypeParameters
.
SelectAsArray
(
TypeMap
.
AsTypeSymbolWithAnnotations
);
}
}
...
...
@@ -967,16 +959,24 @@ internal override void AddSynthesizedReturnTypeAttributes(ref ArrayBuilder<Synth
{
base
.
AddSynthesizedReturnTypeAttributes
(
ref
attributes
);
if
(
this
.
ReturnType
.
ContainsDynamic
())
var
type
=
this
.
ReturnType
;
if
(
type
.
TypeSymbol
.
ContainsDynamic
())
{
var
compilation
=
this
.
DeclaringCompilation
;
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeDynamicAttribute
(
t
his
.
ReturnType
,
this
.
ReturnType
CustomModifiers
.
Length
+
this
.
RefCustomModifiers
.
Length
,
this
.
RefKind
));
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeDynamicAttribute
(
t
ype
.
TypeSymbol
,
type
.
CustomModifiers
.
Length
+
this
.
RefCustomModifiers
.
Length
,
this
.
RefKind
));
}
if
(
ReturnType
.
ContainsTupleNames
())
if
(
type
.
TypeSymbol
.
ContainsTupleNames
())
{
AddSynthesizedAttribute
(
ref
attributes
,
DeclaringCompilation
.
SynthesizeTupleNamesAttribute
(
ReturnType
));
DeclaringCompilation
.
SynthesizeTupleNamesAttribute
(
type
.
TypeSymbol
));
}
if
(
type
.
ContainsNullableReferenceTypes
())
{
var
compilation
=
this
.
DeclaringCompilation
;
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeNullableAttribute
(
type
));
}
}
...
...
@@ -1085,11 +1085,11 @@ private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttribut
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
PreserveSigAttribute
))
{
arguments
.
GetOrCreateData
<
Common
MethodWellKnownAttributeData
>().
SetPreserveSignature
(
arguments
.
Index
);
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
SetPreserveSignature
(
arguments
.
Index
);
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
MethodImplAttribute
))
{
AttributeData
.
DecodeMethodImplAttribute
<
Common
MethodWellKnownAttributeData
,
AttributeSyntax
,
CSharpAttributeData
,
AttributeLocation
>(
ref
arguments
,
MessageProvider
.
Instance
);
AttributeData
.
DecodeMethodImplAttribute
<
MethodWellKnownAttributeData
,
AttributeSyntax
,
CSharpAttributeData
,
AttributeLocation
>(
ref
arguments
,
MessageProvider
.
Instance
);
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
DllImportAttribute
))
{
...
...
@@ -1097,11 +1097,11 @@ private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttribut
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
SpecialNameAttribute
))
{
arguments
.
GetOrCreateData
<
Common
MethodWellKnownAttributeData
>().
HasSpecialNameAttribute
=
true
;
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
HasSpecialNameAttribute
=
true
;
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
ExcludeFromCodeCoverageAttribute
))
{
arguments
.
GetOrCreateData
<
Common
MethodWellKnownAttributeData
>().
HasExcludeFromCodeCoverageAttribute
=
true
;
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
HasExcludeFromCodeCoverageAttribute
=
true
;
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
ConditionalAttribute
))
{
...
...
@@ -1109,11 +1109,11 @@ private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttribut
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
SuppressUnmanagedCodeSecurityAttribute
))
{
arguments
.
GetOrCreateData
<
Common
MethodWellKnownAttributeData
>().
HasSuppressUnmanagedCodeSecurityAttribute
=
true
;
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
HasSuppressUnmanagedCodeSecurityAttribute
=
true
;
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
DynamicSecurityMethodAttribute
))
{
arguments
.
GetOrCreateData
<
Common
MethodWellKnownAttributeData
>().
HasDynamicSecurityMethodAttribute
=
true
;
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
HasDynamicSecurityMethodAttribute
=
true
;
}
else
if
(
VerifyObsoleteAttributeAppliedToMethod
(
ref
arguments
,
AttributeDescription
.
ObsoleteAttribute
))
{
...
...
@@ -1134,12 +1134,16 @@ private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttribut
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_SecurityCriticalOrSecuritySafeCriticalOnAsync
,
arguments
.
AttributeSyntaxOpt
.
Location
,
arguments
.
AttributeSyntaxOpt
.
GetErrorDisplayName
());
}
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
NullableOptOutAttribute
))
{
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
NullableOptOut
=
attribute
.
GetConstructorArgument
<
bool
>(
0
,
SpecialType
.
System_Boolean
);
}
else
{
var
compilation
=
this
.
DeclaringCompilation
;
if
(
attribute
.
IsSecurityAttribute
(
compilation
))
{
attribute
.
DecodeSecurityAttribute
<
Common
MethodWellKnownAttributeData
>(
this
,
compilation
,
ref
arguments
);
attribute
.
DecodeSecurityAttribute
<
MethodWellKnownAttributeData
>(
this
,
compilation
,
ref
arguments
);
}
}
}
...
...
@@ -1245,6 +1249,11 @@ private void DecodeWellKnownAttributeAppliedToReturnValue(ref DecodeWellKnownAtt
{
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_ExplicitTupleElementNamesAttribute
,
arguments
.
AttributeSyntaxOpt
.
Location
);
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
NullableAttribute
))
{
// NullableAttribute should not be set explicitly.
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_ExplicitNullableAttribute
,
arguments
.
AttributeSyntaxOpt
.
Location
);
}
}
private
void
DecodeDllImportAttribute
(
ref
DecodeWellKnownAttributeArguments
<
AttributeSyntax
,
CSharpAttributeData
,
AttributeLocation
>
arguments
)
...
...
@@ -1346,7 +1355,7 @@ private void DecodeDllImportAttribute(ref DecodeWellKnownAttributeArguments<Attr
if
(!
hasErrors
)
{
arguments
.
GetOrCreateData
<
Common
MethodWellKnownAttributeData
>().
SetDllImport
(
arguments
.
GetOrCreateData
<
MethodWellKnownAttributeData
>().
SetDllImport
(
arguments
.
Index
,
moduleName
,
importName
,
...
...
@@ -1451,6 +1460,15 @@ internal sealed override bool HasSpecialName
}
}
internal
override
bool
NullableOptOut
{
get
{
var
data
=
GetDecodedWellKnownAttributeData
()
as
MethodWellKnownAttributeData
;
return
data
?.
NullableOptOut
??
base
.
NullableOptOut
;
}
}
internal
sealed
override
bool
IsDirectlyExcludedFromCodeCoverage
=>
GetDecodedWellKnownAttributeData
()?.
HasExcludeFromCodeCoverageAttribute
==
true
;
...
...
@@ -1470,28 +1488,12 @@ internal sealed override bool HasDeclarativeSecurity
var
data
=
this
.
GetDecodedWellKnownAttributeData
();
return
data
!=
null
&&
data
.
HasDeclarativeSecurity
;
}
if
(((
CSharpParseOptions
)
implementation
.
Locations
[
0
].
SourceTree
?.
Options
)?.
IsFeatureEnabled
(
MessageID
.
IDS_FeatureStaticNullChecking
)
==
true
&&
!
implementation
.
NullableOptOut
)
{
ImmutableArray
<
ParameterSymbol
>
implementationParameters
=
implementation
.
Parameters
;
ImmutableArray
<
ParameterSymbol
>
definitionParameters
=
definition
.
ConstructIfGeneric
(
implementation
.
TypeParameters
.
SelectAsArray
(
TypeMap
.
AsTypeSymbolWithAnnotations
)).
Parameters
;
for
(
int
i
=
0
;
i
<
implementationParameters
.
Length
;
i
++)
{
if
(!
implementationParameters
[
i
].
Type
.
Equals
(
definitionParameters
[
i
].
Type
,
TypeCompareKind
.
AllIgnoreOptions
|
TypeCompareKind
.
CompareNullableModifiersForReferenceTypes
)
&&
implementationParameters
[
i
].
Type
.
Equals
(
definitionParameters
[
i
].
Type
,
TypeCompareKind
.
AllIgnoreOptions
))
{
diagnostics
.
Add
(
ErrorCode
.
WRN_NullabilityMismatchInParameterTypeOnPartial
,
implementation
.
Locations
[
0
],
new
FormattedSymbol
(
implementationParameters
[
i
],
SymbolDisplayFormat
.
ShortFormat
));
}
}
}
}
internal
sealed
override
IEnumerable
<
Cci
.
SecurityAttribute
>
GetSecurityInformation
()
{
var
attributesBag
=
this
.
GetAttributesBag
();
var
wellKnownData
=
(
Common
MethodWellKnownAttributeData
)
attributesBag
.
DecodedWellKnownAttributeData
;
var
wellKnownData
=
(
MethodWellKnownAttributeData
)
attributesBag
.
DecodedWellKnownAttributeData
;
if
(
wellKnownData
!=
null
)
{
SecurityWellKnownAttributeData
securityData
=
wellKnownData
.
SecurityInformation
;
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -21,9 +21,9 @@ internal sealed class SourceOrdinaryMethodSymbol : SourceMemberMethodSymbol
private
readonly
RefKind
_refKind
;
private
ImmutableArray
<
MethodSymbol
>
_lazyExplicitInterfaceImplementations
;
private
CustomModifiersTuple
_lazy
CustomModifiers
;
private
ImmutableArray
<
CustomModifier
>
_lazyRef
CustomModifiers
;
private
ImmutableArray
<
ParameterSymbol
>
_lazyParameters
;
private
TypeSymbol
_lazyReturnType
;
private
TypeSymbol
WithAnnotations
_lazyReturnType
;
private
bool
_lazyIsVararg
;
/// <summary>
...
...
@@ -182,7 +182,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
else
{
// Method or delegate cannot return type '{0}'
diagnostics
.
Add
(
ErrorCode
.
ERR_MethodReturnCantBeRefAny
,
syntax
.
ReturnType
.
Location
,
_lazyReturnType
);
diagnostics
.
Add
(
ErrorCode
.
ERR_MethodReturnCantBeRefAny
,
syntax
.
ReturnType
.
Location
,
_lazyReturnType
.
TypeSymbol
);
}
}
...
...
@@ -208,13 +208,13 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
if
(
IsExtensionMethod
)
{
var
parameter0Type
=
this
.
Parameters
[
0
].
Type
;
if
(!
parameter0Type
.
IsValidExtensionParameterType
())
if
(!
parameter0Type
.
TypeSymbol
.
IsValidExtensionParameterType
())
{
// Duplicate Dev10 behavior by selecting the parameter type.
var
parameterSyntax
=
syntax
.
ParameterList
.
Parameters
[
0
];
Debug
.
Assert
(
parameterSyntax
.
Type
!=
null
);
var
loc
=
parameterSyntax
.
Type
.
Location
;
diagnostics
.
Add
(
ErrorCode
.
ERR_BadTypeforThis
,
loc
,
parameter0Type
);
diagnostics
.
Add
(
ErrorCode
.
ERR_BadTypeforThis
,
loc
,
parameter0Type
.
TypeSymbol
);
}
else
if
((
object
)
ContainingType
.
ContainingType
!=
null
)
{
...
...
@@ -297,12 +297,12 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
// unnecessary for implicit implementations because, if the custom modifiers don't match,
// we'll insert a bridge method (an explicit implementation that delegates to the implicit
// implementation) with the correct custom modifiers
// (see Source
NamedTypeSymbol.ImplementInterfaceMember
).
// (see Source
MemberContainerTypeSymbol.SynthesizeInterfaceMemberImplementation
).
// This value may not be correct, but we need something while we compute
overridden/implemented m
ethod.
// This value may not be correct, but we need something while we compute
this.OverriddenM
ethod.
// May be re-assigned below.
Debug
.
Assert
(
_lazy
CustomModifiers
==
null
);
_lazy
CustomModifiers
=
CustomModifiersTuple
.
Empty
;
Debug
.
Assert
(
_lazy
ReturnType
.
CustomModifiers
.
IsEmpty
);
_lazy
RefCustomModifiers
=
ImmutableArray
<
CustomModifier
>
.
Empty
;
// Note: we're checking if the syntax indicates explicit implementation rather,
// than if explicitInterfaceType is null because we don't want to look for an
...
...
@@ -329,7 +329,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
if
((
object
)
overriddenMethod
!=
null
)
{
CustomModifierUtils
.
CopyMethodCustomModifiers
(
overriddenMethod
,
this
,
out
_lazyReturnType
,
out
_lazyCustomModifiers
,
out
_lazy
Ref
CustomModifiers
,
out
_lazyParameters
,
alsoCopyParamsModifier
:
true
);
}
}
...
...
@@ -345,13 +345,17 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
_lazyExplicitInterfaceImplementations
=
ImmutableArray
.
Create
<
MethodSymbol
>(
implementedMethod
);
CustomModifierUtils
.
CopyMethodCustomModifiers
(
implementedMethod
,
this
,
out
_lazyReturnType
,
out
_lazyCustomModifiers
,
out
_lazy
Ref
CustomModifiers
,
out
_lazyParameters
,
alsoCopyParamsModifier
:
false
);
this
.
FindExplicitlyImplementedMemberVerification
(
implementedMethod
,
diagnostics
);
TypeSymbol
.
CheckNullableReferenceTypeMismatchOnImplementingMember
(
this
,
implementedMethod
,
true
,
diagnostics
);
}
else
{
Debug
.
Assert
(
_lazyExplicitInterfaceImplementations
.
IsDefault
);
_lazyExplicitInterfaceImplementations
=
ImmutableArray
<
MethodSymbol
>.
Empty
;
Debug
.
Assert
(
_lazyReturnType
.
CustomModifiers
.
IsEmpty
);
}
}
...
...
@@ -374,7 +378,7 @@ internal static void ReportAsyncParameterErrors(ImmutableArray<ParameterSymbol>
}
else
if
(
parameter
.
Type
.
IsRestrictedType
())
{
diagnostics
.
Add
(
ErrorCode
.
ERR_BadSpecialByRefLocal
,
loc
,
parameter
.
Type
);
diagnostics
.
Add
(
ErrorCode
.
ERR_BadSpecialByRefLocal
,
loc
,
parameter
.
Type
.
TypeSymbol
);
}
}
}
...
...
@@ -424,7 +428,7 @@ protected sealed override void LazyAsyncMethodChecks(CancellationToken cancellat
diagnostics
.
Add
(
ErrorCode
.
ERR_SynchronizedAsyncMethod
,
errorLocation
);
}
if
(
diagnostics
.
IsEmptyWithoutResolution
)
if
(
!
diagnostics
.
HasAnyResolvedErrors
()
)
{
ReportAsyncParameterErrors
(
_lazyParameters
,
diagnostics
,
errorLocation
);
}
...
...
@@ -543,7 +547,7 @@ internal override RefKind RefKind
}
}
public
override
TypeSymbol
ReturnType
public
override
TypeSymbol
WithAnnotations
ReturnType
{
get
{
...
...
@@ -668,21 +672,12 @@ public override ImmutableArray<MethodSymbol> ExplicitInterfaceImplementations
}
}
public
override
ImmutableArray
<
CustomModifier
>
ReturnTypeCustomModifiers
{
get
{
LazyMethodChecks
();
return
_lazyCustomModifiers
.
TypeCustomModifiers
;
}
}
public
override
ImmutableArray
<
CustomModifier
>
RefCustomModifiers
{
get
{
LazyMethodChecks
();
return
_lazy
CustomModifiers
.
RefCustomModifiers
;
return
_lazyRefCustomModifiers
;
}
}
...
...
@@ -900,7 +895,7 @@ private void CheckModifiers(Location location, DiagnosticBag diagnostics)
else
if
(!
ContainingType
.
IsInterfaceType
()
&&
_lazyReturnType
.
IsStatic
)
{
// '{0}': static types cannot be used as return types
diagnostics
.
Add
(
ErrorCode
.
ERR_ReturnTypeIsStaticClass
,
location
,
_lazyReturnType
);
diagnostics
.
Add
(
ErrorCode
.
ERR_ReturnTypeIsStaticClass
,
location
,
_lazyReturnType
.
TypeSymbol
);
}
else
if
(
IsAbstract
&&
IsExtern
)
{
...
...
@@ -1046,6 +1041,22 @@ private static void PartialMethodChecks(SourceOrdinaryMethodSymbol definition, S
{
diagnostics
.
Add
(
ErrorCode
.
ERR_PartialMethodInconsistentConstraints
,
implementation
.
Locations
[
0
],
implementation
);
}
if
(((
CSharpParseOptions
)
implementation
.
Locations
[
0
].
SourceTree
?.
Options
)?.
IsFeatureEnabled
(
MessageID
.
IDS_FeatureStaticNullChecking
)
==
true
&&
!
implementation
.
NullableOptOut
)
{
ImmutableArray
<
ParameterSymbol
>
implementationParameters
=
implementation
.
Parameters
;
ImmutableArray
<
ParameterSymbol
>
definitionParameters
=
definition
.
ConstructIfGeneric
(
implementation
.
TypeParameters
.
SelectAsArray
(
TypeMap
.
AsTypeSymbolWithAnnotations
)).
Parameters
;
for
(
int
i
=
0
;
i
<
implementationParameters
.
Length
;
i
++)
{
if
(!
implementationParameters
[
i
].
Type
.
Equals
(
definitionParameters
[
i
].
Type
,
TypeCompareKind
.
AllIgnoreOptions
|
TypeCompareKind
.
CompareNullableModifiersForReferenceTypes
)
&&
implementationParameters
[
i
].
Type
.
Equals
(
definitionParameters
[
i
].
Type
,
TypeCompareKind
.
AllIgnoreOptions
))
{
diagnostics
.
Add
(
ErrorCode
.
WRN_NullabilityMismatchInParameterTypeOnPartial
,
implementation
.
Locations
[
0
],
new
FormattedSymbol
(
implementationParameters
[
i
],
SymbolDisplayFormat
.
ShortFormat
));
}
}
}
}
/// <summary>
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceTypeParameterSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -442,8 +442,8 @@ protected override TypeParameterBounds ResolveBounds(ConsList<TypeParameterSymbo
{
var
constraintClauses
=
_owner
.
TypeParameterConstraintClauses
;
var
constraintTypes
=
constraintClauses
.
IsEmpty
?
ImmutableArray
<
TypeSymbol
>.
Empty
:
constraintClauses
[
Ordinal
]?.
ConstraintTypes
??
ImmutableArray
<
TypeSymbol
>.
Empty
;
?
ImmutableArray
<
TypeSymbol
WithAnnotations
>.
Empty
:
constraintClauses
[
Ordinal
]?.
ConstraintTypes
??
ImmutableArray
<
TypeSymbol
WithAnnotations
>.
Empty
;
return
this
.
ResolveBounds
(
this
.
ContainingAssembly
.
CorLibrary
,
inProgress
.
Prepend
(
this
),
constraintTypes
,
false
,
this
.
DeclaringCompilation
,
diagnostics
);
}
...
...
src/Compilers/CSharp/Portable/Symbols/SubstitutedTypeParameterSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -4,6 +4,7 @@
using
System
;
using
System.Collections.Immutable
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
...
...
src/Compilers/CSharp/Portable/Symbols/SymbolWithAnnotations.cs
浏览文件 @
c1a0658e
...
...
@@ -8,6 +8,7 @@
using
System.Diagnostics
;
using
System.Linq
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.PooledObjects
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
{
...
...
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedAccessorValueParameterSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Symbols
/// </summary>
internal
sealed
class
SynthesizedAccessorValueParameterSymbol
:
SourceComplexParameterSymbol
{
public
SynthesizedAccessorValueParameterSymbol
(
SourceMemberMethodSymbol
accessor
,
TypeSymbolWithAnnotations
paramType
,
int
ordinal
,
ImmutableArray
<
CustomModifier
>
customModifiers
)
public
SynthesizedAccessorValueParameterSymbol
(
SourceMemberMethodSymbol
accessor
,
TypeSymbolWithAnnotations
paramType
,
int
ordinal
)
:
base
(
accessor
,
ordinal
,
paramType
,
RefKind
.
None
,
ParameterSymbol
.
ValueParameterName
,
accessor
.
Locations
,
syntaxRef
:
null
,
defaultSyntaxValue
:
ConstantValue
.
Unset
,
// the default value can be set via [param: DefaultParameterValue] applied on the accessor
...
...
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedEntryPointSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -37,7 +37,7 @@ internal static SynthesizedEntryPointSymbol Create(SynthesizedInteractiveInitial
else
{
var
systemVoid
=
Binder
.
GetSpecialType
(
compilation
,
SpecialType
.
System_Void
,
DummySyntax
(),
diagnostics
);
return
new
ScriptEntryPoint
(
containingType
,
systemVoid
);
return
new
ScriptEntryPoint
(
containingType
,
TypeSymbolWithAnnotations
.
Create
(
systemVoid
)
);
}
}
...
...
@@ -397,9 +397,9 @@ internal override BoundBlock CreateBody(DiagnosticBag diagnostics)
private
sealed
class
ScriptEntryPoint
:
SynthesizedEntryPointSymbol
{
private
readonly
TypeSymbol
_returnType
;
private
readonly
TypeSymbol
WithAnnotations
_returnType
;
internal
ScriptEntryPoint
(
NamedTypeSymbol
containingType
,
TypeSymbol
returnType
)
:
internal
ScriptEntryPoint
(
NamedTypeSymbol
containingType
,
TypeSymbol
WithAnnotations
returnType
)
:
base
(
containingType
)
{
Debug
.
Assert
(
containingType
.
IsScriptClass
);
...
...
src/Compilers/CSharp/Portable/Symbols/TypeParameterSymbol.cs
浏览文件 @
c1a0658e
...
...
@@ -3,6 +3,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
...
...
src/Compilers/CSharp/Test/Semantic/FlowAnalysis/FlowTests.cs
浏览文件 @
c1a0658e
...
...
@@ -2407,7 +2407,7 @@ static T F<T>(System.ValueType o)
comp
.
VerifyDiagnostics
(
// (5,21): error CS8314: An expression of type 'ValueType' cannot be handled by a pattern of type 'T' in C# 7. Please use language version 7.1 or greater.
// return o is T t ? t : default(T);
Diagnostic
(
ErrorCode
.
ERR_PatternWrongGenericTypeInVersion
,
"T"
).
WithArguments
(
"System.ValueType"
,
"T"
,
"7"
,
"7.1"
).
WithLocation
(
5
,
21
));
Diagnostic
(
ErrorCode
.
ERR_PatternWrongGenericTypeInVersion
,
"T"
).
WithArguments
(
"System.ValueType"
,
"T"
,
"7
.0
"
,
"7.1"
).
WithLocation
(
5
,
21
));
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录