Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9582b3a2
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,发现更多精彩内容 >>
未验证
提交
9582b3a2
编写于
11月 17, 2017
作者:
C
Charles Stoner
提交者:
GitHub
11月 17, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23199 from cston/embedded
Merge misc. changes for embedded attributes from
7a0467ec
上级
3eebaf57
3714f5c4
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
94 addition
and
132 deletion
+94
-132
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+4
-4
src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
...pilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
+5
-12
src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
...ompilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
+5
-8
src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs
...ilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs
+6
-0
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
...s/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
+3
-19
src/Compilers/CSharp/Portable/Symbols/Compilation_WellKnownMembers.cs
...s/CSharp/Portable/Symbols/Compilation_WellKnownMembers.cs
+5
-6
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs
...ers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs
+10
-0
src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
+13
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs
...rp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs
+0
-12
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
...Sharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
+0
-17
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
...s/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
+0
-13
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbolBase.cs
...harp/Portable/Symbols/Source/SourceParameterSymbolBase.cs
+5
-0
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedImplementationMethod.cs
...le/Symbols/Synthesized/SynthesizedImplementationMethod.cs
+0
-19
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs
...Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs
+11
-2
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs
...Sharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs
+0
-18
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs
.../CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs
+5
-0
src/Test/Utilities/Portable/Metadata/MetadataReaderUtils.cs
src/Test/Utilities/Portable/Metadata/MetadataReaderUtils.cs
+22
-2
未找到文件。
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
9582b3a2
...
...
@@ -1998,10 +1998,10 @@ private IEnumerable<Diagnostic> FreezeDeclarationDiagnostics()
{
_declarationDiagnosticsFrozen
=
true
;
// Also freeze generated attribute flags
by observing them
//
symbols bound after getting the declaration diagnostics shouldn't need to modify the flags
_needsGeneratedIsReadOnlyAttribute_IsFrozen
=
true
;
_needsGenerated
IsByRefLikeAttribute
_IsFrozen
=
true
;
// Also freeze generated attribute flags
.
//
Symbols bound after getting the declaration
// diagnostics shouldn't need to modify the flags.
_needsGenerated
Attributes
_IsFrozen
=
true
;
var
result
=
_lazyDeclarationDiagnostics
?.
AsEnumerable
()
??
Enumerable
.
Empty
<
Diagnostic
>();
return
result
;
...
...
src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
浏览文件 @
9582b3a2
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Reflection
;
using
System.Threading
;
using
Microsoft.Cci
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.Emit
;
using
Microsoft.CodeAnalysis.PooledObjects
;
...
...
@@ -165,15 +162,11 @@ protected override void AddEmbeddedResourcesFromAddedModules(ArrayBuilder<Cci.Ma
internal
override
SynthesizedAttributeData
SynthesizeEmbeddedAttribute
()
{
if
((
object
)
_lazyEmbeddedAttribute
!=
null
)
{
return
new
SynthesizedAttributeData
(
_lazyEmbeddedAttribute
.
Constructor
,
ImmutableArray
<
TypedConstant
>.
Empty
,
ImmutableArray
<
KeyValuePair
<
string
,
TypedConstant
>>.
Empty
);
}
return
base
.
SynthesizeEmbeddedAttribute
();
// _lazyEmbeddedAttribute should have been created before calling this method.
return
new
SynthesizedAttributeData
(
_lazyEmbeddedAttribute
.
Constructor
,
ImmutableArray
<
TypedConstant
>.
Empty
,
ImmutableArray
<
KeyValuePair
<
string
,
TypedConstant
>>.
Empty
);
}
protected
override
SynthesizedAttributeData
TrySynthesizeIsReadOnlyAttribute
()
...
...
src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
浏览文件 @
9582b3a2
...
...
@@ -43,7 +43,7 @@ public override NoPia.EmbeddedTypesManager EmbeddedTypesManagerOpt
private
bool
_needsGeneratedIsReadOnlyAttribute_Value
;
private
bool
_needsGenerated
IsReadOnlyAttribute
_IsFrozen
;
private
bool
_needsGenerated
Attributes
_IsFrozen
;
/// <summary>
/// Returns a value indicating whether this builder has a symbol that needs IsReadOnlyAttribute to be generated during emit phase.
...
...
@@ -54,7 +54,7 @@ internal bool NeedsGeneratedIsReadOnlyAttribute
{
get
{
_needsGenerated
IsReadOnlyAttribute
_IsFrozen
=
true
;
_needsGenerated
Attributes
_IsFrozen
=
true
;
return
Compilation
.
NeedsGeneratedIsReadOnlyAttribute
||
_needsGeneratedIsReadOnlyAttribute_Value
;
}
}
...
...
@@ -1427,11 +1427,7 @@ protected override Cci.IMethodDefinition CreatePrivateImplementationDetailsStati
return
new
SynthesizedPrivateImplementationDetailsStaticConstructor
(
SourceModule
,
details
,
GetUntranslatedSpecialType
(
SpecialType
.
System_Void
,
syntaxOpt
,
diagnostics
));
}
internal
virtual
SynthesizedAttributeData
SynthesizeEmbeddedAttribute
()
{
// Embedded attributes should never be synthesized in modules.
throw
ExceptionUtilities
.
Unreachable
;
}
internal
abstract
SynthesizedAttributeData
SynthesizeEmbeddedAttribute
();
internal
SynthesizedAttributeData
SynthesizeIsReadOnlyAttribute
(
Symbol
symbol
)
{
...
...
@@ -1469,6 +1465,8 @@ protected virtual SynthesizedAttributeData TrySynthesizeIsByRefLikeAttribute()
internal
void
EnsureIsReadOnlyAttributeExists
()
{
Debug
.
Assert
(!
_needsGeneratedAttributes_IsFrozen
);
if
(
_needsGeneratedIsReadOnlyAttribute_Value
||
Compilation
.
NeedsGeneratedIsReadOnlyAttribute
)
{
return
;
...
...
@@ -1477,7 +1475,6 @@ internal void EnsureIsReadOnlyAttributeExists()
// Don't report any errors. They should be reported during binding.
if
(
Compilation
.
CheckIfIsReadOnlyAttributeShouldBeEmbedded
(
diagnosticsOpt
:
null
,
locationOpt
:
null
))
{
Debug
.
Assert
(!
_needsGeneratedIsReadOnlyAttribute_IsFrozen
);
_needsGeneratedIsReadOnlyAttribute_Value
=
true
;
}
}
...
...
src/Compilers/CSharp/Portable/Emitter/Model/PENetModuleBuilder.cs
浏览文件 @
9582b3a2
...
...
@@ -25,6 +25,12 @@ protected override void AddEmbeddedResourcesFromAddedModules(ArrayBuilder<Cci.Ma
throw
ExceptionUtilities
.
Unreachable
;
}
internal
override
SynthesizedAttributeData
SynthesizeEmbeddedAttribute
()
{
// Embedded attributes should never be synthesized in modules.
throw
ExceptionUtilities
.
Unreachable
;
}
public
override
int
CurrentGenerationOrdinal
=>
0
;
public
override
IEnumerable
<
Cci
.
IFileReference
>
GetFiles
(
EmitContext
context
)
=>
SpecializedCollections
.
EmptyEnumerable
<
Cci
.
IFileReference
>();
public
override
ISourceAssemblySymbolInternal
SourceAssemblyOpt
=>
null
;
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
浏览文件 @
9582b3a2
...
...
@@ -3,6 +3,7 @@
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Linq
;
using
Microsoft.CodeAnalysis.CodeGen
;
using
Microsoft.CodeAnalysis.CSharp.Emit
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
...
...
@@ -587,25 +588,8 @@ internal static bool WouldBeAssignableIfUsedAsMethodReceiver(BoundExpression rec
private
void
CheckRefReadOnlySymbols
(
MethodSymbol
symbol
)
{
var
foundRefReadOnly
=
false
;
if
(
symbol
.
ReturnsByRefReadonly
)
{
foundRefReadOnly
=
true
;
}
else
{
foreach
(
var
parameter
in
symbol
.
Parameters
)
{
if
(
parameter
.
RefKind
==
RefKind
.
In
)
{
foundRefReadOnly
=
true
;
break
;
}
}
}
if
(
foundRefReadOnly
)
if
(
symbol
.
ReturnsByRefReadonly
||
symbol
.
Parameters
.
Any
(
p
=>
p
.
RefKind
==
RefKind
.
In
))
{
_factory
.
CompilationState
.
ModuleBuilderOpt
?.
EnsureIsReadOnlyAttributeExists
();
}
...
...
src/Compilers/CSharp/Portable/Symbols/Compilation_WellKnownMembers.cs
浏览文件 @
9582b3a2
...
...
@@ -35,8 +35,7 @@ public partial class CSharpCompilation
private
bool
_needsGeneratedIsReadOnlyAttribute_Value
;
private
bool
_needsGeneratedIsByRefLikeAttribute_Value
;
private
bool
_needsGeneratedIsReadOnlyAttribute_IsFrozen
;
private
bool
_needsGeneratedIsByRefLikeAttribute_IsFrozen
;
private
bool
_needsGeneratedAttributes_IsFrozen
;
/// <summary>
/// Returns a value indicating whether this compilation has a member that needs IsReadOnlyAttribute to be generated during emit phase.
...
...
@@ -47,7 +46,7 @@ internal bool NeedsGeneratedIsReadOnlyAttribute
{
get
{
_needsGenerated
IsReadOnlyAttribute
_IsFrozen
=
true
;
_needsGenerated
Attributes
_IsFrozen
=
true
;
return
_needsGeneratedIsReadOnlyAttribute_Value
;
}
}
...
...
@@ -61,7 +60,7 @@ internal bool NeedsGeneratedIsByRefLikeAttribute
{
get
{
_needsGenerated
IsByRefLikeAttribute
_IsFrozen
=
true
;
_needsGenerated
Attributes
_IsFrozen
=
true
;
return
_needsGeneratedIsByRefLikeAttribute_Value
;
}
}
...
...
@@ -463,7 +462,7 @@ internal SynthesizedAttributeData SynthesizeDebuggerStepThroughAttribute()
internal
void
EnsureIsReadOnlyAttributeExists
(
DiagnosticBag
diagnostics
,
Location
location
,
bool
modifyCompilationForRefReadOnly
)
{
Debug
.
Assert
(!
modifyCompilationForRefReadOnly
||
!
_needsGenerated
IsReadOnlyAttribute
_IsFrozen
);
Debug
.
Assert
(!
modifyCompilationForRefReadOnly
||
!
_needsGenerated
Attributes
_IsFrozen
);
var
isNeeded
=
CheckIfIsReadOnlyAttributeShouldBeEmbedded
(
diagnostics
,
location
);
...
...
@@ -475,7 +474,7 @@ internal void EnsureIsReadOnlyAttributeExists(DiagnosticBag diagnostics, Locatio
internal
void
EnsureIsByRefLikeAttributeExists
(
DiagnosticBag
diagnostics
,
Location
location
,
bool
modifyCompilationForIsByRefLike
)
{
Debug
.
Assert
(!
modifyCompilationForIsByRefLike
||
!
_needsGenerated
IsByRefLikeAttribute
_IsFrozen
);
Debug
.
Assert
(!
modifyCompilationForIsByRefLike
||
!
_needsGenerated
Attributes
_IsFrozen
);
var
isNeeded
=
CheckIfIsByRefLikeAttributeShouldBeEmbedded
(
diagnostics
,
location
);
...
...
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs
浏览文件 @
9582b3a2
...
...
@@ -1121,6 +1121,16 @@ internal override OverriddenOrHiddenMembersResult OverriddenOrHiddenMembers
}
}
internal
override
void
AddSynthesizedAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
throw
ExceptionUtilities
.
Unreachable
;
}
internal
override
void
AddSynthesizedReturnTypeAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
throw
ExceptionUtilities
.
Unreachable
;
}
// perf, not correctness
internal
override
CSharpCompilation
DeclaringCompilation
=>
null
;
...
...
src/Compilers/CSharp/Portable/Symbols/MethodSymbol.cs
浏览文件 @
9582b3a2
...
...
@@ -1159,6 +1159,19 @@ internal virtual void AddSynthesizedReturnTypeAttributes(PEModuleBuilder moduleB
{
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeIsReadOnlyAttribute
(
this
));
}
var
compilation
=
this
.
DeclaringCompilation
;
var
type
=
this
.
ReturnType
;
if
(
type
.
ContainsDynamic
()
&&
compilation
.
HasDynamicEmitAttributes
())
{
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeDynamicAttribute
(
type
,
this
.
ReturnTypeCustomModifiers
.
Length
+
this
.
RefCustomModifiers
.
Length
,
this
.
RefKind
));
}
if
(
type
.
ContainsTupleNames
()
&&
compilation
.
HasTupleNamesAttributes
)
{
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeTupleNamesAttribute
(
type
));
}
}
IMethodSymbol
IMethodSymbol
.
Construct
(
params
ITypeSymbol
[]
arguments
)
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs
浏览文件 @
9582b3a2
...
...
@@ -3,8 +3,6 @@
using
System
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
Microsoft.CodeAnalysis.CSharp.Emit
;
using
Microsoft.CodeAnalysis.PooledObjects
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
{
...
...
@@ -158,16 +156,6 @@ internal override bool IsCallerMemberName
get
{
return
_originalParam
.
IsCallerMemberName
;
}
}
internal
override
void
AddSynthesizedAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
base
.
AddSynthesizedAttributes
(
moduleBuilder
,
ref
attributes
);
if
(
this
.
RefKind
==
RefKind
.
RefReadOnly
)
{
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeIsReadOnlyAttribute
(
this
));
}
}
#
endregion
}
}
src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs
浏览文件 @
9582b3a2
...
...
@@ -964,23 +964,6 @@ public sealed override ImmutableArray<CSharpAttributeData> GetReturnTypeAttribut
return
this
.
GetReturnTypeAttributesBag
().
Attributes
;
}
internal
override
void
AddSynthesizedReturnTypeAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
base
.
AddSynthesizedReturnTypeAttributes
(
moduleBuilder
,
ref
attributes
);
if
(
this
.
ReturnType
.
ContainsDynamic
())
{
var
compilation
=
this
.
DeclaringCompilation
;
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeDynamicAttribute
(
this
.
ReturnType
,
this
.
ReturnTypeCustomModifiers
.
Length
+
this
.
RefCustomModifiers
.
Length
,
this
.
RefKind
));
}
if
(
ReturnType
.
ContainsTupleNames
())
{
AddSynthesizedAttribute
(
ref
attributes
,
DeclaringCompilation
.
SynthesizeTupleNamesAttribute
(
ReturnType
));
}
}
internal
override
CSharpAttributeData
EarlyDecodeWellKnownAttribute
(
ref
EarlyDecodeWellKnownAttributeArguments
<
EarlyWellKnownAttributeBinder
,
NamedTypeSymbol
,
AttributeSyntax
,
AttributeLocation
>
arguments
)
{
Debug
.
Assert
(
arguments
.
SymbolPart
==
AttributeLocation
.
None
||
arguments
.
SymbolPart
==
AttributeLocation
.
Return
);
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
浏览文件 @
9582b3a2
...
...
@@ -3,10 +3,7 @@
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp.Emit
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.Emit
;
using
Microsoft.CodeAnalysis.PooledObjects
;
namespace
Microsoft.CodeAnalysis.CSharp.Symbols
{
...
...
@@ -253,16 +250,6 @@ public override bool IsImplicitlyDeclared
}
}
internal
override
void
AddSynthesizedAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
base
.
AddSynthesizedAttributes
(
moduleBuilder
,
ref
attributes
);
if
(
this
.
RefKind
==
RefKind
.
In
)
{
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeIsReadOnlyAttribute
(
this
));
}
}
internal
override
bool
IsMetadataIn
=>
RefKind
==
RefKind
.
In
;
internal
override
bool
IsMetadataOut
=>
RefKind
==
RefKind
.
Out
;
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbolBase.cs
浏览文件 @
9582b3a2
...
...
@@ -88,6 +88,11 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeTupleNamesAttribute
(
Type
));
}
if
(
this
.
RefKind
==
RefKind
.
RefReadOnly
)
{
AddSynthesizedAttribute
(
ref
attributes
,
moduleBuilder
.
SynthesizeIsReadOnlyAttribute
(
this
));
}
}
internal
abstract
ParameterSymbol
WithCustomModifiersAndParams
(
TypeSymbol
newType
,
ImmutableArray
<
CustomModifier
>
newCustomModifiers
,
ImmutableArray
<
CustomModifier
>
newRefCustomModifiers
,
bool
newIsParams
);
...
...
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedImplementationMethod.cs
浏览文件 @
9582b3a2
...
...
@@ -81,25 +81,6 @@ public sealed override ImmutableArray<CustomModifier> RefCustomModifiers
#
endregion
internal
override
void
AddSynthesizedAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
base
.
AddSynthesizedAttributes
(
moduleBuilder
,
ref
attributes
);
var
compilation
=
this
.
DeclaringCompilation
;
if
(
this
.
ReturnType
.
ContainsDynamic
()
&&
compilation
.
HasDynamicEmitAttributes
()
&&
compilation
.
CanEmitBoolean
())
{
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeDynamicAttribute
(
this
.
ReturnType
,
this
.
ReturnTypeCustomModifiers
.
Length
+
this
.
RefCustomModifiers
.
Length
,
this
.
RefKind
));
}
if
(
ReturnType
.
ContainsTupleNames
()
&&
compilation
.
HasTupleNamesAttributes
&&
compilation
.
CanEmitSpecialType
(
SpecialType
.
System_String
))
{
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeTupleNamesAttribute
(
ReturnType
));
}
}
internal
sealed
override
bool
GenerateDebugInfo
{
get
{
return
_generateDebugInfo
;
}
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDynamicTests.cs
浏览文件 @
9582b3a2
...
...
@@ -683,8 +683,17 @@ public IEnumerable<dynamic> M1()
break;
case SymbolKind.Method:
// Dev11 marks return type of GetEnumerator with DynamicAttribute, we don't
Assert.Equal(0, ((MethodSymbol)member).GetReturnTypeAttributes().Length);
var attributes = ((MethodSymbol)member).GetReturnTypeAttributes();
switch (member.MetadataName)
{
case "System.Collections.Generic.IEnumerator<dynamic>.get_Current":
case "System.Collections.Generic.IEnumerable<dynamic>.GetEnumerator":
Assert.Equal(1, attributes.Length);
break;
default:
Assert.Equal(0, attributes.Length);
break;
}
break;
case SymbolKind.Property:
...
...
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/EEMethodSymbol.cs
浏览文件 @
9582b3a2
...
...
@@ -697,24 +697,6 @@ private static TypeSymbol CalculateReturnType(CSharpCompilation compilation, Bou
}
}
internal
override
void
AddSynthesizedReturnTypeAttributes
(
PEModuleBuilder
moduleBuilder
,
ref
ArrayBuilder
<
SynthesizedAttributeData
>
attributes
)
{
base
.
AddSynthesizedReturnTypeAttributes
(
moduleBuilder
,
ref
attributes
);
var
compilation
=
this
.
DeclaringCompilation
;
var
returnType
=
this
.
ReturnType
;
if
(
returnType
.
ContainsDynamic
()
&&
compilation
.
HasDynamicEmitAttributes
())
{
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeDynamicAttribute
(
returnType
,
ReturnTypeCustomModifiers
.
Length
+
RefCustomModifiers
.
Length
,
RefKind
));
}
if
(
returnType
.
ContainsTupleNames
()
&&
compilation
.
HasTupleNamesAttributes
)
{
AddSynthesizedAttribute
(
ref
attributes
,
compilation
.
SynthesizeTupleNamesAttribute
(
returnType
));
}
}
internal
override
int
CalculateLocalSyntaxOffset
(
int
localPosition
,
SyntaxTree
localTree
)
{
return
localPosition
;
...
...
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ReferencedModulesTests.cs
浏览文件 @
9582b3a2
...
...
@@ -1010,6 +1010,11 @@ internal override IEnumerable<INamespaceTypeDefinition> GetTopLevelTypesCore(Emi
}
}
internal
override
SynthesizedAttributeData
SynthesizeEmbeddedAttribute
()
{
throw
new
NotImplementedException
();
}
public
override
int
CurrentGenerationOrdinal
=>
_builder
.
CurrentGenerationOrdinal
;
public
override
ISourceAssemblySymbolInternal
SourceAssemblyOpt
=>
_builder
.
SourceAssemblyOpt
;
...
...
src/Test/Utilities/Portable/Metadata/MetadataReaderUtils.cs
浏览文件 @
9582b3a2
...
...
@@ -156,8 +156,9 @@ public static StringHandle GetName(this MetadataReader reader, EntityHandle toke
switch
(
token
.
Kind
)
{
case
HandleKind
.
TypeReference
:
var
typeRef
=
reader
.
GetTypeReference
((
TypeReferenceHandle
)
token
);
return
typeRef
.
Name
;
return
reader
.
GetTypeReference
((
TypeReferenceHandle
)
token
).
Name
;
case
HandleKind
.
TypeDefinition
:
return
reader
.
GetTypeDefinition
((
TypeDefinitionHandle
)
token
).
Name
;
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
token
.
Kind
);
}
...
...
@@ -172,6 +173,25 @@ public static IEnumerable<CustomAttributeRow> GetCustomAttributeRows(this Metada
}
}
public
static
string
GetCustomAttributeName
(
this
MetadataReader
reader
,
CustomAttributeRow
row
)
{
EntityHandle
parent
;
var
token
=
row
.
ConstructorToken
;
switch
(
token
.
Kind
)
{
case
HandleKind
.
MemberReference
:
parent
=
reader
.
GetMemberReference
((
MemberReferenceHandle
)
token
).
Parent
;
break
;
case
HandleKind
.
MethodDefinition
:
parent
=
reader
.
GetMethodDefinition
((
MethodDefinitionHandle
)
token
).
GetDeclaringType
();
break
;
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
token
.
Kind
);
}
var
strHandle
=
reader
.
GetName
(
parent
);
return
reader
.
GetString
(
strHandle
);
}
public
static
bool
IsIncluded
(
this
ImmutableArray
<
byte
>
metadata
,
string
str
)
{
var
builder
=
ArrayBuilder
<
byte
>.
GetInstance
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录