FXVersion.TryParse fails to parse version on Thai culture
See original GitHub issueProblem
Steps to reproduce, on UNIX machine:
LANG=th_TH.UTF-8 dotnet new
this will print: https://gist.github.com/DavidKarlas/29a0749d371be2858ea629a3c66d26fb
Unfortunately on Windows its not so easy to reproduce, but I have this example:
CultureInfo.CurrentCulture = new CultureInfo("th-TH");
Console.WriteLine("55.66.77.88".IndexOf("."));
Which prints 0
instead of 2
.
And this is where FXVersion parsing fails: https://github.com/dotnet/sdk/blob/a5bda50/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/FXVersion.cs#L237 because it tries to parse empty string.
I just want to add this is not just dotnet new
problem, similar issue can be reproduced with LANG=th_TH.UTF-8 dotnet build
which will print https://gist.github.com/DavidKarlas/a16d14224ad993e71f2b45a0b2103015
And I believe it will also be problem on Windows when user has Thai(or some other similar culture set) as Windows language/culture.
Solution
Use .IndexOf('.', , StringComparison.Ordinal)
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
@wli3 you should enable CA1307 and CA1309 (at least locally) to look for other cases https://github.com/dotnet/docs/issues/21249
Ah, sorry, I thought it was by design. Reopening