Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-276836: DataAnnotation DisplayName localization

$
0
0
Reporter Alex Berezoutsky (fergard) Alex Berezoutsky (fergard)
Created Oct 6, 2011 4:56:01 PM
Updated Dec 28, 2011 12:18:31 AM
Resolved Dec 27, 2011 4:14:02 PM
Priority Critical
Type Task
Fix versions 6.1
State Fixed
Assignee Tatyana Lunegova (lunega)
Subsystem No subsystem
Affected versions 6.0
Fixed in build 6.5.1.1441
In an MVC 3 development, to workaround localization limits in DisplayName attributes, I've my custom attribute called "LocalizationDisplayName".

The typical use is something like that:
[LocalizationDisplayName("FirstName", typeof(Resources.Global))]


The code behind this attribute is the following:

    public class LocalizationDisplayNameAttribute : DisplayNameAttribute
    {
        private readonly DisplayAttribute _display;

        public LocalizationDisplayNameAttribute(string resourceName, Type resourceType)
        {
            _display = new DisplayAttribute()
                           {
                               ResourceType = resourceType,
                               Name = resourceName
                           };
        }

        public override string DisplayName
        {
            get
            {
                return _display.GetName();
            }
        }
    }


Please not that, even though I don't think is relevant for this issue, for the sake of completeness, I think is wort to say that all my resources are in a distinct project.

The issue is that resharper keeps warning me about localizable string each time I use this attribute.
I don't want to annotate all of them with Localizable(False), first because is not true, second because it makes the code dirty.

Also the more standard approach ([Display(ResourceType = typeof(Resources.Global), Name = "LastName")]) gives the same issue: corrugated underline below the strings.

Since ReSharper has a very good localization support (though could be improved, for instance in how contants are named), it would be nice if you at least would allow users to define which attributes provides localized string.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>