belav / csharpier

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

Fixing issues with weird indent on raw string literals as arguments #1175

Closed belav closed 9 months ago

belav commented 9 months ago

closes #1169

belav commented 9 months ago

I fixed the extra indent, but there is also the problem of the arguments not breaking properly. It looks like this problem also exists for multiline verbatim strings so it has been here for a while. I have the problem somewhat narrowed down, so hopefully can fix it within this PR

// input/expected output
CallMethod(
    """
    SomeRawString
    """.CallMethod().CallMethod()
);

CallMethod(
    @"
    SomeVerbatimString
    ".CallMethod().CallMethod()
);

// actual output
CallMethod("""
    SomeRawString
    """.CallMethod().CallMethod());

CallMethod(@"
    SomeVerbatimString
    ".CallMethod().CallMethod());

The problem is more apparent with multiple arguments


// input/expected output
CallMethod(
    """
    SomeRawString
    """.CallMethod().CallMethod(),
    []
);

// actual output
CallMethod("""
    SomeRawString
    """.CallMethod().CallMethod(), []);