csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Lambda argument unexpected formatting on exactly max length line

Open ovska opened this issue 7 months ago • 1 comments

Print width 120 (you can paste the example to https://playground.csharpier.com/)

Input:

public class ClassName
{
    public static int Run()
    {
        await Assert.ThrowsAsync<IOException>(async () => await writer.FlushAsync(TestContext.Current.CancellationToken));
    }
}

Output:

public class ClassName
{
    public static int Run()
    {
        await Assert.ThrowsAsync<IOException>(async () => await writer.FlushAsync(TestContext.Current.CancellationToken)
        );
    }
}

Expected behavior:

public class ClassName
{
    public static int Run()
    {
        await Assert.ThrowsAsync<IOException>(
            async () => await writer.FlushAsync(TestContext.Current.CancellationToken)
        );
    }
}

or

public class ClassName
{
    public static int Run()
    {
        await Assert.ThrowsAsync<IOException>(async () => await writer.FlushAsync(TestContext.Current.CancellationToken));
    }
}

ovska avatar Jun 04 '25 13:06 ovska

My hope is that resolving #1613 will also resolve this

belav avatar Jun 06 '25 14:06 belav

I'm unable to reproduce this. I did notice that the playground was still running 1.0.0 which was unable to reproduce it. I was also unable to reproduce it after updating the playground to 1.0.2.

belav avatar Jun 29 '25 16:06 belav

Updating the version in dotnet-tools.json from 1.0.1 to 1.0.3 fixes it in the CLI, however the VS Code extension might still be using an older version as it formats the file a bit differently. Perhaps this is just a matter of pushing the newest version to the extension

ovska avatar Jun 30 '25 06:06 ovska

The VSCode extension will use the version from dotnet-tools.json when it finds an appropriate one. It will fall back to using the global version of csharpier if one is installed. Perhaps you need to update the global version.

Also the extensions don't detect when you update csharpier yet. I've been meaning to add that feature for a while now but never find the time. So if you updating csharpier with vscode open it could still be using the older version for some files.

belav avatar Jul 04 '25 15:07 belav

Thanks, the problem was a globally installed 0.30.6 overriding dotnet-tools.

ovska avatar Jul 04 '25 19:07 ovska