Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataAnnotations] LocalizableString does not work with internal resource types #110073

Open
uo1 opened this issue Nov 22, 2024 · 3 comments
Open
Labels
area-System.ComponentModel.DataAnnotations needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@uo1
Copy link

uo1 commented Nov 22, 2024

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.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 22, 2024
@tarekgh
Copy link
Member

tarekgh commented Nov 24, 2024

@uo1 could you please provide a sample code to demonstrate the issue?

@tarekgh
Copy link
Member

tarekgh commented Nov 24, 2024

Looks related to #41505.

@tarekgh tarekgh added needs-author-action An issue or pull request that requires more info or actions from the author. and removed untriaged New issue has not been triaged by the area owner labels Nov 24, 2024
@tarekgh tarekgh added this to the Future milestone Nov 24, 2024
@uo1
Copy link
Author

uo1 commented Nov 26, 2024

I just created this small App repository /uo1/MyApp to demonstrate the issue.

It's not directly related to #41505, but I would appreciate if that issue would be resolved as well.

@dotnet-policy-service dotnet-policy-service bot added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.ComponentModel.DataAnnotations needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

2 participants