Skip to content

Additional tab white space on XML comment leading trivia if Attribute is added prior #63227

@elachlan

Description

@elachlan

I am currently working on this PR for CsWin32: microsoft/CsWin32#621

We have this code that causes the xml comment to have an extra leading tab white space:

typeDeclaration = typeDeclaration
                    .WithLeadingTrivia()
                    .AddAttributeLists(AttributeList().AddAttributes(GeneratedCodeAttribute))
                    .WithLeadingTrivia(typeDeclaration.GetLeadingTrivia());

typeDeclaration is MemberDeclarationSyntax.

The generated code attribute is:

private static readonly AttributeSyntax GeneratedCodeAttribute = Attribute(IdentifierName("global::System.CodeDom.Compiler.GeneratedCode"))
        .WithArgumentList(FixTrivia(AttributeArgumentList().AddArguments(
            AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(ThisAssembly.AssemblyName))),
            AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(ThisAssembly.AssemblyInformationalVersion))))));

If we do not add the attribute, then the leading trivia xml comment is formatted correctly.

Am I missing something obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersBughelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions