belav / csharpier

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

`readonly ref` is changed to `ref readonly` causing error CS9190 #1123

Closed aurnoi1 closed 10 months ago

aurnoi1 commented 10 months ago

Hi,

When running chsharpier, readonly ref is changed to ref readonly causing error CS9190.

Version dotnet: net8.0 Version csharpier: 0.26.7

Input:

    public static Result<int> DoSomething(ref readonly Result<int> result)
    {
        return result;
    }

Output:

    public static Result<int> DoSomething(readonly ref Result<int> result)
    {
        return result;
    }

Expected behavior:

    public static Result<int> DoSomething(ref readonly Result<int> result)
    {
        return result;
    }

Thanks!

belav commented 10 months ago

I modified the sorting modifiers logic to only run on specific nodes to hopefully prevent something like this in the future. Thanks for reporting the problem, it'll be fixed in the coming release!

aurnoi1 commented 10 months ago

I confirmed that the but is fixed on my side in the last version 0.27.1. Thanks!