dotnet/roslyn
View on GitHubNormalizeWhitespace does not automatically insert a newline after documentation
Open
#50,626 opened on Jan 20, 2021
Area-CompilersBughelp wanted
Repository metrics
- Stars
- (20,414 stars)
- PR merge metrics
- (Avg merge 6d 17h) (256 merged PRs in 30d)
Description
Version Used: Mircrosoft.CodeAnalysis.Common : 4.0.30319
Steps to Reproduce:
- Emit a method using the following declaration:
MethodDeclaration(
PredefinedType(
Token(SyntaxKind.IntKeyword)),
Identifier("Method"))
.WithAttributeLists(
SingletonList(
AttributeList(
SingletonSeparatedList<AttributeSyntax>(
Attribute(
IdentifierName("Pure"))))
.WithOpenBracketToken(
Token(
TriviaList(
Trivia(
DocumentationCommentTrivia(
SyntaxKind.SingleLineDocumentationCommentTrivia,
SingletonList<XmlNodeSyntax>(
XmlText()
.WithTextTokens(
TokenList(
new []{
XmlTextLiteral(
TriviaList(
DocumentationCommentExterior("///")),
" Some cool documentation",
" Some cool documentation",
TriviaList())})))))),
SyntaxKind.OpenBracketToken,
TriviaList()))))
.WithModifiers(
TokenList(
Token(SyntaxKind.PublicKeyword)))
.WithBody(
Block(
SingletonList<StatementSyntax>(
ReturnStatement(
LiteralExpression(
SyntaxKind.NumericLiteralExpression,
Literal(1))))))
.NormalizeWhitespace());
Expected Behavior: Should automatically output a new line after the documentation
/// Some cool documentation
[Pure]
public int Method()
{
return 1;
}
Actual Behavior: Does not output a new line after the documentation
/// Some cool documentation[Pure]
public int Method()
{
return 1;
}
Manually adding a XmlTextNewLine token at the end of the documentation resolves the issue, not sure if this is the intended behavior.