Additional tab white space on XML comment leading trivia if Attribute is added prior
See original GitHub issueI am currently working on this PR for CsWin32: https://github.com/microsoft/CsWin32/pull/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?
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Is there any way to preserve white space in C# XML ...
I used <br /> to indicate individual new lines (this works as of VS 2019), but I can't insert spaces or tabs. I...
Read more >SyntaxFactory Class (Microsoft.CodeAnalysis.CSharp)
Determines if two syntax nodes are the same, disregarding trivia differences. ... Creates an xml documentation comment that abstracts xml syntax creation.
Read more >XML Schema Restrictions/Facets
Restrictions are used to define acceptable values for XML elements or attributes. Restrictions on XML elements are called facets.
Read more >Creating an Editable Textarea That Supports Syntax- ...
We can add some CSS that basically allows the <textarea> and the <pre><code> elements to be sized and spaced consistently. #editing, # ...
Read more >A Roadmap to XML Parsers in Python
In this tutorial, you'll learn what XML parsers are available in Python and how to pick the right parsing model for your specific...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not seeing this line being hit with
typeDeclaration
corresponding toPInvoke
in testTestSimpleMethod
. Can you confirm?It looks like trivia is messed up at
WhitespaceRewriter
Hope https://github.com/elachlan/CsWin32/pull/1 corrects the implementation 😃