belav / csharpier

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

csharpier-ignore-start comment ignored between attributes #1368

Closed maurobringolf closed 1 hour ago

maurobringolf commented 1 hour ago

Input:

public class A {
    [X]
    // csharpier-ignore-start
    [Y(1,"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")]
    // csharpier-ignore-end
    public A M() {}
}

Output:

Breaks line between attribute arguments

public class A
{
    [X]
    // csharpier-ignore-start
    [Y(
        1,
        "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
    )]
    // csharpier-ignore-end
    public A M() { }
}

Expected behavior:

Unchanged:

public class A {
    [X]
    // csharpier-ignore-start
    [Y(1,"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")]
    // csharpier-ignore-end
    public A M() {}
}

Note: When you place // csharpier-ignore-start above the first attribute [X] it works as expected.

maurobringolf commented 1 hour ago

Ah sorry, I only saw the line "This is valid on statements and members." in the documentation now. So I guess placing it before [X] makes links the comment to the member instead of the attribute and that is why it works in that case.