Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
649f3b63
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,发现更多精彩内容 >>
提交
649f3b63
编写于
6月 12, 2019
作者:
G
Gen Lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't show non attribute import completion items in attribute context
上级
fa73aa94
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
6 deletion
+50
-6
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/TypeImportCompletionProviderTests.cs
.../CompletionProviders/TypeImportCompletionProviderTests.cs
+11
-0
src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/TypeImportCompletionProviderTests.vb
.../CompletionProviders/TypeImportCompletionProviderTests.vb
+29
-0
src/Features/Core/Portable/Completion/Providers/TypeImportCompletionService.cs
...table/Completion/Providers/TypeImportCompletionService.cs
+10
-6
未找到文件。
src/EditorFeatures/CSharpTest/Completion/CompletionProviders/TypeImportCompletionProviderTests.cs
浏览文件 @
649f3b63
...
...
@@ -915,6 +915,7 @@ public async Task AttributeTypeInAttributeNameContext()
namespace Foo
{
public class MyAttribute : System.Attribute { }
public class MyClass { }
}"
;
var
file2
=
@"
...
...
@@ -927,6 +928,7 @@ class Program { }
await
VerifyTypeImportItemExistsAsync
(
markup
,
"My"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.MyAttribute"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"MyAttribute"
,
inlineDescription
:
"Foo"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"MyClass"
,
inlineDescription
:
"Foo"
);
}
[
InlineData
(
SourceCodeKind
.
Regular
)]
...
...
@@ -969,6 +971,7 @@ public async Task AttributeTypeInNonAttributeNameContext()
namespace Foo
{
public class MyAttribute : System.Attribute { }
public class MyClass { }
}"
;
var
file2
=
@"
...
...
@@ -983,6 +986,7 @@ class Program
await
VerifyTypeImportItemExistsAsync
(
markup
,
"MyAttribute"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.MyAttribute"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"My"
,
inlineDescription
:
"Foo"
);
await
VerifyTypeImportItemExistsAsync
(
markup
,
"MyClass"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.MyClass"
);
}
[
InlineData
(
SourceCodeKind
.
Regular
)]
...
...
@@ -1028,6 +1032,7 @@ public async Task AttributeTypeWithoutSuffixInAttributeNameContext()
namespace Foo
{
public class Myattribute : System.Attribute { }
public class MyClass { }
}"
;
var
file2
=
@"
...
...
@@ -1040,6 +1045,7 @@ class Program { }
await
VerifyTypeImportItemExistsAsync
(
markup
,
"Myattribute"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.Myattribute"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"My"
,
inlineDescription
:
"Foo"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"MyClass"
,
inlineDescription
:
"Foo"
);
}
[
InlineData
(
SourceCodeKind
.
Regular
)]
...
...
@@ -1082,6 +1088,7 @@ public async Task AttributeTypeWithoutSuffixInNonAttributeNameContext()
namespace Foo
{
public class Myattribute : System.Attribute { }
public class MyClass { }
}"
;
var
file2
=
@"
...
...
@@ -1096,6 +1103,7 @@ class Program
await
VerifyTypeImportItemExistsAsync
(
markup
,
"Myattribute"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.Myattribute"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"My"
,
inlineDescription
:
"Foo"
);
await
VerifyTypeImportItemExistsAsync
(
markup
,
"MyClass"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.MyClass"
);
}
[
InlineData
(
SourceCodeKind
.
Regular
)]
...
...
@@ -1142,6 +1150,8 @@ Namespace Foo
Public Class Myattribute
Inherits System.Attribute
End Class
Public Class MyVBClass
End Class
End Namespace"
;
var
file2
=
@"
...
...
@@ -1157,6 +1167,7 @@ class Program
await
VerifyTypeImportItemExistsAsync
(
markup
,
"Myattribute"
,
glyph
:
(
int
)
Glyph
.
ClassPublic
,
inlineDescription
:
"Foo"
,
expectedDescriptionOrNull
:
"class Foo.Myattribute"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"My"
,
inlineDescription
:
"Foo"
);
await
VerifyTypeImportItemIsAbsentAsync
(
markup
,
"MyVBClass"
,
inlineDescription
:
"Foo"
);
}
...
...
src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/TypeImportCompletionProviderTests.vb
浏览文件 @
649f3b63
...
...
@@ -41,6 +41,8 @@ Namespace Foo
Public
Class
MyAttribute
Inherits
System
.
Attribute
End
Class
Public
Class
MyVBClass
End
Class
End
Namespace
</
Text
>
.
Value
Dim
file2
=
<
Text
><
!
[
CDATA
[
...
...
@@ -54,6 +56,33 @@ End Class]]></Text>.Value
Dim
markup
=
CreateMarkupForSingleProject
(
file2
,
file1
,
LanguageNames
.
VisualBasic
)
Await
VerifyItemExistsAsync
(
markup
,
"My"
,
glyph
:
=
Glyph
.
ClassPublic
,
inlineDescription
:
=
"Foo"
,
expectedDescriptionOrNull
:
=
"Class Foo.MyAttribute"
)
Await
VerifyItemIsAbsentAsync
(
markup
,
"MyAttribute"
,
inlineDescription
:
=
"Foo"
)
Await
VerifyItemIsAbsentAsync
(
markup
,
"MyVBClass"
,
inlineDescription
:
=
"Foo"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)
>
<
WorkItem
(
35540
,
"https://github.com/dotnet/roslyn/issues/35540"
)
>
Public
Async
Function
AttributeTypeInNonAttributeNameContext
()
As
Task
Dim
file1
=
<
Text
>
Namespace
Foo
Public
Class
MyAttribute
Inherits
System
.
Attribute
End
Class
Public
Class
MyVBClass
End
Class
End
Namespace
</
Text
>
.
Value
Dim
file2
=
<
Text
><
!
[
CDATA
[
Public
Class
Bar
Sub
Main
()
Dim
x
As
$$
End
Sub
End
Class
]]
></
Text
>
.
Value
Dim
markup
=
CreateMarkupForSingleProject
(
file2
,
file1
,
LanguageNames
.
VisualBasic
)
Await
VerifyItemExistsAsync
(
markup
,
"MyAttribute"
,
glyph
:
=
Glyph
.
ClassPublic
,
inlineDescription
:
=
"Foo"
,
expectedDescriptionOrNull
:
=
"Class Foo.MyAttribute"
)
Await
VerifyItemExistsAsync
(
markup
,
"MyVBClass"
,
glyph
:
=
Glyph
.
ClassPublic
,
inlineDescription
:
=
"Foo"
,
expectedDescriptionOrNull
:
=
"Class Foo.MyVBClass"
)
Await
VerifyItemIsAbsentAsync
(
markup
,
"My"
,
inlineDescription
:
=
"Foo"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Completion
)
>
...
...
src/Features/Core/Portable/Completion/Providers/TypeImportCompletionService.cs
浏览文件 @
649f3b63
...
...
@@ -212,14 +212,17 @@ static string GetReferenceKey(PortableExecutableReference reference)
cache
[
key
]
=
cacheEntry
;
}
foreach
(
var
item
in
cacheEntry
.
CommonItems
)
if
(!
syntaxContext
.
IsAttributeNameContext
)
{
handleItem
(
item
);
}
foreach
(
var
item
in
cacheEntry
.
CommonItems
)
{
handleItem
(
item
);
}
foreach
(
var
item
in
cacheEntry
.
GetGenericItems
(
isCSharp
))
{
handleItem
(
item
);
foreach
(
var
item
in
cacheEntry
.
GetGenericItems
(
isCSharp
))
{
handleItem
(
item
);
}
}
foreach
(
var
item
in
cacheEntry
.
GetAttributeItems
(
isCSharp
,
syntaxContext
.
IsAttributeNameContext
))
...
...
@@ -375,6 +378,7 @@ public void AddItem(INamedTypeSymbol symbol, string containingNamespace, bool is
{
ArrayBuilder
<
TypeImportCompletionItemInfo
>
correspondingBuilder
;
// Attribute type can't be generic
if
(
symbol
.
Arity
>
0
)
{
correspondingBuilder
=
_genericItemsBuilder
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录