belav / csharpier

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

Losing code in pattern matching list (capturing remaining elements) #1205

Closed maghis closed 8 months ago

maghis commented 8 months ago

Csharpier version: 0.27.3

Before formatting:

public static void TestMethod(int[] testList)
{
    if (testList is [var first, .. var rest])
    {
        // ...
    }
}

After formatting:

public static void TestMethod(int[] testList)
{
    if (testList is [var first, ..])
    {
        // ...
    }
}

The capture for the remaining elements of the list var rest disappears from the formatted code, breaking the build.

belav commented 8 months ago

This is formatted without losing any code on https://playground.csharpier.com/

if (testList is [var first, .. var rest])
{
    // ...
}

Are you sure you are using 0.27.3?

maghis commented 8 months ago

Apologies, I just realized that in my project there was a version override that was keeping me on 0.21 (globally I was up-to-date). Closing this.