Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

Must use Type.FullName for resource files found using default IStringLocalizer<T> #296

Closed
@dougbu

Description

@dougbu

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.
capture

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions