belav / csharpier

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

Empty Collection Expression failed to format #1122

Closed mahmoudmahm00d closed 10 months ago

mahmoudmahm00d commented 10 months ago

Environments

Log Output In VSCode Log: ["INFO" - 10:47:07 PM] File is ignored by .csharpierignore or there was an error

In CLI tool log: Failed to compile so was not formatted. (11,51): error CS1525: Invalid expression term '[' (11,52): error CS0443: Syntax error; value expected (15,37): error CS1525: Invalid expression term '[' (15,38): error CS0443: Syntax error; value expected

Expected behavior Format the document

Actual behavior nothing change.

belav commented 10 months ago

There is no version 1.5.2 of CSharpier. My guess is you are on a version of CSharpier prior to 0.26 which is when collection expressions were supported.

If you have it installed globally you can run dotnet tool upgrade csharpier -g or maybe update I don't recall without double checking.

DarkStoorM commented 10 months ago

There is no version 1.5.2 of CSharpier. My guess is you are on a version of CSharpier prior to 0.26 which is when collection expressions were supported.

If you have it installed globally you can run dotnet tool upgrade csharpier -g or maybe update I don't recall without double checking.

1.5.2 is the latest extension version on the VS marketplace, I had to manually run dotnet tool update csharpier -g to update from 0.25 to 0.27, the collection expressions are not working on that version and are causing it to fail. I guess the one on the marketplace is behind?

belav commented 10 months ago

1.5.2 is the latest version. You may have installed 0.25.0 when you first downloaded the extension, or you already had CSharpier installed globally before installing the extension.

The extension currenly lacks the ability to know when you update CSharpier, so if you had VSCode running when updating CSharpier you'd have to restart it.

It also lacks information about what version of CSharpier it is using to format a file. I think that may be in the debug logs somewhere. Both are things I hope to improve.