belav / csharpier

CSharpier is an opinionated code formatter for c#.
https://csharpier.com
MIT License
1.41k stars 98 forks source link

Collection expression inside a dictionary adds unexpected new line #1390

Open SigtryggurO opened 10 hours ago

SigtryggurO commented 10 hours ago

Running on csharpier 0.30.1

Input:

static Dictionary<string, string[]> dictionary = new()
{
    {
        "Key",
        [
            "ItemWithLongEnoughNameToNotJoin1",
            "ItemWithLongEnoughNameToNotJoin2",
            "ItemWithLongEnoughNameToNotJoin3",
            "ItemWithLongEnoughNameToNotJoin4",
        ]
    },
};

Output:

static Dictionary<string, string[]> dictionary = new()
{
    {
        "Key",

        [
            "ItemWithLongEnoughNameToNotJoin1",
            "ItemWithLongEnoughNameToNotJoin2",
            "ItemWithLongEnoughNameToNotJoin3",
            "ItemWithLongEnoughNameToNotJoin4",
        ]
    },
};

Expected behavior:

static Dictionary<string, string[]> dictionary = new()
{
    {
        "Key",
        [
            "ItemWithLongEnoughNameToNotJoin1",
            "ItemWithLongEnoughNameToNotJoin2",
            "ItemWithLongEnoughNameToNotJoin3",
            "ItemWithLongEnoughNameToNotJoin4",
        ]
    },
};