Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
3f0d9eba
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,发现更多精彩内容 >>
提交
3f0d9eba
编写于
6月 03, 2015
作者:
A
AlekseyTs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include ContentType into assembly qualified type name emitted for an attribute argument.
Addresses DevDiv 1169511.
上级
b790432f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
79 addition
and
1 deletion
+79
-1
src/Compilers/CSharp/Test/WinRT/Metadata/WinMdMetadataTests.cs
...ompilers/CSharp/Test/WinRT/Metadata/WinMdMetadataTests.cs
+37
-0
src/Compilers/Core/Portable/MetadataReader/PEModule.cs
src/Compilers/Core/Portable/MetadataReader/PEModule.cs
+1
-1
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
+9
-0
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/WinMdTypeTests.vb
...Basic/Test/Symbol/SymbolsTests/Metadata/WinMdTypeTests.vb
+32
-0
未找到文件。
src/Compilers/CSharp/Test/WinRT/Metadata/WinMdMetadataTests.cs
浏览文件 @
3f0d9eba
...
...
@@ -206,5 +206,42 @@ public static void Main(string[] args)
expectedOutput
:
"10\r\n0"
);
verifier
.
VerifyDiagnostics
();
}
[
Fact
,
WorkItem
(
1169511
,
"DevDiv"
)]
public
void
WinMdAssemblyQualifiedType
()
{
var
source
=
@"using System;
[MyAttribute(typeof(C1))]
public class C
{
public static void Main(string[] args)
{
}
}
public class MyAttribute : System.Attribute
{
public MyAttribute(System.Type type)
{
}
}
"
;
CompileAndVerify
(
source
,
WinRtRefs
.
Concat
(
new
[]
{
AssemblyMetadata
.
CreateFromImage
(
TestResources
.
WinRt
.
W1
).
GetReference
()
}),
symbolValidator
:
m
=>
{
var
module
=
(
PEModuleSymbol
)
m
;
var
c
=
(
PENamedTypeSymbol
)
module
.
GlobalNamespace
.
GetTypeMember
(
"C"
);
var
attributeHandle
=
module
.
Module
.
MetadataReader
.
GetCustomAttributes
(
c
.
Handle
).
Single
();
string
value
;
module
.
Module
.
TryExtractStringValueFromAttribute
(
attributeHandle
,
out
value
);
Assert
.
Equal
(
"C1, W, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime"
,
value
);
},
emitters
:
TestEmitters
.
RefEmitBug
);
}
}
}
src/Compilers/Core/Portable/MetadataReader/PEModule.cs
浏览文件 @
3f0d9eba
...
...
@@ -1238,7 +1238,7 @@ private bool TryExtractTypeLibTypeFromAttribute(AttributeInfo info, out Cci.Type
return
false
;
}
private
bool
TryExtractStringValueFromAttribute
(
CustomAttributeHandle
handle
,
out
string
value
)
internal
bool
TryExtractStringValueFromAttribute
(
CustomAttributeHandle
handle
,
out
string
value
)
{
return
TryExtractValueFromAttribute
(
handle
,
out
value
,
s_attributeStringValueExtractor
);
}
...
...
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
浏览文件 @
3f0d9eba
...
...
@@ -4759,6 +4759,15 @@ internal static string StrongName(IAssemblyReference assemblyReference)
sb
.
Append
(
", Retargetable=Yes"
);
}
if
(
assemblyReference
.
ContentType
==
AssemblyContentType
.
WindowsRuntime
)
{
sb
.
Append
(
", ContentType=WindowsRuntime"
);
}
else
{
Debug
.
Assert
(
assemblyReference
.
ContentType
==
AssemblyContentType
.
Default
);
}
return
pooled
.
ToStringAndFree
();
}
...
...
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/WinMdTypeTests.vb
浏览文件 @
3f0d9eba
...
...
@@ -43,5 +43,37 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Symbols.Metadata
Dim
value
=
type
.
GetMember
(
Of
FieldSymbol
)(
"value__"
)
Assert
.
Equal
(
value
.
DeclaredAccessibility
,
Accessibility
.
Public
)
End
Sub
<
Fact
,
WorkItem
(
1169511
,
"DevDiv"
)
>
Public
Sub
WinMdAssemblyQualifiedType
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
><
!
[
CDATA
[
<
MyAttribute
(
GetType
(
C1
))
>
Public
Class
C
Public
Shared
Sub
Main
()
End
Sub
End
Class
Public
Class
MyAttribute
Inherits
System
.
Attribute
Sub
New
(
type
As
System
.
Type
)
End
Sub
End
Class
]]
></
file
>
</
compilation
>
Dim
comp
=
CreateWinRtCompilation
(
source
).
AddReferences
(
AssemblyMetadata
.
CreateFromImage
(
TestResources
.
WinRt
.
W1
).
GetReference
())
CompileAndVerify
(
comp
,
symbolValidator
:
=
Sub
(
m
)
Dim
[
module
]
=
DirectCast
(
m
,
PEModuleSymbol
)
Dim
c
=
DirectCast
(
[
module
]
.
GlobalNamespace
.
GetTypeMember
(
"C"
),
PENamedTypeSymbol
)
Dim
attributeHandle
=
[
module
]
.
Module
.
MetadataReader
.
GetCustomAttributes
(
c
.
Handle
).
Single
()
Dim
value
As
String
=
Nothing
[
module
]
.
Module
.
TryExtractStringValueFromAttribute
(
attributeHandle
,
value
)
Assert
.
Equal
(
"C1, W, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime"
,
value
)
End
Sub
)
End
Sub
End
Class
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录