-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Support for multilingual DisplayAttribute #1145
base: master
Are you sure you want to change the base?
Conversation
… resource via reflection. This is important in multilingual projects.
@@ -20,6 +20,9 @@ | |||
<PropertyGroup Condition="'$(TargetFramework)' == 'net40'"> | |||
<DefineConstants>LEGACY</DefineConstants> | |||
</PropertyGroup> | |||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.0'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is already a const for this (not needed here)
Thanks for the PR. Please also add some unit tests. |
I've just run into this exact problem - getting values from resources would be an incredibly useful addition. I don't think it's a breaking change, because the behaviour when you specify That said, it would be easier to just let the attribute do the heavy lifting for you, and use the GetName and GetDescription methods to get the name and description, as these return either the literal value or a resource depending on how the attribute has been declared. Both are available since .NET Framework 4.0. |
If there are GetName() and GetDescription() especially for that we should use that and not "reimplement" their logic. |
I needed NJsonSchema in a multilingual project, where each language was added in .resx files. NJsonSchema didn't respect ResourceType argument in DisplayAttribute. So I added support for this scenario. Also it doesn't matter if the resource class has internal or public accessors.
Since Net standard 1.0 doesn't have BindingFlags, I kept the past behavior if target framework is Net standard 1.0