Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e6b31c1f
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,发现更多精彩内容 >>
提交
e6b31c1f
编写于
5月 19, 2017
作者:
O
Omar Tawfik
提交者:
Omar Tawfik
5月 19, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding IsConst modreq on ref readonly signatures
上级
ea0afa37
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
1058 addition
and
70 deletion
+1058
-70
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/SymbolFactory.cs
...lers/CSharp/Portable/Symbols/Metadata/PE/SymbolFactory.cs
+5
-0
src/Compilers/CSharp/Portable/Symbols/PropertySymbolExtensions.cs
...ilers/CSharp/Portable/Symbols/PropertySymbolExtensions.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/CustomModifierUtils.cs
...ers/CSharp/Portable/Symbols/Source/CustomModifierUtils.cs
+1
-2
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
...ers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
...pilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
+3
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceConstructorSymbol.cs
...CSharp/Portable/Symbols/Source/SourceConstructorSymbol.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs
...arp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs
+1
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
...Sharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
+11
-2
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
...s/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
+22
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
...rs/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
+9
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
...ble/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
+1
-0
src/Compilers/CSharp/Test/Emit/CSharpCompilerEmitTest.csproj
src/Compilers/CSharp/Test/Emit/CSharpCompilerEmitTest.csproj
+1
-0
src/Compilers/CSharp/Test/Emit/Emit/IsConstModifierTests.cs
src/Compilers/CSharp/Test/Emit/Emit/IsConstModifierTests.cs
+757
-0
src/Compilers/Core/Portable/MetadataReader/MetadataDecoder.cs
...Compilers/Core/Portable/MetadataReader/MetadataDecoder.cs
+45
-63
src/Compilers/Core/Portable/MetadataReader/SymbolFactory.cs
src/Compilers/Core/Portable/MetadataReader/SymbolFactory.cs
+1
-0
src/Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs
...Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs
+5
-0
src/Compilers/Core/Portable/PEWriter/MetadataVisitor.cs
src/Compilers/Core/Portable/PEWriter/MetadataVisitor.cs
+2
-0
src/Compilers/Core/Portable/WellKnownTypes.cs
src/Compilers/Core/Portable/WellKnownTypes.cs
+2
-0
src/Compilers/VisualBasic/Portable/Symbols/Metadata/PE/SymbolFactory.vb
...VisualBasic/Portable/Symbols/Metadata/PE/SymbolFactory.vb
+5
-0
src/Compilers/VisualBasic/Test/Emit/Emit/EmitCustomModifiers.vb
...mpilers/VisualBasic/Test/Emit/Emit/EmitCustomModifiers.vb
+184
-0
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/SymbolFactory.cs
浏览文件 @
e6b31c1f
...
...
@@ -57,6 +57,11 @@ internal override bool IsVolatileModifierType(PEModuleSymbol moduleSymbol, TypeS
return
type
.
SpecialType
==
SpecialType
.
System_Runtime_CompilerServices_IsVolatile
;
}
internal
override
bool
IsConstModifierType
(
PEModuleSymbol
moduleSymbol
,
TypeSymbol
type
)
{
return
type
.
ToDisplayString
()
==
WellKnownTypes
.
GetMetadataName
(
WellKnownType
.
System_Runtime_CompilerServices_IsConst
);
}
internal
override
TypeSymbol
GetSZArrayTypeSymbol
(
PEModuleSymbol
moduleSymbol
,
TypeSymbol
elementType
,
ImmutableArray
<
ModifierInfo
<
TypeSymbol
>>
customModifiers
)
{
if
(
elementType
is
UnsupportedMetadataTypeSymbol
)
...
...
src/Compilers/CSharp/Portable/Symbols/PropertySymbolExtensions.cs
浏览文件 @
e6b31c1f
...
...
@@ -63,7 +63,7 @@ public static bool HasRefOrOutParameter(this PropertySymbol property)
{
foreach
(
ParameterSymbol
param
in
property
.
Parameters
)
{
if
(
param
.
RefKind
!=
RefKind
.
None
)
if
(
param
.
RefKind
==
RefKind
.
Ref
||
param
.
RefKind
==
RefKind
.
Out
)
{
return
true
;
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/CustomModifierUtils.cs
浏览文件 @
e6b31c1f
...
...
@@ -35,8 +35,7 @@ internal static class CustomModifierUtils
// have already been compared.
MethodSymbol
constructedSourceMethod
=
sourceMethod
.
ConstructIfGeneric
(
destinationMethod
.
TypeArguments
);
customModifiers
=
CustomModifiersTuple
.
Create
(
constructedSourceMethod
.
ReturnTypeCustomModifiers
,
destinationMethod
.
ReturnsByRef
?
constructedSourceMethod
.
RefCustomModifiers
:
ImmutableArray
<
CustomModifier
>.
Empty
);
customModifiers
=
CustomModifiersTuple
.
Create
(
constructedSourceMethod
.
ReturnTypeCustomModifiers
,
constructedSourceMethod
.
RefCustomModifiers
);
parameters
=
CopyParameterCustomModifiers
(
constructedSourceMethod
.
Parameters
,
destinationMethod
.
Parameters
,
alsoCopyParamsModifier
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionSymbol.cs
浏览文件 @
e6b31c1f
...
...
@@ -160,6 +160,7 @@ private void ComputeParameters()
arglistToken
:
out
arglistToken
,
allowRefOrOut
:
true
,
allowThis
:
true
,
shouldPlaceIsConstModifier
:
false
,
diagnostics
:
diagnostics
);
ParameterHelpers
.
EnsureIsReadOnlyAttributeExists
(
parameters
,
diagnostics
,
modifyCompilationForRefReadOnly
:
false
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
浏览文件 @
e6b31c1f
...
...
@@ -20,7 +20,8 @@ internal static class ParameterHelpers
out
SyntaxToken
arglistToken
,
DiagnosticBag
diagnostics
,
bool
allowRefOrOut
,
bool
allowThis
)
bool
allowThis
,
bool
shouldPlaceIsConstModifier
)
{
arglistToken
=
default
(
SyntaxToken
);
...
...
@@ -90,6 +91,7 @@ internal static class ParameterHelpers
parameterIndex
,
(
paramsKeyword
.
Kind
()
!=
SyntaxKind
.
None
),
parameterIndex
==
0
&&
thisKeyword
.
Kind
()
!=
SyntaxKind
.
None
,
shouldPlaceIsConstModifier
,
diagnostics
);
ReportParameterErrors
(
owner
,
parameterSyntax
,
parameter
,
firstDefault
,
diagnostics
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceConstructorSymbol.cs
浏览文件 @
e6b31c1f
...
...
@@ -83,6 +83,7 @@ protected override void MethodChecks(DiagnosticBag diagnostics)
bodyBinder
,
this
,
parameterList
,
out
arglistToken
,
allowRefOrOut
:
true
,
allowThis
:
false
,
shouldPlaceIsConstModifier
:
false
,
diagnostics
:
diagnostics
);
_lazyIsVararg
=
(
arglistToken
.
Kind
()
==
SyntaxKind
.
ArgListKeyword
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceDelegateMethodSymbol.cs
浏览文件 @
e6b31c1f
...
...
@@ -249,6 +249,7 @@ private sealed class InvokeMethod : SourceDelegateMethodSymbol
binder
,
this
,
syntax
.
ParameterList
,
out
arglistToken
,
allowRefOrOut
:
true
,
allowThis
:
false
,
shouldPlaceIsConstModifier
:
false
,
diagnostics
:
diagnostics
);
if
(
arglistToken
.
Kind
()
==
SyntaxKind
.
ArgListKeyword
)
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
浏览文件 @
e6b31c1f
...
...
@@ -167,6 +167,7 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
signatureBinder
,
this
,
syntax
.
ParameterList
,
out
arglistToken
,
allowRefOrOut
:
true
,
allowThis
:
true
,
shouldPlaceIsConstModifier
:
true
,
diagnostics
:
diagnostics
);
_lazyIsVararg
=
(
arglistToken
.
Kind
()
==
SyntaxKind
.
ArgListKeyword
);
...
...
@@ -320,11 +321,19 @@ private void MethodChecks(MethodDeclarationSyntax syntax, Binder withTypeParamsB
if
((
object
)
overriddenMethod
!=
null
)
{
CustomModifierUtils
.
CopyMethodCustomModifiers
(
overriddenMethod
,
this
,
out
_lazyReturnType
,
out
_lazyCustomModifiers
,
CustomModifierUtils
.
CopyMethodCustomModifiers
(
overriddenMethod
,
this
,
out
_lazyReturnType
,
out
_lazyCustomModifiers
,
out
_lazyParameters
,
alsoCopyParamsModifier
:
true
);
}
}
else
if
(
_refKind
==
RefKind
.
RefReadOnly
&&
(
this
.
IsVirtual
||
this
.
IsAbstract
))
{
var
isConst
=
withTypeParamsBinder
.
GetWellKnownType
(
WellKnownType
.
System_Runtime_CompilerServices_IsConst
,
diagnostics
,
syntax
);
_lazyCustomModifiers
=
CustomModifiersTuple
.
Create
(
typeCustomModifiers
:
ImmutableArray
<
CustomModifier
>.
Empty
,
refCustomModifiers
:
ImmutableArray
.
Create
(
CSharpCustomModifier
.
CreateRequired
(
isConst
)));
}
}
else
if
((
object
)
_explicitInterfaceType
!=
null
)
{
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
浏览文件 @
e6b31c1f
...
...
@@ -34,10 +34,12 @@ internal abstract class SourceParameterSymbol : SourceParameterSymbolBase
int
ordinal
,
bool
isParams
,
bool
isExtensionMethodThis
,
bool
shouldPlaceIsConstModifier
,
DiagnosticBag
declarationDiagnostics
)
{
var
name
=
identifier
.
ValueText
;
var
locations
=
ImmutableArray
.
Create
<
Location
>(
new
SourceLocation
(
identifier
));
var
location
=
new
SourceLocation
(
identifier
);
var
locations
=
ImmutableArray
.
Create
<
Location
>(
location
);
if
(
isParams
)
{
...
...
@@ -48,6 +50,25 @@ internal abstract class SourceParameterSymbol : SourceParameterSymbolBase
identifier
.
Parent
.
GetLocation
());
}
if
(
shouldPlaceIsConstModifier
&&
refKind
==
RefKind
.
RefReadOnly
&&
(
owner
.
IsVirtual
||
owner
.
IsAbstract
))
{
var
isConst
=
context
.
GetWellKnownType
(
WellKnownType
.
System_Runtime_CompilerServices_IsConst
,
declarationDiagnostics
,
syntax
);
return
new
SourceComplexParameterSymbolWithCustomModifiers
(
owner
,
ordinal
,
parameterType
,
refKind
,
ImmutableArray
<
CustomModifier
>.
Empty
,
ImmutableArray
.
Create
(
CSharpCustomModifier
.
CreateRequired
(
isConst
)),
name
,
locations
,
syntax
.
GetReference
(),
ConstantValue
.
Unset
,
isParams
,
isExtensionMethodThis
);
}
if
(!
isParams
&&
!
isExtensionMethodThis
&&
(
syntax
.
Default
==
null
)
&&
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
浏览文件 @
e6b31c1f
...
...
@@ -273,6 +273,14 @@ internal sealed class SourcePropertySymbol : PropertySymbol, IAttributeTargetSym
_lazyParameters
=
CustomModifierUtils
.
CopyParameterCustomModifiers
(
overriddenOrImplementedProperty
.
Parameters
,
_lazyParameters
,
alsoCopyParamsModifier
:
isOverride
);
}
}
else
if
(
_refKind
==
RefKind
.
RefReadOnly
&&
(
this
.
IsVirtual
||
this
.
IsAbstract
))
{
var
isConst
=
bodyBinder
.
GetWellKnownType
(
WellKnownType
.
System_Runtime_CompilerServices_IsConst
,
diagnostics
,
syntax
);
_customModifiers
=
CustomModifiersTuple
.
Create
(
ImmutableArray
<
CustomModifier
>.
Empty
,
ImmutableArray
.
Create
(
CSharpCustomModifier
.
CreateRequired
(
isConst
)));
}
if
(!
hasAccessorList
)
{
...
...
@@ -792,6 +800,7 @@ private DeclarationModifiers MakeModifiers(SyntaxTokenList modifiers, bool isExp
binder
,
owner
,
parameterSyntaxOpt
,
out
arglistToken
,
allowRefOrOut
:
false
,
allowThis
:
false
,
shouldPlaceIsConstModifier
:
true
,
diagnostics
:
diagnostics
);
if
(
arglistToken
.
Kind
()
!=
SyntaxKind
.
None
)
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceUserDefinedOperatorSymbolBase.cs
浏览文件 @
e6b31c1f
...
...
@@ -131,6 +131,7 @@ protected override void MethodChecks(DiagnosticBag diagnostics)
out
arglistToken
,
allowRefOrOut
:
true
,
allowThis
:
false
,
shouldPlaceIsConstModifier
:
false
,
diagnostics
:
diagnostics
);
if
(
arglistToken
.
Kind
()
==
SyntaxKind
.
ArgListKeyword
)
...
...
src/Compilers/CSharp/Test/Emit/CSharpCompilerEmitTest.csproj
浏览文件 @
e6b31c1f
...
...
@@ -158,6 +158,7 @@
<Compile
Include=
"Emit\EntryPointTests.cs"
/>
<Compile
Include=
"Emit\NoPiaEmbedTypes.cs"
/>
<Compile
Include=
"Emit\OptionalArgumentsTests.cs"
/>
<Compile
Include=
"Emit\IsConstModifierTests.cs"
/>
<Compile
Include=
"Emit\ResourceTests.cs"
/>
<Compile
Include=
"CodeGen\CodeGenScriptTests.cs"
/>
<Compile
Include=
"PDB\CheckSumTest.cs"
/>
...
...
src/Compilers/CSharp/Test/Emit/Emit/IsConstModifierTests.cs
0 → 100644
浏览文件 @
e6b31c1f
此差异已折叠。
点击以展开。
src/Compilers/Core/Portable/MetadataReader/MetadataDecoder.cs
浏览文件 @
e6b31c1f
...
...
@@ -672,33 +672,47 @@ private TypeSymbol GetTypeOfTypeDef(TypeDefinitionHandle typeDef, out bool isNoP
/// <exception cref="UnsupportedSignatureContent">If the encoded type is invalid.</exception>
/// <exception cref="BadImageFormatException">An exception from metadata reader.</exception>
private
ImmutableArray
<
ModifierInfo
<
TypeSymbol
>>
DecodeModifiersOrThrow
(
ref
BlobReader
signatureReader
,
out
SignatureTypeCode
typeCode
)
private
ImmutableArray
<
ModifierInfo
<
TypeSymbol
>>
DecodeModifiersOrThrow
(
ref
BlobReader
signatureReader
,
out
SignatureTypeCode
typeCode
,
Func
<
TypeSymbol
,
bool
>
acceptRequiredModifier
=
null
)
{
ArrayBuilder
<
ModifierInfo
<
TypeSymbol
>>
modifiers
=
null
;
for
(;;)
{
typeCode
=
signatureReader
.
ReadSignatureTypeCode
();
bool
isOptional
;
if
(
typeCode
==
SignatureTypeCode
.
RequiredModifier
)
{
throw
new
UnsupportedSignatureContent
();
isOptional
=
false
;
}
else
if
(
typeCode
==
SignatureTypeCode
.
OptionalModifier
)
{
isOptional
=
true
;
}
else
{
break
;
}
TypeSymbol
type
=
DecodeModifierTypeOrThrow
(
ref
signatureReader
);
if
(
typeCode
==
SignatureTypeCode
.
OptionalModifier
)
// if it is a required modifier, make sure the compiler supports this modifier type
if
(!
isOptional
&&
(
acceptRequiredModifier
==
null
||
!
acceptRequiredModifier
(
type
)))
{
ModifierInfo
<
TypeSymbol
>
modifier
=
new
ModifierInfo
<
TypeSymbol
>(
true
,
DecodeModifierTypeOrThrow
(
ref
signatureReader
));
throw
new
UnsupportedSignatureContent
();
}
if
(
modifiers
==
null
)
{
modifiers
=
ArrayBuilder
<
ModifierInfo
<
TypeSymbol
>>.
GetInstance
();
}
ModifierInfo
<
TypeSymbol
>
modifier
=
new
ModifierInfo
<
TypeSymbol
>(
isOptional
,
type
);
modifiers
.
Add
(
modifier
);
continue
;
if
(
modifiers
==
null
)
{
modifiers
=
ArrayBuilder
<
ModifierInfo
<
TypeSymbol
>>.
GetInstance
();
}
break
;
modifiers
.
Add
(
modifier
)
;
}
return
modifiers
?.
ToImmutableAndFree
()
??
default
(
ImmutableArray
<
ModifierInfo
<
TypeSymbol
>>);
...
...
@@ -1095,15 +1109,26 @@ private void DecodeParameterOrThrow(ref BlobReader signatureReader, /*out*/ ref
{
bool
refersToNoPiaLocalType
;
var
isConstFound
=
false
;
SignatureTypeCode
typeCode
;
info
.
CustomModifiers
=
DecodeModifiersOrThrow
(
ref
signatureReader
,
out
typeCode
);
info
.
CustomModifiers
=
DecodeModifiersOrThrow
(
ref
signatureReader
,
out
typeCode
,
acceptRequiredModifier
:
type
=>
{
var
isConst
=
IsConstModifierType
(
type
);
isConstFound
|=
isConst
;
return
isConst
;
});
if
(
typeCode
==
SignatureTypeCode
.
ByReference
)
{
info
.
IsByRef
=
true
;
info
.
RefCustomModifiers
=
info
.
CustomModifiers
;
info
.
RefCustomModifiers
=
info
.
CustomModifiers
;
info
.
CustomModifiers
=
DecodeModifiersOrThrow
(
ref
signatureReader
,
out
typeCode
);
}
else
if
(
isConstFound
)
{
// This cannot be placed on CustomModifiers, just RefCustomModifiers
throw
new
UnsupportedSignatureContent
();
}
info
.
Type
=
DecodeTypeOrThrow
(
ref
signatureReader
,
typeCode
,
out
refersToNoPiaLocalType
);
}
...
...
@@ -1844,60 +1869,17 @@ protected TypeSymbol DecodeFieldSignature(ref BlobReader signatureReader, out bo
try
{
// See if there is a Volatile modifier.
var
isVolatileFound
=
false
;
SignatureTypeCode
typeCode
;
ArrayBuilder
<
ModifierInfo
<
TypeSymbol
>>
customModifierBuilder
=
null
;
for
(;;)
customModifiers
=
DecodeModifiersOrThrow
(
ref
signatureReader
,
out
typeCode
,
acceptRequiredModifier
:
type
=>
{
typeCode
=
signatureReader
.
ReadSignatureTypeCode
();
var
isTypeVolatile
=
this
.
IsVolatileModifierType
(
type
);
isVolatileFound
|=
isTypeVolatile
;
return
isTypeVolatile
;
});
if
(
typeCode
==
SignatureTypeCode
.
OptionalModifier
||
typeCode
==
SignatureTypeCode
.
RequiredModifier
)
{
TypeSymbol
type
;
try
{
type
=
DecodeModifierTypeOrThrow
(
ref
signatureReader
);
}
catch
(
BadImageFormatException
mrEx
)
{
return
GetUnsupportedMetadataTypeSymbol
(
mrEx
);
// an exception from metadata reader.
}
catch
(
UnsupportedSignatureContent
)
{
return
GetUnsupportedMetadataTypeSymbol
();
// unsupported signature content
}
ModifierInfo
<
TypeSymbol
>
modifier
=
new
ModifierInfo
<
TypeSymbol
>((
typeCode
==
SignatureTypeCode
.
OptionalModifier
),
type
);
if
(
IsVolatileModifierType
(
modifier
.
Modifier
))
{
isVolatile
=
true
;
}
else
if
(!
modifier
.
IsOptional
)
{
return
GetUnsupportedMetadataTypeSymbol
();
// unsupported signature content
}
if
(
customModifierBuilder
==
null
)
{
customModifierBuilder
=
ArrayBuilder
<
ModifierInfo
<
TypeSymbol
>>.
GetInstance
();
}
customModifierBuilder
.
Add
(
modifier
);
continue
;
}
break
;
}
if
(
customModifierBuilder
!=
null
)
{
customModifiers
=
customModifierBuilder
.
ToImmutableAndFree
();
}
isVolatile
=
isVolatileFound
;
// get the type
bool
refersToNoPiaLocalType
;
...
...
src/Compilers/Core/Portable/MetadataReader/SymbolFactory.cs
浏览文件 @
e6b31c1f
...
...
@@ -41,6 +41,7 @@ internal abstract class SymbolFactory<ModuleSymbol, TypeSymbol>
internal
abstract
TypeSymbol
GetEnumUnderlyingType
(
ModuleSymbol
moduleSymbol
,
TypeSymbol
type
);
internal
abstract
bool
IsVolatileModifierType
(
ModuleSymbol
moduleSymbol
,
TypeSymbol
type
);
internal
abstract
bool
IsConstModifierType
(
ModuleSymbol
moduleSymbol
,
TypeSymbol
type
);
internal
abstract
Cci
.
PrimitiveTypeCode
GetPrimitiveTypeCode
(
ModuleSymbol
moduleSymbol
,
TypeSymbol
type
);
}
}
src/Compilers/Core/Portable/MetadataReader/TypeNameDecoder.cs
浏览文件 @
e6b31c1f
...
...
@@ -92,6 +92,11 @@ protected bool IsVolatileModifierType(TypeSymbol type)
return
_factory
.
IsVolatileModifierType
(
this
.
moduleSymbol
,
type
);
}
protected
bool
IsConstModifierType
(
TypeSymbol
type
)
{
return
_factory
.
IsConstModifierType
(
this
.
moduleSymbol
,
type
);
}
protected
Microsoft
.
Cci
.
PrimitiveTypeCode
GetPrimitiveTypeCode
(
TypeSymbol
type
)
{
return
_factory
.
GetPrimitiveTypeCode
(
this
.
moduleSymbol
,
type
);
...
...
src/Compilers/Core/Portable/PEWriter/MetadataVisitor.cs
浏览文件 @
e6b31c1f
...
...
@@ -273,6 +273,7 @@ public virtual void Visit(IMethodDefinition method)
{
this
.
Visit
(
method
.
GetReturnValueAttributes
(
Context
));
this
.
Visit
(
method
.
ReturnValueCustomModifiers
);
this
.
Visit
(
method
.
RefCustomModifiers
);
if
(
method
.
HasDeclarativeSecurity
)
{
...
...
@@ -412,6 +413,7 @@ public virtual void Visit(IParameterDefinition parameterDefinition)
Debug
.
Assert
((
marshalling
!=
null
||
!
parameterDefinition
.
MarshallingDescriptor
.
IsDefaultOrEmpty
)
==
parameterDefinition
.
IsMarshalledExplicitly
);
this
.
Visit
(
parameterDefinition
.
GetAttributes
(
Context
));
this
.
Visit
(
parameterDefinition
.
RefCustomModifiers
);
this
.
Visit
(
parameterDefinition
.
CustomModifiers
);
MetadataConstant
defaultValue
=
parameterDefinition
.
GetDefaultValue
(
Context
);
...
...
src/Compilers/Core/Portable/WellKnownTypes.cs
浏览文件 @
e6b31c1f
...
...
@@ -267,6 +267,7 @@ internal enum WellKnownType
System_Runtime_CompilerServices_IsReadOnlyAttribute
,
System_Runtime_CompilerServices_IsByRefLikeAttribute
,
System_Runtime_CompilerServices_IsConst
,
NextAvailable
,
}
...
...
@@ -529,6 +530,7 @@ internal static class WellKnownTypes
"System.Runtime.CompilerServices.IsReadOnlyAttribute"
,
"System.Runtime.CompilerServices.IsByRefLikeAttribute"
,
"System.Runtime.CompilerServices.IsConst"
,
};
private
readonly
static
Dictionary
<
string
,
WellKnownType
>
s_nameToTypeIdMap
=
new
Dictionary
<
string
,
WellKnownType
>((
int
)
Count
);
...
...
src/Compilers/VisualBasic/Portable/Symbols/Metadata/PE/SymbolFactory.vb
浏览文件 @
e6b31c1f
...
...
@@ -49,6 +49,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Return
False
End
Function
Friend
Overrides
Function
IsConstModifierType
(
moduleSymbol
As
PEModuleSymbol
,
type
As
TypeSymbol
)
As
Boolean
' VB doesn't deal with ref-readonly parameters or return-types.
Return
False
End
Function
Friend
Overrides
Function
GetSZArrayTypeSymbol
(
moduleSymbol
As
PEModuleSymbol
,
elementType
As
TypeSymbol
,
customModifiers
As
ImmutableArray
(
Of
ModifierInfo
(
Of
TypeSymbol
)))
As
TypeSymbol
If
TypeOf
elementType
Is
UnsupportedMetadataTypeSymbol
Then
Return
elementType
...
...
src/Compilers/VisualBasic/Test/Emit/Emit/EmitCustomModifiers.vb
浏览文件 @
e6b31c1f
...
...
@@ -4,6 +4,7 @@ Imports System
Imports
System.Collections.Generic
Imports
System.Linq
Imports
System.Text
Imports
Microsoft.CodeAnalysis.CSharp
Imports
Microsoft.CodeAnalysis.Test.Utilities
Imports
Microsoft.CodeAnalysis.Text
Imports
Microsoft.CodeAnalysis.VisualBasic.Symbols
...
...
@@ -107,5 +108,188 @@ End Class
CompileAndVerify
(
comp
,
expectedOutput
:
=<
!
[
CDATA
[
2
]]
>
)
End
Sub
<
Fact
>
Public
Sub
NonExtensibleReadOnlySignaturesAreRead
()
Dim
reference
=
CreateCSharpCompilation
(
"
public class TestRef
{
public void M(ref readonly int x)
{
System.Console.WriteLine(x);
}
}"
,
parseOptions
:
=
New
CSharpParseOptions
(
CSharp
.
LanguageVersion
.
Latest
)).
EmitToImageReference
()
Dim
source
=
<
compilation
>
<
file
>
Class
Test
Shared
Sub
Main
()
Dim
x
=
5
Dim
obj
=
New
TestRef
()
obj
.
M
(
x
)
End
Sub
End
Class
</
file
>
</
compilation
>
CompileAndVerify
(
source
,
additionalRefs
:
=
{
reference
},
expectedOutput
:
=
"5"
)
End
Sub
<
Fact
>
Public
Sub
ExtensibleReadOnlySignaturesAreNotSupported_Methods_ReturnTypes
()
Dim
reference
=
CreateCSharpCompilation
(
"
public class TestRef
{
private int value = 0;
public virtual ref readonly int M()
{
return ref value;
}
}"
,
parseOptions
:
=
New
CSharpParseOptions
(
CSharp
.
LanguageVersion
.
Latest
)).
EmitToImageReference
()
Dim
source
=
<
compilation
>
<
file
>
Class
Test
Shared
Sub
Main
()
Dim
obj
=
New
TestRef
()
Dim
value
=
obj
.
M
()
End
Sub
End
Class
</
file
>
</
compilation
>
Dim
compilation
=
CreateCompilationWithMscorlib
(
source
,
references
:
=
{
reference
})
AssertTheseDiagnostics
(
compilation
,
<
expected
>
BC30657
:
'M' has a return type that is not supported or parameter types that are not supported.
Dim
value
=
obj
.
M
()
~
</
expected
>
)
End
Sub
<
Fact
>
Public
Sub
ExtensibleReadOnlySignaturesAreNotSupported_Methods_Parameters
()
Dim
reference
=
CreateCSharpCompilation
(
"
public class TestRef
{
public virtual void M(ref readonly int x)
{
System.Console.WriteLine(x);
}
}"
,
parseOptions
:
=
New
CSharpParseOptions
(
CSharp
.
LanguageVersion
.
Latest
)).
EmitToImageReference
()
Dim
source
=
<
compilation
>
<
file
>
Class
Test
Shared
Sub
Main
()
Dim
x
=
5
Dim
obj
=
New
TestRef
()
obj
.
M
(
x
)
End
Sub
End
Class
</
file
>
</
compilation
>
Dim
compilation
=
CreateCompilationWithMscorlib
(
source
,
references
:
=
{
reference
})
AssertTheseDiagnostics
(
compilation
,
<
expected
>
BC30657
:
'M' has a return type that is not supported or parameter types that are not supported.
obj
.
M
(
x
)
~
</
expected
>
)
End
Sub
<
Fact
>
Public
Sub
ExtensibleReadOnlySignaturesAreNotSupported_Properties
()
Dim
reference
=
CreateCSharpCompilation
(
"
public class TestRef
{
private int value = 0;
public virtual ref readonly int P => ref value;
}"
,
parseOptions
:
=
New
CSharpParseOptions
(
CSharp
.
LanguageVersion
.
Latest
)).
EmitToImageReference
()
Dim
source
=
<
compilation
>
<
file
>
Class
Test
Shared
Sub
Main
()
Dim
obj
=
New
TestRef
()
Dim
value
=
obj
.
P
End
Sub
End
Class
</
file
>
</
compilation
>
Dim
compilation
=
CreateCompilationWithMscorlib
(
source
,
references
:
=
{
reference
})
AssertTheseDiagnostics
(
compilation
,
<
expected
>
BC30643
:
Property
'P' is of an unsupported type.
Dim
value
=
obj
.
P
~
</
expected
>
)
End
Sub
<
Fact
>
Public
Sub
ExtensibleReadOnlySignaturesAreNotSupported_Indexers_ReturnTypes
()
Dim
reference
=
CreateCSharpCompilation
(
"
public class TestRef
{
private int value = 0;
public virtual ref readonly int this[int p] => ref value;
}"
,
parseOptions
:
=
New
CSharpParseOptions
(
CSharp
.
LanguageVersion
.
Latest
)).
EmitToImageReference
()
Dim
source
=
<
compilation
>
<
file
>
Class
Test
Shared
Sub
Main
()
Dim
obj
=
New
TestRef
()
Dim
value
=
obj
(
0
)
End
Sub
End
Class
</
file
>
</
compilation
>
Dim
compilation
=
CreateCompilationWithMscorlib
(
source
,
references
:
=
{
reference
})
AssertTheseDiagnostics
(
compilation
,
<
expected
>
BC30643
:
Property
'TestRef.Item(p As )' is of an unsupported type.
Dim
value
=
obj
(
0
)
~~~
</
expected
>
)
End
Sub
<
Fact
>
Public
Sub
ExtensibleReadOnlySignaturesAreNotSupported_Indexers_Parameters
()
Dim
reference
=
CreateCSharpCompilation
(
"
public class TestRef
{
public virtual int this[ref readonly int p] => 0;
}"
,
parseOptions
:
=
New
CSharpParseOptions
(
CSharp
.
LanguageVersion
.
Latest
)).
EmitToImageReference
()
Dim
source
=
<
compilation
>
<
file
>
Class
Test
Shared
Sub
Main
()
Dim
p
=
0
Dim
obj
=
New
TestRef
()
Dim
value
=
obj
(
p
)
End
Sub
End
Class
</
file
>
</
compilation
>
Dim
compilation
=
CreateCompilationWithMscorlib
(
source
,
references
:
=
{
reference
})
AssertTheseDiagnostics
(
compilation
,
<
expected
>
BC30643
:
Property
'TestRef.Item(p As )' is of an unsupported type.
Dim
value
=
obj
(
p
)
~~~
</
expected
>
)
End
Sub
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录