-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
There's a feature switch which is intended to reduce size of applications by removing exception messages and instead using just the resource key as the exception message. This is turned on by setting MSBuild property UseSystemResourceKeys=true.
The code which does that is here:
| if (UsingResourceKeys()) |
It's compiled into each library and the rest of SR class (all the properties) are generated from resources.
This means that calling SR.CultureInfoConverterDefaultCultureString in default app returns (Default) from resources, but when UseSystemResourceKeys=true it returns CultureInfoConverterDefaultCultureString (string). This is used here:
Line 25 in f10cdda
| private static string DefaultCultureString => SR.CultureInfoConverterDefaultCultureString; |
The external visible repro is:
dotnet new console
Program.cs:
System.ComponentModel.TypeDescriptor.GetConverter(typeof(System.Globalization.CultureInfo)).ConvertFrom(null, null, "(Default)");dotnet run -> prints out nothing == works correctly.
dotnet build /p:UseSystemResourceKeys=true
./bin/Debug/net6.0/app.exe -> prints:
Unhandled exception. System.ArgumentException: CultureInfoConverterInvalidCulture, (Default) Arg_ParamName_Name, value
at System.ComponentModel.CultureInfoConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Program.<Main>$(String[] args) in ...\Program.cs:line 1
The UseSystemResourceKeys is set to true by default in Blazor WASM projects, so this is effectively broken in all Blazor projects by default.