Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9899aa58
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,发现更多精彩内容 >>
提交
9899aa58
编写于
5月 13, 2015
作者:
M
Matt Warren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support explicit interface members
上级
df567fdf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
37 deletion
+76
-37
src/Compilers/Core/Portable/DocumentationCommentId.cs
src/Compilers/Core/Portable/DocumentationCommentId.cs
+55
-27
src/Diagnostics/FxCop/Test/Design/CodeFixes/CA1033FixerTests.cs
...agnostics/FxCop/Test/Design/CodeFixes/CA1033FixerTests.cs
+2
-2
src/Workspaces/CSharpTest/CodeGeneration/SymbolEditorTests.cs
...Workspaces/CSharpTest/CodeGeneration/SymbolEditorTests.cs
+4
-4
src/Workspaces/CoreTest/UtilityTest/DocumentationCommentIdTests.cs
...paces/CoreTest/UtilityTest/DocumentationCommentIdTests.cs
+15
-4
未找到文件。
src/Compilers/Core/Portable/DocumentationCommentId.cs
浏览文件 @
9899aa58
...
...
@@ -265,6 +265,39 @@ private static string EncodeName(string name)
return
name
;
}
private
static
string
EncodePropertyName
(
string
name
)
{
// convert C# indexer names to 'Item'
if
(
name
==
"this[]"
)
{
name
=
"Item"
;
}
else
if
(
name
.
EndsWith
(
".this[]"
))
{
name
=
name
.
Substring
(
0
,
name
.
Length
-
6
)
+
"Item"
;
}
return
name
;
}
private
static
string
DecodePropertyName
(
string
name
,
string
language
)
{
// special case, csharp names indexers 'this[]', not 'Item'
if
(
language
==
LanguageNames
.
CSharp
)
{
if
(
name
==
"Item"
)
{
name
=
"this[]"
;
}
else
if
(
name
.
EndsWith
(
".Item"
))
{
name
=
name
.
Substring
(
0
,
name
.
Length
-
4
)
+
"this[]"
;
}
}
return
name
;
}
private
class
DeclarationGenerator
:
SymbolVisitor
{
private
readonly
StringBuilder
_builder
;
...
...
@@ -371,14 +404,10 @@ public override bool VisitProperty(IPropertySymbol symbol)
_builder
.
Append
(
"."
);
}
if
(
symbol
.
Name
==
"this[]"
)
{
_builder
.
Append
(
"Item"
);
}
else
{
_builder
.
Append
(
EncodeName
(
symbol
.
Name
));
}
var
name
=
EncodePropertyName
(
symbol
.
Name
);
_builder
.
Append
(
EncodeName
(
name
));
AppendParameters
(
symbol
.
Parameters
);
return
true
;
}
...
...
@@ -397,19 +426,32 @@ public override bool VisitMethod(IMethodSymbol symbol)
_builder
.
Append
(
symbol
.
TypeParameters
.
Length
);
}
if
(
symbol
.
Parameters
.
Length
>
0
)
AppendParameters
(
symbol
.
Parameters
);
if
(!
symbol
.
ReturnsVoid
)
{
_builder
.
Append
(
"~"
);
this
.
GetReferenceGenerator
(
symbol
).
Visit
(
symbol
.
ReturnType
);
}
return
true
;
}
private
void
AppendParameters
(
ImmutableArray
<
IParameterSymbol
>
parameters
)
{
if
(
parameters
.
Length
>
0
)
{
_builder
.
Append
(
"("
);
for
(
int
i
=
0
,
n
=
symbol
.
P
arameters
.
Length
;
i
<
n
;
i
++)
for
(
int
i
=
0
,
n
=
p
arameters
.
Length
;
i
<
n
;
i
++)
{
if
(
i
>
0
)
{
_builder
.
Append
(
","
);
}
var
p
=
symbol
.
P
arameters
[
i
];
this
.
GetReferenceGenerator
(
s
ymbol
).
Visit
(
p
.
Type
);
var
p
=
p
arameters
[
i
];
this
.
GetReferenceGenerator
(
p
.
ContainingS
ymbol
).
Visit
(
p
.
Type
);
if
(
p
.
RefKind
!=
RefKind
.
None
)
{
_builder
.
Append
(
"@"
);
...
...
@@ -418,14 +460,6 @@ public override bool VisitMethod(IMethodSymbol symbol)
_builder
.
Append
(
")"
);
}
if
(!
symbol
.
ReturnsVoid
)
{
_builder
.
Append
(
"~"
);
this
.
GetReferenceGenerator
(
symbol
).
Visit
(
symbol
.
ReturnType
);
}
return
true
;
}
public
override
bool
VisitNamespace
(
INamespaceSymbol
symbol
)
...
...
@@ -1218,13 +1252,7 @@ private static void GetMatchingProperties(string id, ref int index, List<INamesp
{
for
(
int
i
=
0
,
n
=
containers
.
Count
;
i
<
n
;
i
++)
{
// special case, csharp names indexers 'this[]', not 'Item'
if
(
memberName
==
"Item"
&&
compilation
.
Language
==
LanguageNames
.
CSharp
)
{
memberName
=
"this[]"
;
}
memberName
=
DecodePropertyName
(
memberName
,
compilation
.
Language
);
var
members
=
containers
[
i
].
GetMembers
(
memberName
);
foreach
(
var
symbol
in
members
)
...
...
src/Diagnostics/FxCop/Test/Design/CodeFixes/CA1033FixerTests.cs
浏览文件 @
9899aa58
...
...
@@ -196,8 +196,8 @@ public string Name
VerifyCSharpFix
(
code
,
expectedFixedCode
);
}
[
WorkItem
(
26
50
,
"https://github.com/dotnet/roslyn/issues/2650
"
)]
[
Fact
(
Skip
=
"2650
"
),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
[
WorkItem
(
26
16
,
"https://github.com/dotnet/roslyn/issues/2616
"
)]
[
Fact
(
Skip
=
"2616
"
),
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Diagnostics
)]
public
void
CA1033SimpleDiagnosticCasesCSharp_Indexer
()
{
var
code
=
@"
...
...
src/Workspaces/CSharpTest/CodeGeneration/SymbolEditorTests.cs
浏览文件 @
9899aa58
...
...
@@ -1025,19 +1025,19 @@ public class C : I
var
solution
=
GetSolution
(
code
);
var
typeC
=
(
INamedTypeSymbol
)
GetSymbols
(
solution
,
"C"
).
First
();
var
method
=
typeC
.
GetMembers
().
First
(
m
=>
m
.
Kind
==
SymbolKind
.
Method
);
var
property
=
typeC
.
GetMembers
().
First
(
m
=>
m
.
Kind
==
SymbolKind
.
Property
);
var
editor
=
SymbolEditor
.
Create
(
solution
);
var
new
Method
=
editor
.
EditOneDeclarationAsync
(
method
,
(
e
,
d
)
=>
var
new
Property
=
editor
.
EditOneDeclarationAsync
(
property
,
(
e
,
d
)
=>
{
// nothing
});
var
typeI
=
(
INamedTypeSymbol
)
GetSymbols
(
solution
,
"I"
).
First
();
var
i
method
=
typeI
.
GetMembers
().
First
(
m
=>
m
.
Kind
==
SymbolKind
.
Method
);
var
i
property
=
typeI
.
GetMembers
().
First
(
m
=>
m
.
Kind
==
SymbolKind
.
Property
);
var
newI
Method
=
editor
.
EditOneDeclarationAsync
(
imethod
,
(
e
,
d
)
=>
var
newI
Property
=
editor
.
EditOneDeclarationAsync
(
iproperty
,
(
e
,
d
)
=>
{
// nothing;
});
...
...
src/Workspaces/CoreTest/UtilityTest/DocumentationCommentIdTests.cs
浏览文件 @
9899aa58
...
...
@@ -28,12 +28,23 @@ private void CheckDeclarationId(string expectedId, INamespaceOrTypeSymbol symbol
Assert
.
Equal
(
symbol
,
sym
);
}
private
void
CheckDeclarationId
<
TSymbol
>(
string
expectedId
,
Compilation
compilation
,
Func
<
TSymbol
,
bool
>
test
)
private
TSymbol
CheckDeclarationId
<
TSymbol
>(
string
expectedId
,
Compilation
compilation
,
Func
<
TSymbol
,
bool
>
test
)
where
TSymbol
:
ISymbol
{
var
symbol
=
DocumentationCommentId
.
GetFirstSymbolForDeclarationId
(
expectedId
,
compilation
);
Assert
.
Equal
(
true
,
symbol
is
TSymbol
);
Assert
.
Equal
(
true
,
test
((
TSymbol
)
symbol
));
return
(
TSymbol
)
symbol
;
}
private
void
CheckDeclarationIdExact
<
TSymbol
>(
string
expectedId
,
Compilation
compilation
,
Func
<
TSymbol
,
bool
>
test
)
where
TSymbol
:
ISymbol
{
var
symbol
=
CheckDeclarationId
(
expectedId
,
compilation
,
test
);
var
id
=
DocumentationCommentId
.
CreateDeclarationId
(
symbol
);
Assert
.
Equal
(
expectedId
,
id
);
}
private
void
CheckReferenceId
(
string
expectedId
,
INamespaceOrTypeSymbol
symbol
,
Compilation
compilation
)
...
...
@@ -232,9 +243,9 @@ class Widget : IProcess
}
"
);
CheckDeclarationId
<
IPropertySymbol
>(
"P:Acme.Widget.Width"
,
compilation
,
p
=>
p
.
Name
==
"Width"
);
CheckDeclarationId
<
IPropertySymbol
>(
"P:Acme.Widget.Item(System.Int32)"
,
compilation
,
p
=>
p
.
Parameters
.
Length
==
1
);
CheckDeclarationId
<
IPropertySymbol
>(
"P:Acme.Widget.Item(System.String,System.Int32)"
,
compilation
,
p
=>
p
.
Parameters
.
Length
==
2
);
CheckDeclarationId
Exact
<
IPropertySymbol
>(
"P:Acme.Widget.Width"
,
compilation
,
p
=>
p
.
Name
==
"Width"
);
CheckDeclarationId
Exact
<
IPropertySymbol
>(
"P:Acme.Widget.Item(System.Int32)"
,
compilation
,
p
=>
p
.
Parameters
.
Length
==
1
);
CheckDeclarationId
Exact
<
IPropertySymbol
>(
"P:Acme.Widget.Item(System.String,System.Int32)"
,
compilation
,
p
=>
p
.
Parameters
.
Length
==
2
);
}
[
Fact
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录