KirillOsenkov / RoslynQuoter

Roslyn tool that for a given C# program shows syntax tree API calls to construct its syntax tree
http://roslynquoter.azurewebsites.net
Apache License 2.0
918 stars 118 forks source link

Colon at BaseConstructorInitializer wrong #65

Open p-bojkowski opened 3 years ago

p-bojkowski commented 3 years ago

Hi!

RoslynQuoter generate for this:


public class CLASS_NAME : ClassTemplateBase
{
    public CLASS_NAME() : base()
    {

    }
}

Result:

CompilationUnit()
.WithMembers(
    SingletonList<MemberDeclarationSyntax>(
        ClassDeclaration("CLASS_NAME")
        .WithModifiers(
            TokenList(
                Token(SyntaxKind.PublicKeyword)))
        .WithBaseList(
            BaseList(
                SingletonSeparatedList<BaseTypeSyntax>(
                    SimpleBaseType(
                        IdentifierName("ClassTemplateBase")))))
        .WithMembers(
            SingletonList<MemberDeclarationSyntax>(
                ConstructorDeclaration(
                    Identifier("CLASS_NAME"))
                .WithModifiers(
                    TokenList(
                        Token(SyntaxKind.PublicKeyword)))
                .WithInitializer(
                    ConstructorInitializer(
                        SyntaxKind.BaseConstructorInitializer,
                        ArgumentList()))
                .WithBody(
                    Block())))))
.NormalizeWhitespace()

What result with this:


public class CLASS_NAME : ClassTemplateBase
{
    public CLASS_NAME(): base()
    {

    }
}

The position of the colon is wrong


CLASS_NAME(): base()

it should be:


CLASS_NAME() : base()

like in the class declaration.

bernd5 commented 3 years ago

That is an issue in NormalizeWhitespace() - not in the quoter... Please open an issue at dotnet/roslyn

p-bojkowski commented 3 years ago

Done! https://github.com/dotnet/roslyn/issues/53254

KirillOsenkov commented 3 years ago

This was fixed in Roslyn: https://github.com/dotnet/roslyn/pull/53326

Leaving this bug open to track updating to a version of Roslyn that has that fix ^^