Version Used: 3.7.0
Steps to Reproduce:
Run the following code:
string code = @"
/// <example>
/// <code lang=""cs"" source=""foo.cs"" />
/// </example>
class Foo {}";
var tree = SyntaxFactory.ParseSyntaxTree(code);
tree = tree.WithRootAndOptions(tree.GetRoot().NormalizeWhitespace(), tree.Options.WithDocumentationMode(DocumentationMode.Diagnose));
var compilation = CSharpCompilation.Create(null)
.WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
.AddSyntaxTrees(tree)
.AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location));
var diagnostics = compilation.GetDiagnostics();
Expected Behavior:
No warnings.
Actual Behavior:
warning CS1570: XML comment has badly formed XML -- ''source' is an unexpected token. Expecting whitespace. Line 2, position 32.'
This seems to happen because NormalizeWhitespace() changes the code to:
/// <example>
/// <code lang = "cs"source = "foo.cs"/>
/// </example>
class Foo
{
}
Notice how there is no space before the source attribute, which is invalid XML.
Also, when running this code under a Debug build of the compiler on .Net Core, the following assertion is triggered:
|
Debug.Assert(false, "If we hit this, then we might need to think about a different workaround " + |
|
"for stripping the location out the message."); |
Version Used: 3.7.0
Steps to Reproduce:
Run the following code:
Expected Behavior:
No warnings.
Actual Behavior:
This seems to happen because
NormalizeWhitespace()changes the code to:Notice how there is no space before the
sourceattribute, which is invalid XML.Also, when running this code under a Debug build of the compiler on .Net Core, the following assertion is triggered:
roslyn/src/Compilers/CSharp/Portable/Compiler/DocumentationCommentCompiler.cs
Lines 1233 to 1234 in 4eca967