-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
According to the docs:
the
BaseNameproperty reflects the fully qualified namespace name and the root resource name of a resource file, without its culture or file name extension. For example, if an app's default resource file is named SampleApps.StringResources.resources, the value of the BaseName property is "SampleApps.StringResources".
This is true when you access the generated MyResource.ResourceManager.BaseName property, which uses the ResourceManager(baseName, assembly) constructor.
However, if you construct a ResourceManager with just a Type, it sets BaseName to Type.Name which is different. The resource lookup still works because it uses the type's full name internally.
Reproduction Steps
Console.WriteLine(MyResourceType.ResourceManager.BaseName); // e.g. "MyNamespace.MyResourceType"
Console.WriteLine(new ResourceManager(typeof(MyResourceType)).BaseName); // e.g. "MyResourceType"Expected behavior
The BaseName property should be initialized from the type's full name.
Actual behavior
The BaseName property is initialized from the type's name.
Regression?
No.
Known Workarounds
Don't use the ResourceManager(Type) constructor if you will be accessing the BaseName property. This is unfortunate because that is the easiest constructor to use.
Configuration
.NET 6 Windows 10 x64.
Other information
Possibly this is "by design" and the docs just need to be updated? Not sure why that would be the case, though.