belav / csharpier

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

Comma insertion with a comment suffix #1356

Closed Hona closed 1 month ago

Hona commented 1 month ago

@belav

Currently we get a line break and the comma inserted, I think it would be simpler to add the comma before the comment.

Thoughts?

Input:

var option = Options.A;

var value = option switch
{
    Options.A => "A",
    Options.B => "B",
    Options.C => "C" // comment line

};

public enum Options
{
    A,
    B,
    C,
}

Output:

var option = Options.A;

var value = option switch
{
    Options.A => "A",
    Options.B => "B",
    Options.C =>
        "C" // comment line
    ,
};

public enum Options
{
    A,
    B,
    C,
}

Expected behavior:

var option = Options.A;

var value = option switch
{
    Options.A => "A",
    Options.B => "B",
    Options.C => "C", // comment line
};

public enum Options
{
    A,
    B,
    C,
}
Hona commented 1 month ago

Ah, duplicate of https://github.com/belav/csharpier/issues/1354 . Sorry.