Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b595e1f4
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,发现更多精彩内容 >>
提交
b595e1f4
编写于
9月 30, 2015
作者:
B
Brett Forsgren
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5559 from brettfo/doc-comment-attributes
process all attributes in XML documentation comments
上级
96d8afee
705032f5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
101 addition
and
47 deletion
+101
-47
src/EditorFeatures/CSharp/Outlining/Outliners/DocumentationCommentOutliner.cs
...Sharp/Outlining/Outliners/DocumentationCommentOutliner.cs
+20
-17
src/EditorFeatures/CSharpTest/Outlining/DocumentationCommentOutlinerTests.cs
...CSharpTest/Outlining/DocumentationCommentOutlinerTests.cs
+3
-3
src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
...ures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
+22
-0
src/EditorFeatures/VisualBasic/Outlining/Outliners/DocumentationCommentOutliner.vb
...Basic/Outlining/Outliners/DocumentationCommentOutliner.vb
+13
-16
src/EditorFeatures/VisualBasicTest/Outlining/DocumentationCommentOutlinerTests.vb
...lBasicTest/Outlining/DocumentationCommentOutlinerTests.vb
+3
-3
src/EditorFeatures/VisualBasicTest/QuickInfo/SemanticQuickInfoSourceTests.vb
...VisualBasicTest/QuickInfo/SemanticQuickInfoSourceTests.vb
+19
-0
src/Features/Core/Portable/DocumentationCommentFormatting/AbstractDocumentationCommentFormattingService.cs
...rmatting/AbstractDocumentationCommentFormattingService.cs
+21
-8
未找到文件。
src/EditorFeatures/CSharp/Outlining/Outliners/DocumentationCommentOutliner.cs
浏览文件 @
b595e1f4
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
...
...
@@ -50,24 +51,26 @@ private static string GetBannerText(DocumentationCommentTriviaSyntax documentati
else
if
(
node
is
XmlEmptyElementSyntax
)
{
var
e
=
(
XmlEmptyElementSyntax
)
node
;
var
cref
=
e
.
Attributes
.
OfType
<
XmlCrefAttributeSyntax
>().
FirstOrDefault
();
if
(
cref
!=
null
)
foreach
(
var
attribute
in
e
.
Attributes
)
{
sb
.
Append
(
" "
);
sb
.
Append
(
cref
.
Cref
.
ToString
());
}
var
nameattribute
=
e
.
Attributes
.
OfType
<
XmlNameAttributeSyntax
>().
FirstOrDefault
();
if
(
nameattribute
!=
null
)
{
sb
.
Append
(
" "
);
sb
.
Append
(
nameattribute
.
Identifier
.
Identifier
.
Text
);
}
var
langword
=
e
.
Attributes
.
OfType
<
XmlTextAttributeSyntax
>().
FirstOrDefault
(
a
=>
a
.
Name
.
LocalName
.
ToString
()
==
"langword"
);
if
(
langword
!=
null
)
{
AppendTextTokens
(
sb
,
langword
.
TextTokens
);
if
(
attribute
is
XmlCrefAttributeSyntax
)
{
sb
.
Append
(
" "
);
sb
.
Append
(((
XmlCrefAttributeSyntax
)
attribute
).
Cref
.
ToString
());
}
else
if
(
attribute
is
XmlNameAttributeSyntax
)
{
sb
.
Append
(
" "
);
sb
.
Append
(((
XmlNameAttributeSyntax
)
attribute
).
Identifier
.
Identifier
.
Text
);
}
else
if
(
attribute
is
XmlTextAttributeSyntax
)
{
AppendTextTokens
(
sb
,
((
XmlTextAttributeSyntax
)
attribute
).
TextTokens
);
}
else
{
Debug
.
Fail
(
$"Unexpected XML syntax kind
{
attribute
.
Kind
()}
"
);
}
}
}
}
...
...
src/EditorFeatures/CSharpTest/Outlining/DocumentationCommentOutlinerTests.cs
浏览文件 @
b595e1f4
...
...
@@ -391,7 +391,7 @@ public void CrefInSummary()
"{"
,
" /// <summary>"
,
" /// Summary with <see cref=\"SeeClass\" />, <seealso cref=\"SeeAlsoClass\" />, "
,
" /// <see langword=\"null\" />, <typeparamref name=\"T\" />,
and <paramref name=\"t
\" />."
,
" /// <see langword=\"null\" />, <typeparamref name=\"T\" />,
<paramref name=\"t\" />, and <see unsupported-attribute=\"not-supported
\" />."
,
" /// </summary>"
,
" public void M<T>(T t) { }"
,
"}"
);
...
...
@@ -402,8 +402,8 @@ public void CrefInSummary()
var
docComment
=
(
DocumentationCommentTriviaSyntax
)
trivia
.
Single
(
t
=>
t
.
HasStructure
).
GetStructure
();
var
actualRegion
=
GetRegion
(
docComment
);
var
expectedRegion
=
new
OutliningSpan
(
TextSpan
.
FromBounds
(
16
,
2
18
),
"/// <summary> Summary with SeeClass , SeeAlsoClass , null , T ,
and t
."
,
TextSpan
.
FromBounds
(
16
,
2
65
),
"/// <summary> Summary with SeeClass , SeeAlsoClass , null , T ,
t , and not-supported
."
,
autoCollapse
:
true
);
AssertRegion
(
expectedRegion
,
actualRegion
);
...
...
src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
浏览文件 @
b595e1f4
...
...
@@ -4184,5 +4184,27 @@ void M()
"
,
Exceptions
(
$"\r\n
{
WorkspacesResources
.
Exceptions
}
\r\n MyException1\r\n MyException2\r\n int\r\n double\r\n Not_A_Class_But_Still_Displayed"
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)]
[
WorkItem
(
1516
,
"https://github.com/dotnet/roslyn/issues/1516"
)]
public
void
QuickInfoWithNonStandardSeeAttributesAppear
()
{
Test
(
@"
class C
{
/// <summary>
/// <see cref=""System.String"" />
/// <see href=""http://microsoft.com"" />
/// <see langword=""null"" />
/// <see unsupported-attribute=""cat"" />
/// </summary>
void M()
{
M$$();
}
}
"
,
Documentation
(
@"string http://microsoft.com null cat"
));
}
}
}
src/EditorFeatures/VisualBasic/Outlining/Outliners/DocumentationCommentOutliner.vb
浏览文件 @
b595e1f4
...
...
@@ -26,22 +26,19 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Outlining
AppendTextTokens
(
sb
,
textTokens
)
ElseIf
node
.
Kind
()
=
SyntaxKind
.
XmlEmptyElement
Then
Dim
elementNode
=
DirectCast
(
node
,
XmlEmptyElementSyntax
)
Dim
cref
=
elementNode
.
Attributes
.
OfType
(
Of
XmlCrefAttributeSyntax
).
FirstOrDefault
()
If
cref
IsNot
Nothing
Then
sb
.
Append
(
" "
)
sb
.
Append
(
cref
.
Reference
.
ToString
())
End
If
Dim
nameattribute
=
elementNode
.
Attributes
.
OfType
(
Of
XmlNameAttributeSyntax
).
FirstOrDefault
()
If
nameattribute
IsNot
Nothing
Then
sb
.
Append
(
" "
)
sb
.
Append
(
nameattribute
.
Reference
.
ToString
())
End
If
Dim
langword
=
elementNode
.
Attributes
.
OfType
(
Of
XmlAttributeSyntax
).
FirstOrDefault
(
Function
(
a
)
a
.
Name
.
ToString
()
=
"langword"
)
If
langword
IsNot
Nothing
Then
AppendTextTokens
(
sb
,
DirectCast
(
langword
.
Value
,
XmlStringSyntax
).
TextTokens
)
End
If
For
Each
attribute
In
elementNode
.
Attributes
If
TypeOf
attribute
Is
XmlCrefAttributeSyntax
Then
sb
.
Append
(
" "
)
sb
.
Append
(
DirectCast
(
attribute
,
XmlCrefAttributeSyntax
).
Reference
.
ToString
())
ElseIf
TypeOf
attribute
Is
XmlNameAttributeSyntax
Then
sb
.
Append
(
" "
)
sb
.
Append
(
DirectCast
(
attribute
,
XmlNameAttributeSyntax
).
Reference
.
ToString
())
ElseIf
TypeOf
attribute
Is
XmlAttributeSyntax
Then
AppendTextTokens
(
sb
,
DirectCast
(
DirectCast
(
attribute
,
XmlAttributeSyntax
).
Value
,
XmlStringSyntax
).
TextTokens
)
Else
Debug
.
Fail
(
$
"Unexpected XML syntax kind {attribute.Kind()}"
)
End
If
Next
End
If
Next
...
...
src/EditorFeatures/VisualBasicTest/Outlining/DocumentationCommentOutlinerTests.vb
浏览文件 @
b595e1f4
...
...
@@ -236,7 +236,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Outlining
Dim
tree
=
ParseLines
(
"Class C"
,
" ''' <summary>"
,
" ''' Summary with <see cref=
""
SeeClass
""
/>, <seealso cref=
""
SeeAlsoClass
""
/>,"
,
" ''' <see langword=
""
Nothing
""
/>, <typeparamref name=
""
T
""
/>,
and <paramref name=
""
t
""
/>."
,
" ''' <see langword=
""
Nothing
""
/>, <typeparamref name=
""
T
""
/>,
<paramref name=
""
t
""
/>, and <see unsupported-attribute=
""
not-supported
""
/>."
,
" ''' </summary>"
,
" Sub M(Of T)(t as T)"
,
" End Sub"
,
...
...
@@ -248,8 +248,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Outlining
Dim
docComment
=
DirectCast
(
trivia
.
Single
(
Function
(
t
)
t
.
HasStructure
).
GetStructure
(),
DocumentationCommentTriviaSyntax
)
Dim
actualRegion
=
GetRegion
(
docComment
)
Dim
expectedRegion
=
New
OutliningSpan
(
TextSpan
.
FromBounds
(
13
,
2
17
),
"''' <summary> Summary with SeeClass , SeeAlsoClass , Nothing , T ,
and t
."
,
TextSpan
.
FromBounds
(
13
,
2
64
),
"''' <summary> Summary with SeeClass , SeeAlsoClass , Nothing , T ,
t , and not-supported
."
,
autoCollapse
:
=
True
)
AssertRegion
(
expectedRegion
,
actualRegion
)
...
...
src/EditorFeatures/VisualBasicTest/QuickInfo/SemanticQuickInfoSourceTests.vb
浏览文件 @
b595e1f4
...
...
@@ -2059,5 +2059,24 @@ End Namespace
Exceptions
(
$
"{vbCrLf}{WorkspacesResources.Exceptions}{vbCrLf} MyException1{vbCrLf} MyException2{vbCrLf} Integer{vbCrLf} Double{vbCrLf} Not_A_Class_But_Still_Displayed"
))
End
Sub
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
QuickInfo
)
>
<
WorkItem
(
1516
,
"https://github.com/dotnet/roslyn/issues/1516"
)
>
Public
Sub
QuickInfoWithNonStandardSeeAttributesAppear
()
Test
(
"
Class C
''' <summary>
''' <see cref=
""
System.String
""
/>
''' <see href=
""
http://microsoft.com
""
/>
''' <see langword=
""
Nothing
""
/>
''' <see unsupported-attribute=
""
cat
""
/>
''' </summary>
Sub M()
M$$()
End Sub
End Class
"
,
Documentation
(
"String http://microsoft.com Nothing cat"
))
End
Sub
End
Class
End
Namespace
src/Features/Core/Portable/DocumentationCommentFormatting/AbstractDocumentationCommentFormattingService.cs
浏览文件 @
b595e1f4
...
...
@@ -156,13 +156,21 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
if
(
name
==
"see"
||
name
==
"seealso"
)
{
AppendTextFromAttribute
(
state
,
element
,
"cref"
);
foreach
(
var
attribute
in
element
.
Attributes
())
{
AppendTextFromAttribute
(
state
,
element
,
attribute
,
attributeNameToParse
:
"cref"
);
}
return
;
}
else
if
(
name
==
"paramref"
||
name
==
"typeparamref"
)
{
AppendTextFromAttribute
(
state
,
element
,
"name"
);
foreach
(
var
attribute
in
element
.
Attributes
())
{
AppendTextFromAttribute
(
state
,
element
,
attribute
,
attributeNameToParse
:
"name"
);
}
return
;
}
...
...
@@ -182,15 +190,20 @@ private static void AppendTextFromNode(FormatterState state, XNode node, Compila
}
}
private
static
void
AppendTextFromAttribute
(
FormatterState
state
,
XElement
element
,
string
attributeNam
e
)
private
static
void
AppendTextFromAttribute
(
FormatterState
state
,
XElement
element
,
XAttribute
attribute
,
string
attributeNameToPars
e
)
{
var
attribute
=
element
.
Attribute
(
attributeName
)
;
if
(
attribute
==
null
)
var
attribute
Name
=
attribute
.
Name
.
LocalName
;
if
(
attribute
NameToParse
==
attributeName
)
{
return
;
state
.
AppendParts
(
CrefToSymbolDisplayParts
(
attribute
.
Value
,
state
.
Position
,
state
.
SemanticModel
,
state
.
Format
));
}
else
{
var
displayKind
=
attributeName
==
"langword"
?
SymbolDisplayPartKind
.
Keyword
:
SymbolDisplayPartKind
.
Text
;
state
.
AppendParts
(
SpecializedCollections
.
SingletonEnumerable
(
new
SymbolDisplayPart
(
kind
:
displayKind
,
symbol
:
null
,
text
:
attribute
.
Value
)));
}
state
.
AppendParts
(
CrefToSymbolDisplayParts
(
attribute
.
Value
,
state
.
Position
,
state
.
SemanticModel
,
state
.
Format
));
}
internal
static
IEnumerable
<
SymbolDisplayPart
>
CrefToSymbolDisplayParts
(
string
crefValue
,
int
position
,
SemanticModel
semanticModel
,
SymbolDisplayFormat
format
=
null
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录