Skip to content

Collection expression inside a dictionary adds unexpected new line #1390

@SigtryggurO

Description

@SigtryggurO

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",
        ]
    },
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions