belav / csharpier

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

Inconsistent placement of end parenthesis #1079

Closed loraderon closed 10 months ago

loraderon commented 11 months ago

Using the latest 0.26.7 in the playground that reverted #1010, there are some inconsistencies in the intentation of the method call and primarily the end parenthesis ).

Input:

public class ClassName
{
    public void Test()
    {
        var foo = new { Bars = new string[0] };

        foo.Bars.Select(s => s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()).ToArray();

        foo.Select(s => s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()).ToArray();
    }
}

Output:

public class ClassName
{
    public void Test()
    {
        var foo = new { Bars = new string[0] };

        foo.Bars.Select(
            s => s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()
        )
            .ToArray();

        foo.Select(
                s => s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()
            )
            .ToArray();
    }
}

Expected behavior:

Either

        foo.Bars.Select(
                s => s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()
            )
            .ToArray();

Or

        foo.Bars.Select(
            s => s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()
        )
        .ToArray();
loraderon commented 10 months ago

I have verified that this now works correctly in 0.27.1 🎉

Output in the playground:

public class ClassName
{
    public void Test()
    {
        var foo = new { Bars = new string[0] };

        foo
            .Bars.Select(s =>
                s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()
            )
            .ToArray();

        foo.Select(s =>
                s.ToString().ToString().ToString().ToString().ToString().ToString().ToString()
            )
            .ToArray();
    }
}