Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
8f4011df
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,发现更多精彩内容 >>
提交
8f4011df
编写于
5月 15, 2018
作者:
M
Mikkel Nylander Bundgaard
提交者:
Ivan Basov
5月 15, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Escape keywords in object initializer completion (#26740)
上级
18cdf8df
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
1 deletion
+67
-1
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.cs
...tionProviders/ObjectInitializerCompletionProviderTests.cs
+30
-0
src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.vb
...tionProviders/ObjectInitializerCompletionProviderTests.vb
+26
-0
src/Features/CSharp/Portable/Completion/CompletionProviders/ObjectInitializerCompletionProvider.cs
...ompletionProviders/ObjectInitializerCompletionProvider.cs
+5
-0
src/Features/Core/Portable/Completion/Providers/AbstractObjectInitializerCompletionProvider.cs
.../Providers/AbstractObjectInitializerCompletionProvider.cs
+2
-1
src/Features/VisualBasic/Portable/Completion/CompletionProviders/ObjectInitializerCompletionProvider.vb
...ompletionProviders/ObjectInitializerCompletionProvider.vb
+4
-0
未找到文件。
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.cs
浏览文件 @
8f4011df
...
...
@@ -820,6 +820,36 @@ static void Main(string[] args)
await
VerifyItemExistsAsync
(
markup
,
"Value"
);
}
[
WorkItem
(
26560
,
"https://github.com/dotnet/roslyn/issues/26560"
)]
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)]
public
async
Task
ObjectInitializerEscapeKeywords
()
{
var
markup
=
@"
class c
{
public int @new { get; set; }
public int @this { get; set; }
public int now { get; set; }
}
class d
{
static void Main(string[] args)
{
var t = new c() { $$ };
}
}"
;
await
VerifyItemExistsAsync
(
markup
,
"@new"
);
await
VerifyItemExistsAsync
(
markup
,
"@this"
);
await
VerifyItemExistsAsync
(
markup
,
"now"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"new"
);
await
VerifyItemIsAbsentAsync
(
markup
,
"this"
);
}
private
async
Task
VerifyExclusiveAsync
(
string
markup
,
bool
exclusive
)
{
using
(
var
workspace
=
TestWorkspace
.
CreateCSharp
(
markup
))
...
...
src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.vb
浏览文件 @
8f4011df
...
...
@@ -435,6 +435,32 @@ End Program"
Await
VerifySendEnterThroughToEditorAsync
(
code
,
"bar"
,
expected
:
=
False
)
End
Function
<
WorkItem
(
26560
,
"https://github.com/dotnet/roslyn/issues/26560"
)
>
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)
>
Public
Async
Function
TestKeywordsEscaped
()
As
Task
Dim
text
=
<
a
>
Class
C
Public
Property
[
Wend
]
As
Integer
Public
Property
[
New
]
As
Integer
Public
Property
A
As
Integer
End
Class
Class
Program
Sub
Main
()
Dim
c
As
New
C
With
{
.
$$
}
End
Sub
End
Class
</
a
>
.
Value
Await
VerifyItemExistsAsync
(
text
,
"[Wend]"
)
Await
VerifyItemExistsAsync
(
text
,
"[New]"
)
Await
VerifyItemExistsAsync
(
text
,
"A"
)
Await
VerifyItemIsAbsentAsync
(
text
,
"Wend"
)
Await
VerifyItemIsAbsentAsync
(
text
,
"New"
)
End
Function
Friend
Overrides
Function
CreateCompletionProvider
()
As
CompletionProvider
Return
New
ObjectInitializerCompletionProvider
()
End
Function
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/ObjectInitializerCompletionProvider.cs
浏览文件 @
8f4011df
...
...
@@ -178,5 +178,10 @@ protected override bool IsInitializable(ISymbol member, INamedTypeSymbol contain
return
base
.
IsInitializable
(
member
,
containingType
);
}
protected
override
string
EscapeIdentifier
(
ISymbol
symbol
)
{
return
symbol
.
Name
.
EscapeIdentifier
();
}
}
}
src/Features/Core/Portable/Completion/Providers/AbstractObjectInitializerCompletionProvider.cs
浏览文件 @
8f4011df
...
...
@@ -15,6 +15,7 @@ internal abstract class AbstractObjectInitializerCompletionProvider : CommonComp
{
protected
abstract
Tuple
<
ITypeSymbol
,
Location
>
GetInitializedType
(
Document
document
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
);
protected
abstract
HashSet
<
string
>
GetInitializedMembers
(
SyntaxTree
tree
,
int
position
,
CancellationToken
cancellationToken
);
protected
abstract
string
EscapeIdentifier
(
ISymbol
symbol
);
public
override
async
Task
ProvideCompletionsAsync
(
CompletionContext
context
)
{
...
...
@@ -63,7 +64,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
foreach
(
var
uninitializedMember
in
uninitializedMembers
)
{
context
.
AddItem
(
SymbolCompletionItem
.
CreateWithSymbolId
(
displayText
:
uninitializedMember
.
Name
,
displayText
:
EscapeIdentifier
(
uninitializedMember
)
,
insertionText
:
null
,
symbols
:
ImmutableArray
.
Create
(
uninitializedMember
),
contextPosition
:
initializerLocation
.
SourceSpan
.
Start
,
...
...
src/Features/VisualBasic/Portable/Completion/CompletionProviders/ObjectInitializerCompletionProvider.vb
浏览文件 @
8f4011df
...
...
@@ -93,6 +93,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.Providers
member
.
IsAccessibleWithin
(
containingType
)
End
Function
Protected
Overrides
Function
EscapeIdentifier
(
symbol
As
ISymbol
)
As
String
Return
symbol
.
Name
.
EscapeIdentifier
()
End
Function
Private
Function
IsValidProperty
(
member
As
ISymbol
)
As
Boolean
Dim
[
property
]
=
TryCast
(
member
,
IPropertySymbol
)
If
[
property
]
IsNot
Nothing
Then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录