Skip to content

Switch expression single line broken when preceded by comment #1262

@charliefoxtwo

Description

@charliefoxtwo

Version 0.28.2

Input:

public class ClassName {
    private static void Foo(Bar bar)
    {
        var y = bar switch
        {
            // comment
            Bar.A => 1,
            Bar.B => 2,
        };

        var z = bar switch
        {
            Bar.A => 1,
             // comment
            Bar.B => 2,
        };
    }

    enum Bar
    {
        A,
        B,
    }
}

Output:

public class ClassName
{
    private static void Foo(Bar bar)
    {
        var y = bar switch
        {
            // comment
            Bar.A
                => 1,
            Bar.B => 2,
        };

        var z = bar switch
        {
            Bar.A => 1,
            // comment
            Bar.B
                => 2,
        };
    }

    enum Bar
    {
        A,
        B,
    }
}

Expected behavior:
input should not be changed, and switch cases preceded by a comment should not be broken into separate lines.

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