dotnet/roslyn

NormalizeWhitespace incorrectly adds space after comma between omitted nodes

開放

#34,565 建立於 2019年3月28日

 (2 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-CompilersFeature Requesthelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

Version Used: 3.0.0-beta4-final

Steps to Reproduce:

Run the following program:

using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;

class Program
{
    static void Main()
    {
        var type = ArrayType(PredefinedType(Token(SyntaxKind.IntKeyword)))
            .WithRankSpecifiers(SingletonList(ArrayRankSpecifier(
                SeparatedList<ExpressionSyntax>(
                    new[] { OmittedArraySizeExpression(), OmittedArraySizeExpression()}))));

        Console.WriteLine(type);
        Console.WriteLine(type.NormalizeWhitespace());

        var expression = TypeOfExpression(GenericName(Identifier("Dictionary"))
                .WithTypeArgumentList(TypeArgumentList(SeparatedList<TypeSyntax>(
                    new[] { OmittedTypeArgument(), OmittedTypeArgument()}))));

        Console.WriteLine(expression);
        Console.WriteLine(expression.NormalizeWhitespace());
    }
}

Expected Behavior:

NormalizeWhitespace does not add any whitespace here, so the program prints:

int[,]
int[,]
typeof(Dictionary<,>)
typeof(Dictionary<,>)

Actual Behavior:

int[,]
int[, ]
typeof(Dictionary<,>)
typeof(Dictionary<, >)

貢獻者指南