Must use Type.FullName
for resource files found using default IStringLocalizer<T>
#296
Description
Behind our default IStringLocalizer<T>
, ResourceManagerStringLocalizerFactory
removes a prefix matching IHostingEnvironment.ApplicationName
or AssemblyName.Name
(in some cases) from T
's FullName
before a search of the containing assembly for requested resources. This does not help users who happen to have a different root namespace from the containing assembly / application name. They must use T
's entire FullName
e.g.
One important case occurs when Visual Studio creates a new project from a template and the user chooses a name that's invalid as a C# identifier. The "safe project name" used as the root namespace is created using a simple algorithm but will not match the application / assembly name.
While redoing the "safe project name" algorithm in our code may be an ugly hack, we could e.g. extend [ResourceLocation]
to also specify the namespace prefix to remove when searching for resources in the containing assembly based on a Type
.
Found while working with sample application at dougbu/Localized.1.1-preview. Screenshot above comes from VS with that solution open. (Took longer than it should for me to find the workaround.)