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

Duplicate resource files using both dot naming and file naming disables all .resx lookups #209

Closed
Rick-Anderson opened this issue Feb 4, 2016 · 15 comments
Assignees

Comments

@Rick-Anderson
Copy link

When you provide a resource file using both dot naming and folder naming, it disables the entire localization resource lookup. For example, if I have the following resource files in Entropy, no other non-conflicting .resx files are used.

  • Resources\Controllers\HomeController.fr.resx
  • Resources\Controllers.HomeController.fr.resx
@Eilon
Copy link
Member

Eilon commented Feb 4, 2016

What does no other non-conflicting .resx files are used. mean?

Why would you have both files?

@hishamco
Copy link
Contributor

hishamco commented Feb 4, 2016

As @Eilon said Why would you have both files? but if the case is

  • Resources\Controllers\HomeController.cs
  • Resources\Controllers\HomeController.fr.resx

it's already discussed here #13

@Rick-Anderson
Copy link
Author

Damian asked me to:

Log a bug, but this is obviously a bit of an edge case, as you’re essentially duplicating the same resource.

@Eilon Why would you have both files?

You shouldn't and I'll document that. But the Entropy sample and my sample will show both approaches. Suppose you add a new type and it's associated resource - then are off that project for a few days. You return and add the same type resource with the alternative name. You app now fails silently. I was just hoping that when it fails it would throw an exception telling you why it failed. Perhaps this is enough of an edge case that I only need to document it.

@hishamco #13 is "resource name is not found it throws" - this issue is that if you have two resources that are essentially the same resource (one uses the dot naming and the other the file naming) - not that the resource is missing.

@Eilon no other non-conflicting .resx files are used

In the Entropy sample, if you have both

  • Resources\Controllers\HomeController.fr.resx
  • Resources\Controllers.HomeController.fr.resx

It disables all resource files. _Resources\Views.Shared.Layout.fr.resx and all the other .resx files are not read.

@Eilon
Copy link
Member

Eilon commented Feb 4, 2016

Ah, I see. I can only wonder what error we could show... I don't think we can know about the conflict until the app is running, so I don't think we can show an error during build.

I can think of two options:

  1. If there's an ambiguity then arbitrarily pick one (e.g. sort them deterministically and pick the first one)
  2. Maybe do (1) but also log a warning to the logger

@DamianEdwards any preference as to the behavior?

@hishamco
Copy link
Contributor

hishamco commented Feb 4, 2016

@Eilon logging a warning is good option, but can we align it with VS warning, so anyone using VS can see that too

@Eilon
Copy link
Member

Eilon commented Feb 4, 2016

I don't think VS can show the warning because it's a runtime warning. VS isn't even in the picture anymore.

@DamianEdwards
Copy link
Member

I'm surprised this isn't failing at resource generation time (compile time). It can't embed both files with the same name, so it must either be embedding neither, or changing the names when embedding (e.g. append 1, 2 to the end).

Can we check what the actual embedded resources look like in the project assembly after compile?

@Eilon
Copy link
Member

Eilon commented Feb 4, 2016

@DamianEdwards is it possible that it gets embedded with both names? Or does it always embed with dots?

@ryanbrandenburg can you take a look and see what's in the physical DLL in this scenario?

@DamianEdwards
Copy link
Member

@Eilon no, the \ are replaced with . by the compiler, you can't control it.

@Eilon
Copy link
Member

Eilon commented Feb 4, 2016

Ok then that's indeed weird.

@hishamco
Copy link
Contributor

hishamco commented Feb 6, 2016

Related to unrelated question, I faced a strange issue in the Entropy repo too while implementing a JsonRequestCultureProvider seems the entire localization resource lookup is disabled, the source is available here

@ryanbrandenburg
Copy link
Contributor

@hishamco as you said, that seems to be an unrelated question since there are no duplicate Resource files. Please post it as its own issue with more information.

@hishamco
Copy link
Contributor

hishamco commented Feb 8, 2016

Ok @ryanbrandenburg

@ryanbrandenburg
Copy link
Contributor

When I try to reproduce this I run into what @DamianEdwards expected, which is that it fails at compile time with CS1508: Resource identifier 'LocalizationSample.My.Resources.Controllers.HomeController.resources' has already been used in this assembly. This is true for both dnx web and dotnet run. @Rick-Anderson am I missing a part of what you're doing?

@Rick-Anderson
Copy link
Author

Closing. I'm not building so I didn't see that error. I just change the resource files/code and dnx run.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants