[DataAnnotations] LocalizableString does not work with internal resource types #110073
Labels
area-System.ComponentModel.DataAnnotations
needs-further-triage
Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
The class System.ComponentModel.DataAnnotations.LocalizableString that is used by the class System.ComponentModel.DataAnnotations.DisplayAttribute for localization, throws an InvalidOperationException when the given ResourceType is not public.
As you can see at line 132, this is by design, since IsVisible is explicitly checked to be true.
But from my point of view, this check does not make sense.
If I'm able to assign the ResourceType with a type I can access, it should just use that one, no matter if it is public or internal.
I noticed it in my project where I use the new Roslyn ResxSourceGenerator, that generates the resource classes als internal by default.
As a workaround I can configure it to create them as public.
But since I use those resources only inside the same assembly, I don't really want to make them public.
There was already a discussion in the issue #15794, but the explanation not to change that, because it always has been like that, is not very satisfying.
I would appreciate if it can be considered to simply remove the check for IsVisible on the ResourceType.
The text was updated successfully, but these errors were encountered: