Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
3be2584b
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,发现更多精彩内容 >>
提交
3be2584b
编写于
9月 28, 2017
作者:
O
Omar Tawfik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Checked uses of RefKind.RefReadOnly
上级
b79d701b
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
84 addition
and
86 deletion
+84
-86
src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
+4
-4
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
...Binder/Semantics/OverloadResolution/OverloadResolution.cs
+1
-1
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
.../Semantics/OverloadResolution/OverloadResolutionResult.cs
+7
-7
src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
+1
-1
src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
+1
-1
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
...Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
+2
-2
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
...s/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
+1
-1
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
...arp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
+3
-3
src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
...ers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
+1
-1
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs
...rp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs
+2
-4
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs
...ers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs
.../CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs
src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
...pilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
+4
-4
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
...arp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
...s/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
+2
-2
src/Compilers/CSharp/Portable/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
...ble/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs
...ers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs
+1
-1
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_RefReadOnly.cs
...CSharp/Test/Emit/Attributes/AttributeTests_RefReadOnly.cs
+20
-20
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs
...rs/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs
+16
-16
src/Compilers/CSharp/Test/Semantic/Semantics/RefExtensionMethodsTests.cs
...Sharp/Test/Semantic/Semantics/RefExtensionMethodsTests.cs
+1
-1
src/Compilers/CSharp/Test/Symbol/Symbols/Source/DelegateTests.cs
...pilers/CSharp/Test/Symbol/Symbols/Source/DelegateTests.cs
+3
-3
src/Compilers/CSharp/Test/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs
...st/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs
+2
-2
src/VisualStudio/Core/Test/ChangeSignature/ChangeSignatureViewModelTests.vb
...ore/Test/ChangeSignature/ChangeSignatureViewModelTests.vb
+1
-1
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
...s/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
+3
-3
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
浏览文件 @
3be2584b
...
...
@@ -518,7 +518,7 @@ private bool CheckParameterValueKind(SyntaxNode node, BoundParameter parameter,
// all parameters can be passed by ref/out or assigned to
// except "in" parameters, which are readonly
if
(
parameterSymbol
.
RefKind
==
RefKind
.
RefReadOnly
&&
RequiresAssignableVariable
(
valueKind
))
if
(
parameterSymbol
.
RefKind
==
RefKind
.
In
&&
RequiresAssignableVariable
(
valueKind
))
{
ReportReadOnlyError
(
parameterSymbol
,
node
,
valueKind
,
checkingReceiver
,
diagnostics
);
return
false
;
...
...
@@ -1291,9 +1291,9 @@ bool isRefEscape
{
var
paramIndex
=
argsToParamsOpt
.
IsDefault
?
argIndex
:
argsToParamsOpt
[
argIndex
];
if
(
parameters
[
paramIndex
].
RefKind
==
RefKind
.
RefReadOnly
)
if
(
parameters
[
paramIndex
].
RefKind
==
RefKind
.
In
)
{
effectiveRefKind
=
RefKind
.
RefReadOnly
;
effectiveRefKind
=
RefKind
.
In
;
refReadOnlyParametersMatchedWithArgs
=
refReadOnlyParametersMatchedWithArgs
??
ArrayBuilder
<
bool
>.
GetInstance
(
parameters
.
Length
,
fillWithValue
:
false
);
refReadOnlyParametersMatchedWithArgs
[
paramIndex
]
=
true
;
}
...
...
@@ -1321,7 +1321,7 @@ private static ParameterSymbol TryGetUnmatchedRefReadOnlyParameterAndFreeMatched
break
;
}
if
(
parameter
.
RefKind
==
RefKind
.
RefReadOnly
&&
if
(
parameter
.
RefKind
==
RefKind
.
In
&&
refReadOnlyParametersMatchedWithArgs
?[
i
]
!=
true
&&
parameter
.
Type
.
IsByRefLikeType
==
false
)
{
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
浏览文件 @
3be2584b
...
...
@@ -980,7 +980,7 @@ private static void CheckRestrictedTypeReceiver(BoundExpression expression, Comp
CheckFeatureAvailability
(
receiverArgument
.
Syntax
,
MessageID
.
IDS_FeatureRefExtensionMethods
,
diagnostics
);
}
else
if
(
receiverParameter
.
RefKind
==
RefKind
.
RefReadOnly
)
else
if
(
receiverParameter
.
RefKind
==
RefKind
.
In
)
{
CheckFeatureAvailability
(
receiverArgument
.
Syntax
,
MessageID
.
IDS_FeatureRefExtensionMethods
,
diagnostics
);
}
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
浏览文件 @
3be2584b
...
...
@@ -141,7 +141,7 @@ internal partial class Binder
case
SyntaxKind
.
ReadOnlyKeyword
:
Debug
.
Assert
(
refKind
==
RefKind
.
Ref
||
syntax
.
HasErrors
);
refKind
=
RefKind
.
RefReadOnly
;
refKind
=
RefKind
.
In
;
allValue
=
false
;
break
;
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
浏览文件 @
3be2584b
...
...
@@ -2575,7 +2575,7 @@ private RefKind GetEffectiveParameterRefKind(ParameterSymbol parameter, RefKind
{
var
paramRefKind
=
parameter
.
RefKind
;
if
(
paramRefKind
==
RefKind
.
RefReadOnly
)
if
(
paramRefKind
==
RefKind
.
In
)
{
// "in" parameters are effectively None for the purpose of overload resolution.
paramRefKind
=
RefKind
.
None
;
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
浏览文件 @
3be2584b
...
...
@@ -950,17 +950,17 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
ParameterSymbol
parameter
=
method
.
GetParameters
()[
parm
];
bool
isLastParameter
=
method
.
GetParameterCount
()
==
parm
+
1
;
// This is used to later decide if we need to try to unwrap a params array
RefKind
refArg
=
arguments
.
RefKind
(
arg
);
RefKind
refPar
m
=
parameter
.
RefKind
;
RefKind
refPar
ameter
=
parameter
.
RefKind
;
if
(
arguments
.
IsExtensionMethodThisArgument
(
arg
))
{
Debug
.
Assert
(
refArg
==
RefKind
.
None
);
if
(
refPar
m
==
RefKind
.
Ref
||
refParm
==
RefKind
.
RefReadOnly
)
if
(
refPar
ameter
==
RefKind
.
Ref
||
refParameter
==
RefKind
.
In
)
{
// For ref and ref-readonly extension methods, we omit the "ref" modifier on receiver arguments.
// Setting the correct RefKind for finding the correct diagnostics message.
// For other ref kinds, keeping it as it is to find mismatch errors.
refArg
=
refPar
m
;
refArg
=
refPar
ameter
;
}
}
...
...
@@ -974,7 +974,7 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
{
// If the problem is that a lambda isn't convertible to the given type, also report why.
// The argument and parameter type might match, but may not have same in/out modifiers
if
(
argument
.
Kind
==
BoundKind
.
UnboundLambda
&&
refArg
==
refPar
m
)
if
(
argument
.
Kind
==
BoundKind
.
UnboundLambda
&&
refArg
==
refPar
ameter
)
{
((
UnboundLambda
)
argument
).
GenerateAnonymousFunctionConversionError
(
diagnostics
,
parameter
.
Type
);
}
...
...
@@ -992,9 +992,9 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
UnwrapIfParamsArray
(
parameter
,
isLastParameter
));
}
}
else
if
(
refArg
!=
refPar
m
&&
!(
refArg
==
RefKind
.
None
&&
refParm
==
RefKind
.
RefReadOnly
))
else
if
(
refArg
!=
refPar
ameter
&&
!(
refArg
==
RefKind
.
None
&&
refParameter
==
RefKind
.
In
))
{
if
(
refPar
m
==
RefKind
.
None
||
refParm
==
RefKind
.
RefReadOnly
)
if
(
refPar
ameter
==
RefKind
.
None
||
refParameter
==
RefKind
.
In
)
{
// Argument {0} should not be passed with the {1} keyword
diagnostics
.
Add
(
...
...
@@ -1012,7 +1012,7 @@ private static bool HadLambdaConversionError(DiagnosticBag diagnostics, Analyzed
sourceLocation
,
symbols
,
arg
+
1
,
refPar
m
.
ToParameterDisplayString
());
refPar
ameter
.
ToParameterDisplayString
());
}
}
else
...
...
src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
浏览文件 @
3be2584b
...
...
@@ -364,7 +364,7 @@ private bool HasHome(BoundExpression expression, bool needWriteable)
case
BoundKind
.
Parameter
:
return
!
needWriteable
||
((
BoundParameter
)
expression
).
ParameterSymbol
.
RefKind
!=
RefKind
.
RefReadOnly
;
((
BoundParameter
)
expression
).
ParameterSymbol
.
RefKind
!=
RefKind
.
In
;
case
BoundKind
.
Local
:
// locals have home unless they are byval stack locals or ref-readonly
...
...
src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
浏览文件 @
3be2584b
...
...
@@ -599,7 +599,7 @@ private void EmitArgument(BoundExpression argument, RefKind refKind)
EmitExpression
(
argument
,
true
);
break
;
case
RefKind
.
RefReadOnly
:
case
RefKind
.
In
:
var
temp
=
EmitAddress
(
argument
,
AddressKind
.
ReadOnly
);
AddExpressionTemp
(
temp
);
break
;
...
...
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
浏览文件 @
3be2584b
...
...
@@ -378,7 +378,7 @@ private BoundStatement UpdateStatement(BoundSpillSequenceBuilder builder, BoundS
case
BoundKind
.
Call
:
var
call
=
(
BoundCall
)
expression
;
if
(
refKind
!=
RefKind
.
None
&&
refKind
!=
RefKind
.
RefReadOnly
)
if
(
refKind
!=
RefKind
.
None
&&
refKind
!=
RefKind
.
In
)
{
Debug
.
Assert
(
call
.
Method
.
RefKind
!=
RefKind
.
None
);
_F
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_RefReturningCallAndAwait
,
_F
.
Syntax
.
Location
,
call
.
Method
);
...
...
@@ -794,7 +794,7 @@ public override BoundNode VisitCall(BoundCall node)
receiver
=
node
.
ReceiverOpt
;
var
refKind
=
node
.
Method
.
ContainingType
.
IsReadOnly
?
RefKind
.
RefReadOnly
:
RefKind
.
In
:
ReceiverSpillRefKind
(
receiver
);
receiver
=
Spill
(
receiverBuilder
,
VisitExpression
(
ref
receiverBuilder
,
receiver
),
refKind
:
refKind
);
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
浏览文件 @
3be2584b
...
...
@@ -597,7 +597,7 @@ private void CheckRefReadOnlySymbols(MethodSymbol symbol)
{
foreach
(
var
parameter
in
symbol
.
Parameters
)
{
if
(
parameter
.
RefKind
==
RefKind
.
RefReadOnly
)
if
(
parameter
.
RefKind
==
RefKind
.
In
)
{
foundRefReadOnly
=
true
;
break
;
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
浏览文件 @
3be2584b
...
...
@@ -503,7 +503,7 @@ private static ImmutableArray<RefKind> GetEffectiveArgumentRefKinds(ImmutableArr
for
(
int
i
=
0
;
i
<
parameters
.
Length
;
i
++)
{
var
paramRefKind
=
parameters
[
i
].
RefKind
;
if
(
paramRefKind
==
RefKind
.
RefReadOnly
)
if
(
paramRefKind
==
RefKind
.
In
)
{
if
(
refKindsBuilder
==
null
)
{
...
...
@@ -661,9 +661,9 @@ private static ImmutableArray<RefKind> GetRefKindsOrNull(ArrayBuilder<RefKind> r
BoundExpression
argument
=
rewrittenArguments
[
a
];
int
p
=
(!
argsToParamsOpt
.
IsDefault
)
?
argsToParamsOpt
[
a
]
:
a
;
RefKind
refKind
=
argumentRefKinds
.
RefKinds
(
a
);
if
(
refKind
==
RefKind
.
None
&&
parameters
[
p
].
RefKind
==
RefKind
.
RefReadOnly
)
if
(
refKind
==
RefKind
.
None
&&
parameters
[
p
].
RefKind
==
RefKind
.
In
)
{
refKind
=
RefKind
.
RefReadOnly
;
refKind
=
RefKind
.
In
;
}
Debug
.
Assert
(
arguments
[
p
]
==
null
);
...
...
src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
浏览文件 @
3be2584b
...
...
@@ -1269,7 +1269,7 @@ internal static BoundExpression NullOrDefault(TypeSymbol typeSymbol, SyntaxNode
#endif
)
{
if
(
refKind
==
RefKind
.
Out
||
refKind
==
RefKind
.
RefReadOnly
)
if
(
refKind
==
RefKind
.
Out
||
refKind
==
RefKind
.
In
)
{
refKind
=
RefKind
.
Ref
;
}
...
...
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs
浏览文件 @
3be2584b
...
...
@@ -742,10 +742,8 @@ private void AddParameterRefKindIfRequired(RefKind refKind)
AddKeyword
(
SyntaxKind
.
RefKeyword
);
AddSpace
();
break
;
case
RefKind
.
RefReadOnly
:
AddKeyword
(
SyntaxKind
.
RefKeyword
);
AddSpace
();
AddKeyword
(
SyntaxKind
.
ReadOnlyKeyword
);
case
RefKind
.
In
:
AddKeyword
(
SyntaxKind
.
InKeyword
);
AddSpace
();
break
;
}
...
...
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -796,7 +796,7 @@ private bool IsValidExtensionMethodSignature()
{
case
RefKind
.
None
:
case
RefKind
.
Ref
:
case
RefKind
.
RefReadOnly
:
case
RefKind
.
In
:
return
!
parameter
.
IsParams
;
default
:
return
false
;
...
...
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -304,7 +304,7 @@ private sealed class PEParameterSymbolWithCustomModifiers : PEParameterSymbol
_customModifiers
=
CSharpCustomModifier
.
Convert
(
customModifiers
);
_refCustomModifiers
=
CSharpCustomModifier
.
Convert
(
refCustomModifiers
);
if
(
this
.
RefKind
!=
RefKind
.
RefReadOnly
&&
_refCustomModifiers
.
Any
(
modifier
=>
!
modifier
.
IsOptional
&&
modifier
.
Modifier
.
IsWellKnownTypeInAttribute
()))
if
(
this
.
RefKind
!=
RefKind
.
In
&&
_refCustomModifiers
.
Any
(
modifier
=>
!
modifier
.
IsOptional
&&
modifier
.
Modifier
.
IsWellKnownTypeInAttribute
()))
{
// The modreq is only accepted on RefReadOnly symbols
isBad
=
true
;
...
...
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -378,7 +378,7 @@ internal void DoGetExtensionMethods(ArrayBuilder<MethodSymbol> methods, string n
var
thisParam
=
method
.
Parameters
.
First
();
if
((
thisParam
.
RefKind
==
RefKind
.
Ref
&&
!
thisParam
.
Type
.
IsValueType
)
||
(
thisParam
.
RefKind
==
RefKind
.
RefReadOnly
&&
thisParam
.
Type
.
TypeKind
!=
TypeKind
.
Struct
))
(
thisParam
.
RefKind
==
RefKind
.
In
&&
thisParam
.
Type
.
TypeKind
!=
TypeKind
.
Struct
))
{
// For ref and ref-readonly extension methods, receivers need to be of the correct types to be considered in lookup
continue
;
...
...
src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -145,7 +145,7 @@ public bool IsOptional
RefKind
refKind
;
return
!
IsParams
&&
IsMetadataOptional
&&
((
refKind
=
RefKind
)
==
RefKind
.
None
||
(
refKind
==
RefKind
.
RefReadOnly
)
||
(
refKind
==
RefKind
.
In
)
||
(
refKind
==
RefKind
.
Ref
&&
ContainingSymbol
.
ContainingType
.
IsComImport
));
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
浏览文件 @
3be2584b
...
...
@@ -125,7 +125,7 @@ internal static void EnsureIsReadOnlyAttributeExists(ImmutableArray<ParameterSym
{
foreach
(
var
parameter
in
parameters
)
{
if
(
parameter
.
RefKind
==
RefKind
.
RefReadOnly
)
if
(
parameter
.
RefKind
==
RefKind
.
In
)
{
// These parameters might not come from a compilation (example: lambdas evaluated in EE).
// During rewriting, lowering will take care of flagging the appropriate PEModuleBuilder instead.
...
...
@@ -533,11 +533,11 @@ private static RefKind GetModifiers(SyntaxTokenList modifiers, out SyntaxToken r
refKind
=
RefKind
.
Ref
;
}
break
;
case
SyntaxKind
.
ReadOnly
Keyword
:
if
(
refKind
==
RefKind
.
Ref
)
case
SyntaxKind
.
In
Keyword
:
if
(
refKind
==
RefKind
.
None
)
{
refnessKeyword
=
modifier
;
refKind
=
RefKind
.
RefReadOnly
;
refKind
=
RefKind
.
In
;
}
break
;
case
SyntaxKind
.
ParamsKeyword
:
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceOrdinaryMethodSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -226,7 +226,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
{
diagnostics
.
Add
(
ErrorCode
.
ERR_RefExtensionMustBeValueTypeOrConstrainedToOne
,
location
,
Name
);
}
else
if
(
parameter0RefKind
==
RefKind
.
RefReadOnly
&&
parameter0Type
.
TypeKind
!=
TypeKind
.
Struct
)
else
if
(
parameter0RefKind
==
RefKind
.
In
&&
parameter0Type
.
TypeKind
!=
TypeKind
.
Struct
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_RefReadOnlyExtensionMustBeValueType
,
location
,
Name
);
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -50,7 +50,7 @@ internal abstract class SourceParameterSymbol : SourceParameterSymbolBase
identifier
.
Parent
.
GetLocation
());
}
if
(
addRefReadOnlyModifier
&&
refKind
==
RefKind
.
RefReadOnly
)
if
(
addRefReadOnlyModifier
&&
refKind
==
RefKind
.
In
)
{
var
modifierType
=
context
.
GetWellKnownType
(
WellKnownType
.
System_Runtime_InteropServices_InAttribute
,
declarationDiagnostics
,
syntax
);
...
...
@@ -257,7 +257,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r
{
base
.
AddSynthesizedAttributes
(
moduleBuilder
,
ref
attributes
);
if
(
this
.
RefKind
==
RefKind
.
RefReadOnly
)
if
(
this
.
RefKind
==
RefKind
.
In
)
{
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeIsReadOnlyAttribute
(
this
));
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
浏览文件 @
3be2584b
...
...
@@ -178,7 +178,7 @@ private void CheckValueParameters(DiagnosticBag diagnostics)
// SPEC: The parameters of an operator must be value parameters.
foreach
(
var
p
in
this
.
Parameters
)
{
if
(
p
.
RefKind
!=
RefKind
.
None
&&
p
.
RefKind
!=
RefKind
.
RefReadOnly
)
if
(
p
.
RefKind
!=
RefKind
.
None
&&
p
.
RefKind
!=
RefKind
.
In
)
{
diagnostics
.
Add
(
ErrorCode
.
ERR_IllegalRefParam
,
this
.
Locations
[
0
]);
break
;
...
...
src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs
浏览文件 @
3be2584b
...
...
@@ -52,7 +52,7 @@ public override RefKind RefKind
if
(
ContainingType
.
IsReadOnly
)
{
return
RefKind
.
RefReadOnly
;
return
RefKind
.
In
;
}
return
RefKind
.
Ref
;
...
...
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_RefReadOnly.cs
浏览文件 @
3be2584b
...
...
@@ -36,7 +36,7 @@ class Test
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
module
.
ContainingAssembly
.
Name
);
...
...
@@ -56,7 +56,7 @@ class Test
CompileAndVerify
(
text
,
symbolValidator
:
module
=>
{
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"Test"
).
GetMethod
(
"M"
).
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Internal
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
});
...
...
@@ -108,7 +108,7 @@ class Test
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
...
...
@@ -138,7 +138,7 @@ struct Test
foreach
(
var
parameter
in
method
.
Parameters
)
{
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
}
});
...
...
@@ -190,7 +190,7 @@ struct Test
Assert
.
Equal
(
2
,
method
.
ParameterCount
);
foreach
(
var
parameter
in
method
.
Parameters
)
{
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
}
...
...
@@ -217,7 +217,7 @@ class Test
{
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"Test"
).
GetMethod
(
".ctor"
).
Parameters
.
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
});
}
...
...
@@ -261,7 +261,7 @@ class Test
{
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"Test"
).
GetMethod
(
".ctor"
).
Parameters
.
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
AssertNoIsReadOnlyAttributeExists
(
module
.
ContainingAssembly
);
...
...
@@ -391,7 +391,7 @@ class Test
Assert
.
True
(
indexer
.
ReturnsByRefReadonly
);
var
parameter
=
indexer
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
indexer
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
...
...
@@ -411,7 +411,7 @@ class Test
CompileAndVerify
(
text
,
symbolValidator
:
module
=>
{
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"Test"
).
GetProperty
(
"this[]"
).
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Internal
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
});
...
...
@@ -463,7 +463,7 @@ class Test
Assert
.
True
(
indexer
.
ReturnsByRefReadonly
);
var
parameter
=
indexer
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
indexer
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
...
...
@@ -490,7 +490,7 @@ public class IsReadOnlyAttribute : System.Attribute { }
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
module
.
ContainingAssembly
.
Name
);
...
...
@@ -507,7 +507,7 @@ public void RefReadOnlyIsWrittenToMetadata_NeedsToBeGenerated_Delegate_Parameter
CompileAndVerify
(
text
,
symbolValidator
:
module
=>
{
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"D"
).
DelegateInvokeMethod
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Internal
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
});
...
...
@@ -552,7 +552,7 @@ public class IsReadOnlyAttribute : System.Attribute { }
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
...
...
@@ -589,7 +589,7 @@ public void M()
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
module
.
ContainingAssembly
.
Name
);
...
...
@@ -613,7 +613,7 @@ public void M()
CompileAndVerify
(
text
,
options
:
options
,
symbolValidator
:
module
=>
{
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"Test"
).
GetMethod
(
"<M>g__Inner|0_0"
).
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Internal
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
});
...
...
@@ -678,7 +678,7 @@ public void M()
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
...
...
@@ -717,7 +717,7 @@ public void M1()
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
module
.
ContainingAssembly
.
Name
);
...
...
@@ -745,7 +745,7 @@ public void M1()
CompileAndVerify
(
text
,
options
:
options
,
symbolValidator
:
module
=>
{
var
parameter
=
module
.
GlobalNamespace
.
GetMember
<
MethodSymbol
>(
"Test.<>c.<M1>b__0_0"
).
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Internal
,
parameter
.
GetAttributes
(),
module
.
ContainingAssembly
.
Name
);
});
...
...
@@ -813,7 +813,7 @@ public void M1()
Assert
.
True
(
method
.
ReturnsByRefReadonly
);
var
parameter
=
method
.
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
method
.
GetReturnTypeAttributes
(),
referenceA
.
Compilation
.
AssemblyName
);
...
...
@@ -1151,7 +1151,7 @@ public class Test
AssertNoIsReadOnlyAttributeExists
(
module
.
ContainingAssembly
);
var
parameter
=
module
.
ContainingAssembly
.
GetTypeByMetadataName
(
"Test"
).
GetMethod
(
"M"
).
GetParameters
().
Single
();
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
parameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
parameter
.
RefKind
);
AssertReferencedIsReadOnlyAttribute
(
Accessibility
.
Public
,
parameter
.
GetAttributes
(),
reference
.
Display
);
});
}
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenReadonlyStructTests.cs
浏览文件 @
3be2584b
...
...
@@ -814,29 +814,29 @@ public override string ToString()
NamedTypeSymbol
namedType
=
comp
.
GetTypeByMetadataName
(
"Program+S1"
);
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// S1<T>
namedType
=
comp
.
GetTypeByMetadataName
(
"Program+S1`1"
);
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// T
TypeSymbol
type
=
namedType
.
TypeParameters
[
0
];
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// S1<object>
namedType
=
namedType
.
Construct
(
comp
.
ObjectType
);
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// S2
namedType
=
comp
.
GetTypeByMetadataName
(
"Program+S2"
);
...
...
@@ -970,29 +970,29 @@ public override string ToString()
NamedTypeSymbol
namedType
=
comp
.
GetTypeByMetadataName
(
"Program+S1"
);
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// S1<T>
namedType
=
comp
.
GetTypeByMetadataName
(
"Program+S1`1"
);
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// T
TypeSymbol
type
=
namedType
.
TypeParameters
[
0
];
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// S1<object>
namedType
=
namedType
.
Construct
(
comp
.
ObjectType
);
Assert
.
True
(
namedType
.
IsReadOnly
);
Assert
.
Equal
(
RefKind
.
Out
,
namedType
.
Constructors
[
0
].
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"M1"
).
ThisParameter
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
namedType
.
GetMethod
(
"ToString"
).
ThisParameter
.
RefKind
);
// S2
namedType
=
comp
.
GetTypeByMetadataName
(
"Program+S2"
);
...
...
src/Compilers/CSharp/Test/Semantic/Semantics/RefExtensionMethodsTests.cs
浏览文件 @
3be2584b
...
...
@@ -1962,7 +1962,7 @@ public static class Ext
var
model
=
comp
.
GetSemanticModel
(
tree
);
var
symbol
=
(
ParameterSymbol
)
model
.
GetDeclaredSymbolForNode
(
parameter
.
AsNode
());
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
symbol
.
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
symbol
.
RefKind
);
}
[
Fact
]
...
...
src/Compilers/CSharp/Test/Symbol/Symbols/Source/DelegateTests.cs
浏览文件 @
3be2584b
...
...
@@ -750,7 +750,7 @@ public void RefReadonlyReturningDelegate()
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
d
.
DelegateInvokeMethod
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
((
MethodSymbol
)
d
.
GetMembers
(
"EndInvoke"
).
Single
()).
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
d
.
DelegateInvokeMethod
.
Parameters
[
0
].
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
d
.
DelegateInvokeMethod
.
Parameters
[
0
].
RefKind
);
}
[
Fact
]
...
...
@@ -779,14 +779,14 @@ public static void Main()
Assert
.
False
(
lambda
.
ReturnsByRef
);
Assert
.
True
(
lambda
.
ReturnsByRefReadonly
);
Assert
.
Equal
(
lambda
.
Parameters
[
0
].
RefKind
,
RefKind
.
RefReadOnly
);
Assert
.
Equal
(
lambda
.
Parameters
[
0
].
RefKind
,
RefKind
.
In
);
lambdaSyntax
=
tree
.
GetCompilationUnitRoot
().
DescendantNodes
().
OfType
<
AnonymousMethodExpressionSyntax
>().
Single
();
lambda
=
(
LambdaSymbol
)
model
.
GetSymbolInfo
(
lambdaSyntax
).
Symbol
;
Assert
.
False
(
lambda
.
ReturnsByRef
);
Assert
.
True
(
lambda
.
ReturnsByRefReadonly
);
Assert
.
Equal
(
lambda
.
Parameters
[
0
].
RefKind
,
RefKind
.
RefReadOnly
);
Assert
.
Equal
(
lambda
.
Parameters
[
0
].
RefKind
,
RefKind
.
In
);
}
}
}
src/Compilers/CSharp/Test/Symbol/Symbols/Source/ExpressionBodiedPropertyTests.cs
浏览文件 @
3be2584b
...
...
@@ -554,7 +554,7 @@ class C
Assert
.
False
(
p
.
GetMethod
.
IsImplicitlyDeclared
);
Assert
.
True
(
p
.
IsExpressionBodied
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
p
.
GetMethod
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
p
.
GetMethod
.
Parameters
[
0
].
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
p
.
GetMethod
.
Parameters
[
0
].
RefKind
);
Assert
.
False
(
p
.
ReturnsByRef
);
Assert
.
False
(
p
.
GetMethod
.
ReturnsByRef
);
Assert
.
True
(
p
.
ReturnsByRefReadonly
);
...
...
@@ -582,7 +582,7 @@ class C
Assert
.
False
(
p
.
GetMethod
.
IsImplicitlyDeclared
);
Assert
.
True
(
p
.
IsExpressionBodied
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
p
.
GetMethod
.
RefKind
);
Assert
.
Equal
(
RefKind
.
RefReadOnly
,
p
.
GetMethod
.
Parameters
[
0
].
RefKind
);
Assert
.
Equal
(
RefKind
.
In
,
p
.
GetMethod
.
Parameters
[
0
].
RefKind
);
Assert
.
False
(
p
.
ReturnsByRef
);
Assert
.
False
(
p
.
GetMethod
.
ReturnsByRef
);
Assert
.
True
(
p
.
ReturnsByRefReadonly
);
...
...
src/VisualStudio/Core/Test/ChangeSignature/ChangeSignatureViewModelTests.vb
浏览文件 @
3be2584b
...
...
@@ -359,7 +359,7 @@ class MyClass
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestRefKindsDisplayedCorrectly
()
As
Tasks
.
Task
Dim
includedInTest
=
{
RefKind
.
None
,
RefKind
.
Ref
,
RefKind
.
Out
,
RefKind
.
RefReadOnly
}
Dim
includedInTest
=
{
RefKind
.
None
,
RefKind
.
Ref
,
RefKind
.
Out
,
RefKind
.
In
,
RefKind
.
RefReadOnly
}
Assert
.
Equal
(
includedInTest
,
EnumUtilities
.
GetValues
(
Of
RefKind
)())
Dim
markup
=
<
Text
><
!
[
CDATA
[
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
浏览文件 @
3be2584b
...
...
@@ -130,8 +130,8 @@ internal static SyntaxTokenList GetParameterModifiers(RefKind refKind)
return
SyntaxFactory
.
TokenList
(
SyntaxFactory
.
Token
(
SyntaxKind
.
OutKeyword
));
case
RefKind
.
Ref
:
return
SyntaxFactory
.
TokenList
(
SyntaxFactory
.
Token
(
SyntaxKind
.
RefKeyword
));
case
RefKind
.
RefReadOnly
:
return
SyntaxFactory
.
TokenList
(
SyntaxFactory
.
Token
(
SyntaxKind
.
RefKeyword
),
SyntaxFactory
.
Token
(
SyntaxKind
.
ReadOnly
Keyword
));
case
RefKind
.
In
:
return
SyntaxFactory
.
TokenList
(
SyntaxFactory
.
Token
(
SyntaxKind
.
In
Keyword
));
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
refKind
);
}
...
...
@@ -142,7 +142,7 @@ internal static SyntaxToken GetArgumentModifiers(RefKind refKind)
switch
(
refKind
)
{
case
RefKind
.
None
:
case
RefKind
.
RefReadOnly
:
case
RefKind
.
In
:
return
default
;
case
RefKind
.
Out
:
return
SyntaxFactory
.
Token
(
SyntaxKind
.
OutKeyword
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录