Aspnetcore: [Localization 3.1] Failed to resolve string if RootNamespace is different from AssemblyName

Created on 13 Dec 2019  路  11Comments  路  Source: dotnet/aspnetcore

On .NET core 3.1, if the RootNamespace is different from the AssemblyName, the resources fails to resolve.
Related to : https://github.com/aspnet/AspNetCore/issues/10639

Discussion continued from : dotnet/extensions#2081

@hishamco asked me to file a new bug report, so here it is:

Here is a repro project: https://github.com/jeremyVignelles/repro-localization
The relevant line is here : https://github.com/jeremyVignelles/repro-localization/blob/5f0fc80ac58a6321c78f4ce0e743635809f20889/TestLocalization/Program.cs#L14 . If I use the ResourceManagerStringLocalizerFactory from 3.1, it doesn't work as expected.

area-mvc investigate

Most helpful comment

Transferring to dotnet/aspnetcore, since Localization lives there now.

All 11 comments

I download your repo hope to check it today, BTW this is the first time I see Net5ResourceManagerStringLocalizerFactory, AFAIK it's ResourceManagerStringLocalizerFactory

Because it's checked in my repository, it's the class from this repository, but renamed to avoid conflicts

I see, I didn't have a look to the entire repo, ok let me check it later ...

FYI waiting for the team reply on https://github.com/aspnet/Extensions/pull/2081#issuecomment-565678129

Hi, any update on this?

Transferring to dotnet/aspnetcore, since Localization lives there now.

Thanks for contacting us.
@ryanbrandenburg can you please look into this? Thanks!

@jeremyVignelles does specifying the RootNamespaceAttribute work: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1#rootnamespaceattribute? If not, do you have a minimal app that you can share that exhibits this problem? Also we did have a bug that was fixed as part of 5.0: https://github.com/dotnet/aspnetcore/issues/10639.

@pranavkm they provided a repro app already. That repro app bears out that they have used the RootNamespaceAttribute. I'm fairly confident that they are correct that we need to backport the fix they linked from 5.0 into 3.1, will be doing an investigation to confirm and backport today.

@ryanbrandenburg was too fast for me :)

Yes, I did put the attribute, and it didn't fix anything.

My understanding is that yes, it was fixed in .NET 5, because the current "fix" I have is to copy the .NET 5 ResourceManagerStringLocalizerFactory. See here

It just wasn't backported as far as I'm aware of.

Thanks for the investigation, @ryanbrandenburg.
Given the workaround and the impact this has on the community we will not be taking this fix in 3.1.

Was this page helpful?
0 / 5 - 0 ratings