Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9424cbdd
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,发现更多精彩内容 >>
未验证
提交
9424cbdd
编写于
3月 07, 2019
作者:
S
Sam Harwell
提交者:
GitHub
3月 07, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #33547 from sharwell/classify-quick-info
Classify paramref and typeparamref in Quick Info
上级
1cc5ab66
82a6eb63
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
123 addition
and
6 deletion
+123
-6
src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests.vb
...s/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests.vb
+116
-0
src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs
...Comments/AbstractDocumentationCommentFormattingService.cs
+7
-6
未找到文件。
src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests.vb
浏览文件 @
9424cbdd
...
...
@@ -478,6 +478,122 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
AssertEqualAdornments
(
expected
,
container
)
End
Sub
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
<
WorkItem
(
33546
,
"https://github.com/dotnet/roslyn/issues/33546"
)
>
Public
Async
Sub
QuickInfoForParameterReference
()
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
using
System
.
Threading
;
class
MyClass
{
///
&
lt
;
summary>
;
///
The
parameter
is
&
lt
;
paramref
name
=
"p"
/&
gt
;
.
///
&
lt
;
/
summary>
;
void
MyMethod
(
CancellationToken
p
)
{
MyM
$$
ethod
(
CancellationToken
.
None
)
;
}
}
</
Document
>
</
Project
>
</
Workspace
>
Dim
codeAnalysisQuickInfoItem
=
Await
GetQuickInfoItemAsync
(
workspace
,
LanguageNames
.
CSharp
)
Dim
trackingSpan
=
New
Mock
(
Of
ITrackingSpan
)
With
{
.
DefaultValue
=
DefaultValue
.
Mock
}
Dim
intellisenseQuickInfo
=
Await
IntellisenseQuickInfoBuilder
.
BuildItemAsync
(
trackingSpan
.
Object
,
codeAnalysisQuickInfoItem
,
Nothing
,
Nothing
,
CancellationToken
.
None
)
Assert
.
NotNull
(
intellisenseQuickInfo
)
Dim
container
=
Assert
.
IsType
(
Of
ContainerElement
)(
intellisenseQuickInfo
.
Item
)
Dim
expected
=
New
ContainerElement
(
ContainerElementStyle
.
Stacked
Or
ContainerElementStyle
.
VerticalPadding
,
New
ContainerElement
(
ContainerElementStyle
.
Stacked
,
New
ContainerElement
(
ContainerElementStyle
.
Wrapped
,
New
ImageElement
(
New
ImageId
(
KnownImageIds
.
ImageCatalogGuid
,
KnownImageIds
.
MethodPrivate
)),
New
ClassifiedTextElement
(
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Keyword
,
"void"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
ClassName
,
"MyClass"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
"."
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
MethodName
,
"MyMethod"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
"("
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
StructName
,
"CancellationToken"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
ParameterName
,
"p"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
")"
))),
New
ClassifiedTextElement
(
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"The parameter is"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
ParameterName
,
"p"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"."
))))
AssertEqualAdornments
(
expected
,
container
)
End
Sub
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
<
WorkItem
(
33546
,
"https://github.com/dotnet/roslyn/issues/33546"
)
>
Public
Async
Sub
QuickInfoForTypeParameterReference
()
Dim
workspace
=
<
Workspace
>
<
Project
Language
=
"C#"
CommonReferences
=
"true"
>
<
Document
>
using
System
.
Threading
;
class
MyClass
{
///
&
lt
;
summary>
;
///
The
type
parameter
is
&
lt
;
typeparamref
name
=
"T"
/&
gt
;
.
///
&
lt
;
/
summary>
;
void
MyMethod
&
lt
;
T
&
gt
;
()
{
MyM
$$
ethod<
;
int>
;
()
;
}
}
</
Document
>
</
Project
>
</
Workspace
>
Dim
codeAnalysisQuickInfoItem
=
Await
GetQuickInfoItemAsync
(
workspace
,
LanguageNames
.
CSharp
)
Dim
trackingSpan
=
New
Mock
(
Of
ITrackingSpan
)
With
{
.
DefaultValue
=
DefaultValue
.
Mock
}
Dim
intellisenseQuickInfo
=
Await
IntellisenseQuickInfoBuilder
.
BuildItemAsync
(
trackingSpan
.
Object
,
codeAnalysisQuickInfoItem
,
Nothing
,
Nothing
,
CancellationToken
.
None
)
Assert
.
NotNull
(
intellisenseQuickInfo
)
Dim
container
=
Assert
.
IsType
(
Of
ContainerElement
)(
intellisenseQuickInfo
.
Item
)
Dim
expected
=
New
ContainerElement
(
ContainerElementStyle
.
Stacked
Or
ContainerElementStyle
.
VerticalPadding
,
New
ContainerElement
(
ContainerElementStyle
.
Stacked
,
New
ContainerElement
(
ContainerElementStyle
.
Wrapped
,
New
ImageElement
(
New
ImageId
(
KnownImageIds
.
ImageCatalogGuid
,
KnownImageIds
.
MethodPrivate
)),
New
ClassifiedTextElement
(
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Keyword
,
"void"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
ClassName
,
"MyClass"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
"."
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
MethodName
,
"MyMethod"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
"<"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Keyword
,
"int"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
">"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
"("
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Punctuation
,
")"
))),
New
ClassifiedTextElement
(
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"The type parameter is"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
WhiteSpace
,
" "
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
TypeParameterName
,
"T"
),
New
ClassifiedTextRun
(
ClassificationTypeNames
.
Text
,
"."
))))
AssertEqualAdornments
(
expected
,
container
)
End
Sub
Private
Async
Function
GetQuickInfoItemAsync
(
workspaceDefinition
As
XElement
,
language
As
String
)
As
Task
(
Of
QuickInfoItem
)
Using
workspace
=
TestWorkspace
.
Create
(
workspaceDefinition
)
Dim
solution
=
workspace
.
CurrentSolution
...
...
src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs
浏览文件 @
9424cbdd
...
...
@@ -186,7 +186,7 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
{
foreach
(
var
attribute
in
element
.
Attributes
())
{
AppendTextFromAttribute
(
state
,
element
,
attribute
,
attributeNameToParse
:
DocumentationCommentXmlNames
.
CrefAttributeName
);
AppendTextFromAttribute
(
state
,
element
,
attribute
,
attributeNameToParse
:
DocumentationCommentXmlNames
.
CrefAttributeName
,
SymbolDisplayPartKind
.
Text
);
}
return
;
...
...
@@ -195,9 +195,10 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
else
if
(
name
==
DocumentationCommentXmlNames
.
ParameterReferenceElementName
||
name
==
DocumentationCommentXmlNames
.
TypeParameterReferenceElementName
)
{
var
kind
=
name
==
DocumentationCommentXmlNames
.
ParameterReferenceElementName
?
SymbolDisplayPartKind
.
ParameterName
:
SymbolDisplayPartKind
.
TypeParameterName
;
foreach
(
var
attribute
in
element
.
Attributes
())
{
AppendTextFromAttribute
(
state
,
element
,
attribute
,
attributeNameToParse
:
DocumentationCommentXmlNames
.
NameAttributeName
);
AppendTextFromAttribute
(
state
,
element
,
attribute
,
attributeNameToParse
:
DocumentationCommentXmlNames
.
NameAttributeName
,
kind
);
}
return
;
...
...
@@ -223,13 +224,13 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
}
}
private
static
void
AppendTextFromAttribute
(
FormatterState
state
,
XElement
element
,
XAttribute
attribute
,
string
attributeNameToParse
)
private
static
void
AppendTextFromAttribute
(
FormatterState
state
,
XElement
element
,
XAttribute
attribute
,
string
attributeNameToParse
,
SymbolDisplayPartKind
kind
)
{
var
attributeName
=
attribute
.
Name
.
LocalName
;
if
(
attributeNameToParse
==
attributeName
)
{
state
.
AppendParts
(
CrefToSymbolDisplayParts
(
attribute
.
Value
,
state
.
Position
,
state
.
SemanticModel
,
state
.
Format
).
ToTaggedText
());
CrefToSymbolDisplayParts
(
attribute
.
Value
,
state
.
Position
,
state
.
SemanticModel
,
state
.
Format
,
kind
).
ToTaggedText
());
}
else
{
...
...
@@ -241,7 +242,7 @@ private static void AppendTextFromAttribute(FormatterState state, XElement eleme
}
internal
static
IEnumerable
<
SymbolDisplayPart
>
CrefToSymbolDisplayParts
(
string
crefValue
,
int
position
,
SemanticModel
semanticModel
,
SymbolDisplayFormat
format
=
null
)
string
crefValue
,
int
position
,
SemanticModel
semanticModel
,
SymbolDisplayFormat
format
=
null
,
SymbolDisplayPartKind
kind
=
SymbolDisplayPartKind
.
Text
)
{
// first try to parse the symbol
if
(
semanticModel
!=
null
)
...
...
@@ -261,7 +262,7 @@ private static void AppendTextFromAttribute(FormatterState state, XElement eleme
// if any of that fails fall back to just displaying the raw text
return
SpecializedCollections
.
SingletonEnumerable
(
new
SymbolDisplayPart
(
SymbolDisplayPartKind
.
Text
,
symbol
:
null
,
text
:
TrimCrefPrefix
(
crefValue
)));
new
SymbolDisplayPart
(
kind
,
symbol
:
null
,
text
:
TrimCrefPrefix
(
crefValue
)));
}
private
static
string
TrimCrefPrefix
(
string
value
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录