Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9b7fe079
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,发现更多精彩内容 >>
提交
9b7fe079
编写于
9月 18, 2015
作者:
R
Ravi Chande
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4757 from rchande/MASperf2
Always use autoinsertionlocation=false from metadata as source
上级
dcaa8630
c6f32b18
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
14 deletion
+53
-14
src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs
...orFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs
+42
-12
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.cs
...table/MetadataAsSource/AbstractMetadataAsSourceService.cs
+1
-1
src/Workspaces/Core/Portable/CodeGeneration/AbstractCodeGenerationService.cs
.../Portable/CodeGeneration/AbstractCodeGenerationService.cs
+10
-1
未找到文件。
src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs
浏览文件 @
9b7fe079
...
...
@@ -246,6 +246,36 @@ End Class
[
WorkItem
(
546195
),
WorkItem
(
546269
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
MetadataAsSource
)]
public
void
TestEnum
()
{
var
metadataSource
=
"public enum E { A, B, C }"
;
var
symbolName
=
"E"
;
GenerateAndVerifySource
(
metadataSource
,
symbolName
,
LanguageNames
.
CSharp
,
$@"
#region
{
FeaturesResources
.
Assembly
}
ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
//
{
CodeAnalysisResources
.
InMemoryAssembly
}
#endregion
public enum [|E|]
{{
A
=
0
,
B
=
1
,
C
=
2
}}
"
);
GenerateAndVerifySource
(
metadataSource
,
symbolName
,
LanguageNames
.
VisualBasic
,
$@"
#Region ""
{
FeaturesResources
.
Assembly
}
ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null""
'
{
CodeAnalysisResources
.
InMemoryAssembly
}
#End Region
Public Enum [|E|]
A = 0
B = 1
C = 2
End Enum"
);
}
[
WorkItem
(
546195
),
WorkItem
(
546269
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
MetadataAsSource
)]
public
void
TestEnumFromField
()
{
var
metadataSource
=
"public enum E { A, B, C }"
;
var
symbolName
=
"E.C"
;
...
...
@@ -257,9 +287,9 @@ public void TestEnum()
public enum E
{{
A
,
B
,
[|
C
|]
A
=
0
,
B
=
1
,
[|
C
|]
=
2
}}
"
);
GenerateAndVerifySource
(
metadataSource
,
symbolName
,
LanguageNames
.
VisualBasic
,
$@"
#Region ""
{
FeaturesResources
.
Assembly
}
ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null""
...
...
@@ -267,9 +297,9 @@ public enum E
#End Region
Public Enum E
A
B
[|C|]
A
= 0
B
= 1
[|C|]
= 2
End Enum"
);
}
...
...
@@ -287,9 +317,9 @@ public void TestEnumWithUnderlyingType()
public enum E : short
{{
A
,
B
,
[|
C
|]
A
=
0
,
B
=
1
,
[|
C
|]
=
2
}}
"
);
GenerateAndVerifySource
(
metadataSource
,
symbolName
,
LanguageNames
.
VisualBasic
,
$@"
#Region ""
{
FeaturesResources
.
Assembly
}
ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null""
...
...
@@ -297,9 +327,9 @@ public enum E : short
#End Region
Public Enum E As Short
A
B
[|C|]
A
= 0
B
= 1
[|C|]
= 2
End Enum"
);
}
...
...
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.cs
浏览文件 @
9b7fe079
...
...
@@ -100,7 +100,7 @@ private static CodeGenerationOptions CreateCodeGenerationOptions(Location contex
generateMethodBodies
:
false
,
generateDocumentationComments
:
true
,
mergeAttributes
:
false
,
autoInsertionLocation
:
!((
symbol
is
ITypeSymbol
)
&&
(
symbol
as
ITypeSymbol
).
IsEnumType
())
);
autoInsertionLocation
:
false
);
}
}
}
src/Workspaces/Core/Portable/CodeGeneration/AbstractCodeGenerationService.cs
浏览文件 @
9b7fe079
...
...
@@ -262,7 +262,10 @@ protected static T Cast<T>(object value)
// Metadata as source generates complete declarations and doesn't modify
// existing ones. We can take the members to generate, sort them once,
// and then add them in that order to the end of the destination.
newMembers
.
Sort
(
GetMemberComparer
());
if
(!
GeneratingEnum
(
members
))
{
newMembers
.
Sort
(
GetMemberComparer
());
}
currentDestination
=
this
.
AddMembers
(
currentDestination
,
newMembers
);
}
...
...
@@ -270,6 +273,12 @@ protected static T Cast<T>(object value)
return
currentDestination
;
}
private
bool
GeneratingEnum
(
IEnumerable
<
ISymbol
>
members
)
{
var
field
=
members
.
OfType
<
IFieldSymbol
>().
FirstOrDefault
();
return
field
!=
null
&&
field
.
ContainingType
.
IsEnumType
();
}
protected
abstract
IComparer
<
SyntaxNode
>
GetMemberComparer
();
protected
static
CodeGenerationOptions
CreateOptionsForMultipleMembers
(
CodeGenerationOptions
options
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录