-
Notifications
You must be signed in to change notification settings - Fork 158
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
Fix template list parsing on non-English systems #826
Conversation
Thanks! Could you try adding a test to ensure we don't regress here? The tests for templates are here, and I think a good test would:
the tests can be run with |
I agree that adding a regression test is important. But I'm hitting a roadblock, as I don't know .NET well for the time being. I've tried setting Do you know how to do this? |
Since new processes inherit their environment from their parents, I was thinking that you could use it might look something like // save previous env
let priorEnv = System.Environment.GetEnvironmentVariable "DOTNET_CLI_UI_LANGUAGE"
// set env for this call
System.Environment.SetEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US")
// perform the test call
let templates = ....... // actual code goes here
// whatever the assertions are would go here
......
// put the old state back for the remainder of the tests
System.Environment.SetEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", priorEnv) there might be some null-checking required there, but that's about what I was thinking. |
To list the available templates, FSAC parses directly the output of `dotnet new --list`, looking for predefined English words. But if the configured display language / locale of the system is another language (e.g. French or German), this parsing fails and generates an out-of-bounds exception. This commit takes the simplest route to fix the problem: forcing `dotnet` to print its output in English by setting a documented environment variable[1]. Fixes ionide/ionide-vscode-fsharp#1569 [1] https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_cli_ui_language
a2d7483
to
ebed694
Compare
I wasn't thinking of the Testing definitely was a good idea as my initial fix was wrong! :-) |
This changeset looks great, I especially appreciate how you made the |
Your new tests look like they're passing just fine. I'll go ahead and merge this and we'll start working on a release with it soon. Thanks again for being willing to make this fix! |
Thanks for guiding me! |
This has been released in FSAC 0.47.2 |
To list the available templates, FSAC parses directly the output of
dotnet new --list
, looking for predefined English words. But if the configured display language / locale of the system is another language (e.g. French or German), this parsing fails and generates an out-of-bounds exception.This commit takes the simplest route to fix the problem: forcing
dotnet
to print its output in English by setting a documented environment variable[1].Fixes ionide/ionide-vscode-fsharp#1569
[1] https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_cli_ui_language