belav / csharpier

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

Invalid blank line being added with lambda returning collection expression #1306

Closed ShawnTheBeachy closed 3 months ago

ShawnTheBeachy commented 4 months ago

Input:

public sealed class Demo
{
    private void Foo()
    {
        var sub = Substitute.For<IFoo>();
        sub.Bar()
            .Returns(_ =>
                [
                    Guid.Parse("90a34545-5030-4251-8e5b-355c2d1e322e"),
                    Guid.Parse("30c0932b-4563-4a46-8577-3c285addfa69")
                ]
            );
    }

    private interface IFoo
    {
        IReadOnlyList<Guid> Bar();
    }
}

Output:

public sealed class Demo
{
    private void Foo()
    {
        var sub = Substitute.For<IFoo>();
        sub.Bar()
            .Returns(_ =>

                [
                    Guid.Parse("90a34545-5030-4251-8e5b-355c2d1e322e"),
                    Guid.Parse("30c0932b-4563-4a46-8577-3c285addfa69")
                ]
            );
    }

    private interface IFoo
    {
        IReadOnlyList<Guid> Bar();
    }
}

Expected behavior: The blank line on line 8 should not be there.