提交 e4421e82 编写于 作者: A AlekseyTs

Add unit-tests to ensure that unterminated element in XML Doc comment doesn’t...

Add unit-tests to ensure that unterminated element in XML Doc comment doesn’t cause compilation failure.
上级 9dd256f4
......@@ -6118,5 +6118,31 @@ class Module1
}
#endregion Dev10 bugs
[Fact, WorkItem(1115058, "DevDiv")]
public void UnterminatedElement()
{
var source = @"
class Module1
{
///<summary>
/// Something
///<summary>
static void Main()
{
System.Console.WriteLine(""Here"");
}
}";
var comp = CreateCompilationWithMscorlibAndDocumentationComments(source, options: TestOptions.ReleaseExe);
CompileAndVerify(comp, expectedOutput: "Here").VerifyDiagnostics(
// (7,1): warning CS1570: XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'
// static void Main()
Diagnostic(ErrorCode.WRN_XMLParseError, "").WithArguments("summary").WithLocation(7, 1),
// (7,1): warning CS1570: XML comment has badly formed XML -- 'Expected an end tag for element 'summary'.'
// static void Main()
Diagnostic(ErrorCode.WRN_XMLParseError, "").WithArguments("summary").WithLocation(7, 1)
);
}
}
}
......@@ -12282,5 +12282,51 @@ EmptyCref
Assert.Equal("?", symbolInfo.Symbol.ToTestDisplayString())
End Sub
<Fact, WorkItem(1115058, "DevDiv")>
Public Sub UnterminatedElement()
Dim sources =
<compilation>
<file name="a.vb">
<![CDATA[
Module Module1
'''<summary>
''' Something
'''<summary>
Sub Main()
System.Console.WriteLine("Here")
End Sub
End Module
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlibAndVBRuntime(
sources,
options:=TestOptions.ReleaseExe,
parseOptions:=TestOptions.Regular.WithDocumentationMode(DocumentationMode.Diagnose))
' Compilation should succeeed with warnings
AssertTheseDiagnostics(CompileAndVerify(compilation, expectedOutput:="Here").Diagnostics, <![CDATA[
BC42304: XML documentation parse error: Element is missing an end tag. XML comment will be ignored.
'''<summary>
~~~~~~~~~
BC42304: XML documentation parse error: Element is missing an end tag. XML comment will be ignored.
'''<summary>
~~~~~~~~~
BC42304: XML documentation parse error: '>' expected. XML comment will be ignored.
'''<summary>
~
BC42304: XML documentation parse error: '>' expected. XML comment will be ignored.
'''<summary>
~
BC42304: XML documentation parse error: Expected beginning '<' for an XML tag. XML comment will be ignored.
'''<summary>
~
BC42304: XML documentation parse error: Expected beginning '<' for an XML tag. XML comment will be ignored.
'''<summary>
~
]]>)
End Sub
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册