Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
fe0f063f
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,发现更多精彩内容 >>
提交
fe0f063f
编写于
2月 17, 2016
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update doc comment tests that contain XML comments with paths
上级
6131e988
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
125 addition
and
30 deletion
+125
-30
src/Compilers/CSharp/Test/Symbol/DocumentationComments/DocumentationCommentCompilerTests.cs
...ocumentationComments/DocumentationCommentCompilerTests.cs
+39
-7
src/Compilers/CSharp/Test/Symbol/DocumentationComments/DocumentationModeTests.cs
...st/Symbol/DocumentationComments/DocumentationModeTests.cs
+2
-2
src/Compilers/VisualBasic/Test/Symbol/DocumentationComments/DocCommentTests.vb
...asic/Test/Symbol/DocumentationComments/DocCommentTests.vb
+62
-21
src/Test/Utilities/Desktop/TestHelpers.cs
src/Test/Utilities/Desktop/TestHelpers.cs
+22
-0
未找到文件。
src/Compilers/CSharp/Test/Symbol/DocumentationComments/DocumentationCommentCompilerTests.cs
浏览文件 @
fe0f063f
...
...
@@ -2694,7 +2694,7 @@ class C {{ }}
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
xmlFilePath1
),
actual
);
}
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
,
Skip
=
"https://github.com/dotnet/roslyn/issues/8807"
)]
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
)]
public
void
WRN_XMLParseIncludeError_Source
()
{
var
xmlFile
=
Temp
.
CreateFile
(
extension
:
".xml"
).
WriteAllText
(
"<OpenWithoutClose>"
);
...
...
@@ -2724,7 +2724,7 @@ class C {{ }}
</members>
</doc>
"
).
Trim
();
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
xmlFilePath
),
actual
);
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
TestHelpers
.
AsXmlCommentText
(
xmlFilePath
)
),
actual
);
}
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
)]
...
...
@@ -3679,7 +3679,7 @@ class C
Assert
.
Equal
(
expected
,
actual
);
}
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
,
Skip
=
"https://github.com/dotnet/roslyn/issues/8807"
)]
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
)]
public
void
IncludedName_DuplicateNameAttribute
()
{
var
xmlFile
=
Temp
.
CreateFile
(
extension
:
".xml"
).
WriteAllText
(
@"<param name=""x"" name=""y""/>"
);
...
...
@@ -3713,7 +3713,7 @@ class C
</members>
</doc>
"
).
Trim
();
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
xmlFilePath
),
actual
);
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
TestHelpers
.
AsXmlCommentText
(
xmlFilePath
)
),
actual
);
}
[
Fact
]
...
...
@@ -3762,7 +3762,7 @@ Part 2.
</members>
</doc>
"
).
Trim
();
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
xmlFilePath
),
actual
);
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
TestHelpers
.
AsXmlCommentText
(
xmlFilePath
)
),
actual
);
}
#
endregion
Included
names
...
...
@@ -4513,7 +4513,7 @@ class C
}
// As in dev11, the pragma has no effect.
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
,
Skip
=
"https://github.com/dotnet/roslyn/issues/8807"
)]
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
)]
public
void
PragmaDisableWarningInXmlFile
()
{
var
xmlFile
=
Temp
.
CreateFile
(
extension
:
".xml"
).
WriteAllText
(
"&"
);
...
...
@@ -4541,7 +4541,7 @@ class C {{ }}
</members>
</doc>
"
).
Trim
();
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
xmlFile
.
Path
),
actual
);
Assert
.
Equal
(
string
.
Format
(
expectedTemplate
,
TestHelpers
.
AsXmlCommentText
(
xmlFile
.
Path
)
),
actual
);
}
[
Fact
]
...
...
@@ -6145,5 +6145,37 @@ static void Main()
Diagnostic
(
ErrorCode
.
WRN_XMLParseError
,
""
).
WithArguments
(
"summary"
).
WithLocation
(
7
,
1
)
);
}
/// <summary>
/// "--" is not valid within an XML comment.
/// </summary>
[
WorkItem
(
8807
,
"https://github.com/dotnet/roslyn/issues/8807"
)]
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
)]
public
void
IncludeErrorDashDashInName
()
{
var
dir
=
Temp
.
CreateDirectory
();
var
path
=
dir
.
Path
;
var
xmlFile
=
dir
.
CreateFile
(
"---.xml"
).
WriteAllText
(
@"<summary attrib="""" attrib=""""/>"
);
var
source
=
$@"/// <include file='
{
Path
.
Combine
(
path
,
"---.xml"
)}
' path='//summary'/>
class C
{{
}}
"
;
var
comp
=
CreateCompilationWithMscorlibAndDocumentationComments
(
source
);
var
actual
=
GetDocumentationCommentText
(
comp
,
/*ensureEnglishUICulture:*/
true
,
// warning CS1592: Badly formed XML in included comments file -- ''attrib' is a duplicate attribute name.'
Diagnostic
(
ErrorCode
.
WRN_XMLParseIncludeError
).
WithArguments
(
"'attrib' is a duplicate attribute name."
).
WithLocation
(
1
,
1
));
var
expected
=
$@"<?xml version=""1.0""?>
<doc>
<assembly>
<name>Test</name>
</assembly>
<members>
<member name=""T:C"">
<!-- Badly formed XML file ""
{
Path
.
Combine
(
TestHelpers
.
AsXmlCommentText
(
path
),
"- - -.xml"
)}
"" cannot be included -->
</member>
</members>
</doc>"
;
Assert
.
Equal
(
expected
,
actual
);
}
}
}
src/Compilers/CSharp/Test/Symbol/DocumentationComments/DocumentationModeTests.cs
浏览文件 @
fe0f063f
...
...
@@ -42,7 +42,7 @@ public void XmlSyntaxError_Inline()
Diagnostic
(
ErrorCode
.
WRN_XMLParseError
,
""
).
WithArguments
(
"unclosed"
));
}
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
,
Skip
=
"https://github.com/dotnet/roslyn/issues/8807"
)]
[
ClrOnlyFact
(
ClrOnlyReason
.
DocumentationComment
)]
public
void
XmlSyntaxError_Included
()
{
var
xml
=
@"<unclosed>"
;
...
...
@@ -384,7 +384,7 @@ partial class Partial {{ }}
comp
.
GetDiagnostics
().
Verify
(
fallbackToErrorCodeOnlyForNonEnglish
:
fallbackToErrorCodeOnlyForNonEnglish
,
expected
:
makeExpectedDiagnostics
(
includeElement
));
var
actualText
=
GetDocumentationCommentText
(
comp
,
expectedDiagnostics
:
null
);
var
expectedText
=
string
.
Format
(
expectedTextTemplate
,
xmlFilePath
);
var
expectedText
=
string
.
Format
(
expectedTextTemplate
,
TestHelpers
.
AsXmlCommentText
(
xmlFilePath
)
);
Assert
.
Equal
(
expectedText
,
actualText
);
}
...
...
src/Compilers/VisualBasic/Test/Symbol/DocumentationComments/DocCommentTests.vb
浏览文件 @
fe0f063f
...
...
@@ -7359,7 +7359,7 @@ End Class
"Function System.Int32.Parse(s As System.String, style As System.Globalization.NumberStyles, provider As System.IFormatProvider) As System.Int32"
)
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_XPathNotFound_WRN_XMLDocInvalidXMLFragment
()
Dim
xmlText
=
<
root
/>
Dim
xmlFile
=
Temp
.
CreateFile
(
extension
:
=
".xml"
).
WriteAllText
(
xmlText
.
ToString
)
...
...
@@ -7401,11 +7401,11 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
WorkItem
(
684184
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/684184"
)
>
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Bug684184
()
Dim
xmlText
=
<
docs
>
...
...
@@ -7447,10 +7447,10 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_FileNotFound_WRN_XMLDocBadFormedXML
()
Dim
xmlText
=
<
root
/>
Dim
xmlFile
=
Temp
.
CreateFile
(
extension
:
=
".xml"
).
WriteAllText
(
xmlText
.
ToString
)
...
...
@@ -7492,10 +7492,10 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_IOError_WRN_XMLDocBadFormedXML
()
Dim
xmlText
=
<
root
>
<
target
>
Included
</
target
>
...
...
@@ -7541,12 +7541,12 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Using
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_XmlError_WRN_XMLDocBadFormedXML
()
Dim
xmlText
=
<
!
[
CDATA
[
...
...
@@ -7593,10 +7593,10 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_XDocument_WRN_XMLDocInvalidXMLFragment
()
Dim
xmlText
=
<
!
[
CDATA
[
...
...
@@ -7643,10 +7643,10 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_Cycle_WRN_XMLDocInvalidXMLFragment
()
Dim
xmlText
=
<
root
>
...
...
@@ -7677,11 +7677,7 @@ End Class
</
compilation
>
CompileCheckDiagnosticsAndXmlDocument
(
FormatSourceXml
(
xmlSource
,
xmlFile
),
<
error
>
<
!
[
CDATA
[
BC42320
:
Unable
to
include
XML
fragment
'**FILE**' of file '//target'.
]]
>
</
error
>
,
<
error
><
%
=
$
"BC42320: Unable to include XML fragment '{xmlFile.ToString()}' of file '//target'."
%
></
error
>
,
<
xml
>
<
!
[
CDATA
[
<
?
xml
version
=
"1.0"
?
>
...
...
@@ -7709,10 +7705,10 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
Fact
(
Skip
:
=
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
Include_XPathError_WRN_XMLDocBadFormedXML
()
Dim
xmlText
=
<
!
[
CDATA
[
...
...
@@ -7759,7 +7755,7 @@ AssemblyName
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
xmlFile
.
ToString
(
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
AsXmlCommentText
(
xmlFile
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
<
Fact
>
...
...
@@ -11884,6 +11880,10 @@ xmlDoc)
Return
If
(
str
Is
Nothing
,
obj
,
str
.
Replace
(
what
,
[
with
]
))
End
Function
Private
Shared
Function
AsXmlCommentText
(
file
As
TempFile
)
As
String
Return
TestHelpers
.
AsXmlCommentText
(
file
.
ToString
())
End
Function
Private
Function
FormatSourceXml
(
xml
As
XElement
,
ParamArray
obj
()
As
Object
)
As
XElement
For
Each
file
In
xml
.
<
file
>
file
.
Value
=
String
.
Format
(
file
.
Value
,
obj
)
...
...
@@ -12328,5 +12328,46 @@ BC42304: XML documentation parse error: Expected beginning '<' for an XML tag. X
]]
>
)
End
Sub
''' <summary>
''' "--" is not valid within an XML comment.
''' </summary>
<
WorkItem
(
8807
,
"https://github.com/dotnet/roslyn/issues/8807"
)
>
<
Fact
>
Public
Sub
IncludeErrorDashDashInName
()
Dim
dir
=
Temp
.
CreateDirectory
()
Dim
path
=
dir
.
Path
Dim
xmlFile
=
dir
.
CreateFile
(
"---.xml"
).
WriteAllText
(
"<summary attrib=
""""
attrib=
""""
/>"
)
Dim
source
=
<
compilation
name
=
"DashDash"
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
''' <include file='{0}' path='//param'/>
Class
C
End
Class
]]
>
</
file
>
</
compilation
>
CompileCheckDiagnosticsAndXmlDocument
(
FormatSourceXml
(
source
,
System
.
IO
.
Path
.
Combine
(
path
,
"---.xml"
)),
<
error
/>
,
<
xml
>
<
!
[
CDATA
[
<
?
xml
version
=
"1.0"
?
>
<
doc
>
<
assembly
>
<
name
>
DashDash
</
name
>
</
assembly
>
<
members
>
<
member
name
=
"T:C"
>
<
!
--
warning
BC42320
:
Unable
to
include
XML
fragment
'//param' of file '**FILE**'.-->
</
member
>
</
members
>
</
doc
>
]]
>
</
xml
>
,
stringMapper
:
=
Function
(
o
)
StringReplace
(
o
,
System
.
IO
.
Path
.
Combine
(
TestHelpers
.
AsXmlCommentText
(
path
),
"- - -.xml"
),
"**FILE**"
),
ensureEnglishUICulture
:
=
True
)
End
Sub
End
Class
End
Namespace
src/Test/Utilities/Desktop/TestHelpers.cs
浏览文件 @
fe0f063f
...
...
@@ -3,9 +3,11 @@
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Globalization
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.Diagnostics
;
...
...
@@ -123,5 +125,25 @@ public class TestAnalyzer : DiagnosticAnalyzer
return
dir
.
CreateFile
(
assemblyName
+
".dll"
).
WriteAllBytes
(
analyzerCompilation
.
EmitToArray
());
}
/// <summary>
/// <see cref="System.Xml.Linq.XComment.Value"/> is serialized with "--" replaced by "- -"
/// </summary>
public
static
string
AsXmlCommentText
(
string
text
)
{
var
builder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
text
.
Length
;
i
++)
{
var
c
=
text
[
i
];
if
((
c
==
'-'
)
&&
(
i
>
0
)
&&
(
text
[
i
-
1
]
==
'-'
))
{
builder
.
Append
(
' '
);
}
builder
.
Append
(
c
);
}
var
result
=
builder
.
ToString
();
Debug
.
Assert
(!
result
.
Contains
(
"--"
));
return
result
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录