belav / csharpier

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

How do you ignore formatting attributes? #1140

Closed parched closed 10 months ago

parched commented 10 months ago

I'm trying to figure out how to stop csharpier from formatting a bunch of attributes. I tried what's shown below, but I understand that doesn't work because cshaprier-ignore-start only applies when "A range is valid around statements and members".

How should I do it?

Also, it would be great if chsarpier supported #pragma warning disable format. I seem to need that anyway to stop VS from removing the whitespace

Input:

    [Theory]
    // csharpier-ignore-start
#pragma warning disable format
    //          start,       end,         yAxisRef       expectedRef
    [InlineData(0, 0,  0,    1, 0,  0,     0,  0,  1,    "Z")]
    [InlineData(0, 0,  0,    1, 0,  0,     0,  1,  0,    "Y")]
    [InlineData(0, 0,  0,    0, 1,  0,     1,  0,  0,    "X")]
    [InlineData(0, 0,  0,    1, 0,  0,     0,  0, -1,    "-Z")]
    [InlineData(0, 0,  0,    1, 0,  0,     0, -1,  0,    "-Y")]
    [InlineData(0, 0,  0,    0, 1,  0,    -1,  0,  0,    "-X")]
    [InlineData(0, 0,  0,    1, 0,  0,   0.5,  0,  1,    "Z")]
    [InlineData(0, 0,  0,    1, 0,  0,  -0.5,  0,  1,    "Z")]
    [InlineData(0, 0,  0,    1, 0, 10,     0,  0,  1,    "Z")]
    [InlineData(0, 0,  0,    1, 0, 10,    -1,  0,  0,    "Z")]
    [InlineData(0, 0,  0,    1, 0,  0,     0,  1,  1,    "0, 0.707, 0.707")]
    [InlineData(0, 0, 10,    1, 0, 10,     0,  1,  1,    "0, 0.707, 10.707")]
#pragma warning restore format
    // csharpier-ignore-end
    public void ToArc_ReturnsArcMember(

Output: Extra whitespace is removed.

Expected behavior: unchanged

belav commented 10 months ago

CSharpier doesn't have a good way to ignore just a set of attributes. #992 is a duplicate.