dotnet/roslyn

Formatter doesn't increase ident in multiline list patterns correctly

Open

#73,251 创建于 2024年4月27日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)C# (4,257 fork)batch import
Area-IDEBughelp wanted

仓库指标

Star
 (20,414 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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

贡献者指南