dotnet/roslyn

Formatter doesn't increase ident in multiline list patterns correctly

Open

#73,251 opened on 2024年4月27日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-IDEBughelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Found while working on a compiler PR (link)

Version Used: VS 17.10.0 Preview 5.0

Steps to Reproduce: Run formatter on this code:

MyClass[] arr = [new()];

if (arr is
    [
    {
        Prop: 1,
        AnotherProp: 2
    }
    ])
{

}

class MyClass
{
    public int Prop { get; set; }

    public int AnotherProp { get; set; }
}

Expected Behavior:

MyClass[] arr = [new()];

if (arr is
    [
        {
            Prop: 1,
            AnotherProp: 2
        }
    ])
{

}

class MyClass
{
    public int Prop { get; set; }

    public int AnotherProp { get; set; }
}

Actual Behavior: Quite the opposite - when I run formatting on correct code, it dedents it back: formatterBug

コントリビューターガイド