Fix CultureNotFoundException when InvariantGlobalization is enabled
Fixes #1126 .
Starting with .NET 6, when InvariantGlobalization is enabled, CultureInfo constructor throws CultureNotFoundException for all cultures except invariant: https://docs.microsoft.com/en-us/dotnet/core/compatibility/globalization/6.0/culture-creation-invariant-mode
- Handle
CultureNotFoundExceptionwhen creating the default formatter. - Skip other cultures when there was an exception for
en-US.
Any reason for not accepting this useful PR?
@clairernovotny @MehdiK @hazzik can we please have this merged?
@clairernovotny @MehdiK @hazzik Would you please take a look at this PR if you've got the time?
@ptupitsyn sorry for the delayed reply. can you rebase. and also add a test for this scenario
@SimonCropp invariant globalization can only be enabled before the runtime starts: https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization
I'm not sure how to test this scenario. Is it ok to spawn a new process?
@ptupitsyn i think the best way is to add a new test project with the following
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
</Project>
and add a few tests to it. enough to verify the change
Just a question: how to differentiate between culture not found due, for ex, misspelling, and globalization invariant?
@hazzik perhaps it throws a different exception?