Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

 the syntax of C # 12 is not fully supported, and there are issues with the known Collection expressions #1430

Closed
xzf888 opened this issue Jan 9, 2025 · 4 comments

Comments

@xzf888
Copy link

xzf888 commented Jan 9, 2025

When it appears in the code Unable to format

internal class Program
{
private static void Main(string[] args)
{
List Files = ["12"];
var i = Files.Count;
Console.WriteLine(i);
}
}

["DEBUG" - 10:34:18] Ensure there is a csharpier process for d:\TEST
["WARN" - 10:34:18] Received data on stderr from the running charpier process
"Error d:\TEST\Program.cs - Failed to compile so was not formatted.\r\n (6,30): error CS1525: 表达式项“[”无效\r\n"
["INFO" - 10:34:18] File is ignored by .csharpierignore or there was an error

@xzf888
Copy link
Author

xzf888 commented Jan 9, 2025

The above code was escaped incorrectly, the following is the correct code
internal class Program { private static void Main(string[] args) { List<string> Files = ["12"]; var i = Files.Count; Console.WriteLine(i); } }

@belav
Copy link
Owner

belav commented Jan 9, 2025

You are more than likely not on the latest csharpier. Collection expressions have been supported for a while now. 0.30.5 is the latest. You can test your code on playground.csharpier.com to see that it works.

@xzf888
Copy link
Author

xzf888 commented Jan 9, 2025

The VSCode extension is the latest, but I don't know why it doesn't work. I searched for the answer to the previous question and deleted the C: \Users\xzf\AppData\Local\CSharpier folder. After reinstalling the extension, it worked fine

@xzf888 xzf888 closed this as completed Jan 9, 2025
@belav
Copy link
Owner

belav commented Jan 9, 2025

The VSCode extension is versioned separately. It works with any version of csharpier. Csharpier is a dotnet tool that can be installed globally or locally to a project. The extension will prompt you to install csharpier if it doesn't find the tool and installs the latest at that time.

https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools has all the information about how to manage, install and update tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants