-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fallback gracefully when running on runtimes that only support the Invariant culture #70096
Conversation
@dotnet/roslyn-ide @davidwengier @dibarbet for this simple resiliency pr on some stripped down distros. |
{ | ||
// See https://github.com/microsoft/vscode-dotnettools/issues/386 | ||
// This can happen when running on a runtime that is setup for culture invariant mode only. | ||
EnUSCultureInfo = CultureInfo.InvariantCulture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does having this replaced in break any of the other code expecting this to be en-US? For example, the check here:
if (culture.ThreeLetterWindowsLanguageName.Equals(EnUSCultureInfo.ThreeLetterWindowsLanguageName))
That doesn't do anything strange now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a basic test it at least doesn't throw
Console.WriteLine(CultureInfo.InvariantCulture.ThreeLetterWindowsLanguageName);
Console.WriteLine(CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName.Equals(CultureInfo.InvariantCulture.ThreeLetterWindowsLanguageName));
writes
IVL
False
Docs also say this (though not 100% the same)
It can be used in almost any method in the [System.Globalization](https://learn.microsoft.com/en-us/dotnet/api/system.globalization?view=net-7.0) namespace that requires a culture. The objects returned by properties such as [CompareInfo](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.compareinfo?view=net-7.0), [DateTimeFormat](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.datetimeformat?view=net-7.0), and [NumberFormat](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.numberformat?view=net-7.0) also reflect the string comparison and formatting conventions of the invariant culture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't do anything strange now?
It may. But i don't believe that's somethign we should care/invest in. This gets us out of server crashing, which is the pri0 issue. Having slightly incorrect sorting/filtering in pattern matching on this niche platform is pri4/sev4 if it happens.
Fixes microsoft/vscode-dotnettools#386.