Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1f80e1cf
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,发现更多精彩内容 >>
提交
1f80e1cf
编写于
12月 15, 2016
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
InvalidOperationException emitting reference to void* parameter with custom modifiers
上级
cf920d44
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
95 addition
and
27 deletion
+95
-27
src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
...ompilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
+7
-7
src/Compilers/CSharp/Test/Emit/Emit/EmitCustomModifiers.cs
src/Compilers/CSharp/Test/Emit/Emit/EmitCustomModifiers.cs
+69
-0
src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs
src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs
+1
-1
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
+9
-10
src/Compilers/VisualBasic/Portable/Emit/PEModuleBuilder.vb
src/Compilers/VisualBasic/Portable/Emit/PEModuleBuilder.vb
+9
-9
未找到文件。
src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
浏览文件 @
1f80e1cf
...
...
@@ -109,12 +109,12 @@ internal sealed override AssemblySymbol CorLibrary
public
sealed
override
IEnumerable
<
string
>
LinkedAssembliesDebugInfo
=>
SpecializedCollections
.
EmptyEnumerable
<
string
>();
// C# currently doesn't emit compilation level imports (TODO: scripting).
public
override
ImmutableArray
<
Cci
.
UsedNamespaceOrType
>
GetImports
()
=>
ImmutableArray
<
Cci
.
UsedNamespaceOrType
>.
Empty
;
public
sealed
override
ImmutableArray
<
Cci
.
UsedNamespaceOrType
>
GetImports
()
=>
ImmutableArray
<
Cci
.
UsedNamespaceOrType
>.
Empty
;
// C# doesn't allow to define default namespace for compilation.
public
override
string
DefaultNamespace
=>
null
;
public
sealed
override
string
DefaultNamespace
=>
null
;
protected
override
IEnumerable
<
Cci
.
IAssemblyReference
>
GetAssemblyReferencesFromAddedModules
(
DiagnosticBag
diagnostics
)
protected
sealed
override
IEnumerable
<
Cci
.
IAssemblyReference
>
GetAssemblyReferencesFromAddedModules
(
DiagnosticBag
diagnostics
)
{
ImmutableArray
<
ModuleSymbol
>
modules
=
SourceModule
.
ContainingAssembly
.
Modules
;
...
...
@@ -178,7 +178,7 @@ internal sealed override IEnumerable<Cci.INestedTypeDefinition> GetSynthesizedNe
return
null
;
}
public
override
MultiDictionary
<
Cci
.
DebugSourceDocument
,
Cci
.
DefinitionWithLocation
>
GetSymbolToLocationMap
()
public
sealed
override
MultiDictionary
<
Cci
.
DebugSourceDocument
,
Cci
.
DefinitionWithLocation
>
GetSymbolToLocationMap
()
{
var
result
=
new
MultiDictionary
<
Cci
.
DebugSourceDocument
,
Cci
.
DefinitionWithLocation
>();
...
...
@@ -355,7 +355,7 @@ internal virtual bool TryGetAnonymousTypeName(NamedTypeSymbol template, out stri
return
false
;
}
internal
override
ImmutableArray
<
Cci
.
INamespaceTypeDefinition
>
GetAnonymousTypes
()
internal
sealed
override
ImmutableArray
<
Cci
.
INamespaceTypeDefinition
>
GetAnonymousTypes
()
{
if
(
EmitOptions
.
EmitMetadataOnly
)
{
...
...
@@ -436,7 +436,7 @@ private static void GetExportedTypes(NamespaceOrTypeSymbol symbol, int parentInd
}
}
public
override
ImmutableArray
<
Cci
.
ExportedType
>
GetExportedTypes
(
DiagnosticBag
diagnostics
)
public
sealed
override
ImmutableArray
<
Cci
.
ExportedType
>
GetExportedTypes
(
DiagnosticBag
diagnostics
)
{
Debug
.
Assert
(
HaveDeterminedTopLevelTypes
);
...
...
@@ -1073,7 +1073,7 @@ public static Cci.TypeMemberVisibility MemberVisibility(Symbol symbol)
}
}
internal
override
Cci
.
IMethodReference
Translate
(
MethodSymbol
symbol
,
DiagnosticBag
diagnostics
,
bool
needDeclaration
)
internal
sealed
override
Cci
.
IMethodReference
Translate
(
MethodSymbol
symbol
,
DiagnosticBag
diagnostics
,
bool
needDeclaration
)
{
return
Translate
(
symbol
,
null
,
diagnostics
,
null
,
needDeclaration
);
}
...
...
src/Compilers/CSharp/Test/Emit/Emit/EmitCustomModifiers.cs
浏览文件 @
1f80e1cf
...
...
@@ -668,5 +668,74 @@ static void Main()
CompileAndVerify
(
comp
,
expectedOutput
:
"2"
);
}
[
WorkItem
(
294553
,
"https://devdiv.visualstudio.com/DevDiv/_workitems?id=294553"
)]
[
Fact
]
public
void
VoidPointerWithCustomModifiers
()
{
var
ilSource
=
@".class public A
{
// F1(void* p)
.method public static void F1(void* p) { ret }
// F2(const void* p)
.method public static void F2(void modopt([mscorlib]System.Runtime.CompilerServices.IsConst)* p) { ret }
// F3(void* const p)
.method public static void F3(void* modopt([mscorlib]System.Runtime.CompilerServices.IsConst) p) { ret }
// F4(const void* const p)
.method public static void F4(void modopt([mscorlib]System.Runtime.CompilerServices.IsConst)* modopt([mscorlib]System.Runtime.CompilerServices.IsConst) p) { ret }
}"
;
var
source
=
@"class B
{
static void Main()
{
unsafe
{
A.F1(null);
A.F2(null);
A.F3(null);
A.F4(null);
}
}
}"
;
var
compilation
=
CreateCompilationWithCustomILSource
(
source
,
ilSource
,
options
:
TestOptions
.
UnsafeReleaseExe
);
compilation
.
VerifyDiagnostics
();
CompileAndVerify
(
compilation
);
}
[
Fact
]
public
void
IntPointerWithCustomModifiers
()
{
var
ilSource
=
@".class public A
{
// F1(int* p)
.method public static void F1(int32* p) { ret }
// F2(const int* p)
.method public static void F2(int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst)* p) { ret }
// F3(int* const p)
.method public static void F3(int32* modopt([mscorlib]System.Runtime.CompilerServices.IsConst) p) { ret }
// F4(const int* const p)
.method public static void F4(int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst)* modopt([mscorlib]System.Runtime.CompilerServices.IsConst) p) { ret }
}"
;
var
source
=
@"class B
{
static void Main()
{
unsafe
{
A.F1(null);
A.F2(null);
A.F3(null);
A.F4(null);
}
}
}"
;
var
compilation
=
CreateCompilationWithCustomILSource
(
source
,
ilSource
,
options
:
TestOptions
.
UnsafeReleaseExe
);
compilation
.
VerifyDiagnostics
();
CompileAndVerify
(
compilation
);
}
}
}
src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs
浏览文件 @
1f80e1cf
...
...
@@ -882,7 +882,7 @@ internal override bool SupportsPrivateImplClass
#
endregion
public
override
Cci
.
ITypeReference
GetPlatformType
(
Cci
.
PlatformType
platformType
,
EmitContext
context
)
public
sealed
override
Cci
.
ITypeReference
GetPlatformType
(
Cci
.
PlatformType
platformType
,
EmitContext
context
)
{
Debug
.
Assert
((
object
)
this
==
context
.
Module
);
...
...
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
浏览文件 @
1f80e1cf
...
...
@@ -3655,16 +3655,8 @@ private void SerializeTypeReference(SignatureTypeEncoder encoder, ITypeReference
if
(
pointerTypeReference
!=
null
)
{
typeReference
=
pointerTypeReference
.
GetTargetType
(
Context
);
if
(
module
.
IsPlatformType
(
typeReference
,
PlatformType
.
SystemVoid
))
{
encoder
.
VoidPointer
();
return
;
}
else
{
encoder
=
encoder
.
Pointer
();
continue
;
}
encoder
=
encoder
.
Pointer
();
continue
;
}
IGenericTypeParameterReference
genericTypeParameterReference
=
typeReference
.
AsGenericTypeParameterReference
;
...
...
@@ -3803,6 +3795,13 @@ private static void SerializePrimitiveType(SignatureTypeEncoder encoder, Primiti
encoder
.
String
();
break
;
case
PrimitiveTypeCode
.
Void
:
// "void" is handled specifically for "void*" with custom modifiers.
// If SignatureTypeEncoder supports such cases directly, this can
// be removed. See https://github.com/dotnet/corefx/issues/14571.
encoder
.
Builder
.
WriteByte
((
byte
)
System
.
Reflection
.
Metadata
.
PrimitiveTypeCode
.
Void
);
break
;
default
:
throw
ExceptionUtilities
.
UnexpectedValue
(
primitiveType
);
}
...
...
src/Compilers/VisualBasic/Portable/Emit/PEModuleBuilder.vb
浏览文件 @
1f80e1cf
...
...
@@ -78,7 +78,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
End
Get
End
Property
Public
Overrides
ReadOnly
Property
GenerateVisualBasicStylePdb
As
Boolean
Public
NotOverridable
Overrides
ReadOnly
Property
GenerateVisualBasicStylePdb
As
Boolean
Get
Return
True
End
Get
...
...
@@ -122,7 +122,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
End
Get
End
Property
Protected
Overrides
Iterator
Function
GetAssemblyReferencesFromAddedModules
(
diagnostics
As
DiagnosticBag
)
As
IEnumerable
(
Of
Cci
.
IAssemblyReference
)
Protected
NotOverridable
Overrides
Iterator
Function
GetAssemblyReferencesFromAddedModules
(
diagnostics
As
DiagnosticBag
)
As
IEnumerable
(
Of
Cci
.
IAssemblyReference
)
Dim
modules
As
ImmutableArray
(
Of
ModuleSymbol
)
=
SourceModule
.
ContainingAssembly
.
Modules
For
i
As
Integer
=
1
To
modules
.
Length
-
1
...
...
@@ -188,7 +188,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Return
SourceModule
.
GetCustomAttributesToEmit
(
Me
.
CompilationState
)
End
Function
Public
Overrides
Function
GetSymbolToLocationMap
()
As
MultiDictionary
(
Of
Cci
.
DebugSourceDocument
,
Cci
.
DefinitionWithLocation
)
Public
NotOverridable
Overrides
Function
GetSymbolToLocationMap
()
As
MultiDictionary
(
Of
Cci
.
DebugSourceDocument
,
Cci
.
DefinitionWithLocation
)
Dim
result
As
New
MultiDictionary
(
Of
Cci
.
DebugSourceDocument
,
Cci
.
DefinitionWithLocation
)()
Dim
namespacesAndTypesToProcess
As
New
Stack
(
Of
NamespaceOrTypeSymbol
)()
...
...
@@ -330,7 +330,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Return
False
End
Function
Friend
Overrides
Function
GetAnonymousTypes
()
As
ImmutableArray
(
Of
Cci
.
INamespaceTypeDefinition
)
Friend
NotOverridable
Overrides
Function
GetAnonymousTypes
()
As
ImmutableArray
(
Of
Cci
.
INamespaceTypeDefinition
)
If
EmitOptions
.
EmitMetadataOnly
Then
Return
ImmutableArray
(
Of
Cci
.
INamespaceTypeDefinition
).
Empty
End
If
...
...
@@ -379,7 +379,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Return
ImmutableArray
(
Of
NamedTypeSymbol
).
Empty
End
Function
Public
Overrides
Function
GetExportedTypes
(
diagnostics
As
DiagnosticBag
)
As
ImmutableArray
(
Of
Cci
.
ExportedType
)
Public
NotOverridable
Overrides
Function
GetExportedTypes
(
diagnostics
As
DiagnosticBag
)
As
ImmutableArray
(
Of
Cci
.
ExportedType
)
Debug
.
Assert
(
HaveDeterminedTopLevelTypes
)
If
_lazyExportedTypes
.
IsDefault
Then
...
...
@@ -598,11 +598,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Return
typeSymbol
End
Function
Public
Overrides
Function
GetInitArrayHelper
()
As
Cci
.
IMethodReference
Public
NotOverridable
Overrides
Function
GetInitArrayHelper
()
As
Cci
.
IMethodReference
Return
DirectCast
(
Compilation
.
GetWellKnownTypeMember
(
WellKnownMember
.
System_Runtime_CompilerServices_RuntimeHelpers__InitializeArrayArrayRuntimeFieldHandle
),
MethodSymbol
)
End
Function
Public
Overrides
Function
IsPlatformType
(
typeRef
As
Cci
.
ITypeReference
,
platformType
As
Cci
.
PlatformType
)
As
Boolean
Public
NotOverridable
Overrides
Function
IsPlatformType
(
typeRef
As
Cci
.
ITypeReference
,
platformType
As
Cci
.
PlatformType
)
As
Boolean
Dim
namedType
=
TryCast
(
typeRef
,
NamedTypeSymbol
)
If
namedType
IsNot
Nothing
Then
...
...
@@ -616,7 +616,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Return
False
End
Function
Protected
Overrides
Function
GetCorLibraryReferenceToEmit
(
context
As
EmitContext
)
As
Cci
.
IAssemblyReference
Protected
NotOverridable
Overrides
Function
GetCorLibraryReferenceToEmit
(
context
As
EmitContext
)
As
Cci
.
IAssemblyReference
Dim
corLib
=
CorLibrary
If
Not
corLib
.
IsMissing
AndAlso
...
...
@@ -643,7 +643,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Return
_disableJITOptimization
.
ContainsKey
(
methodSymbol
)
End
Function
Protected
Overrides
Function
CreatePrivateImplementationDetailsStaticConstructor
(
details
As
PrivateImplementationDetails
,
syntaxOpt
As
SyntaxNode
,
diagnostics
As
DiagnosticBag
)
As
Cci
.
IMethodDefinition
Protected
NotOverridable
Overrides
Function
CreatePrivateImplementationDetailsStaticConstructor
(
details
As
PrivateImplementationDetails
,
syntaxOpt
As
SyntaxNode
,
diagnostics
As
DiagnosticBag
)
As
Cci
.
IMethodDefinition
Return
New
SynthesizedPrivateImplementationDetailsSharedConstructor
(
SourceModule
,
details
,
GetUntranslatedSpecialType
(
SpecialType
.
System_Void
,
syntaxOpt
,
diagnostics
))
End
Function
End
Class
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录