"Move to Resources" Action in Attribute similar to DisplayAttribute
Hi
my questino is about the "Move to Resource" action that can be used when working with the System.ComponentModel.DataAnnotations.DisplayAttribute.
The Attribute has a Name and a ResourceType Property and when you only set the Name property R# provides an action to move this string to resources.
After that it writes in the Name property the resource key and in the resource type the type of the reousrce file.
We now have an attribute which has similar propertys and I would like to have the same behavior.
As I guess there is not built in support for this currently could I write a plugin to do so? What do I have to look for / use as inspiration?
Thanks for your help.
Kind Regards
Sven
Please sign in to leave a comment.
Hi Sven. Given that it's a custom attribute, and somewhat custom behaviour, you will have to write a plugin to do this. To get an idea how to do this, you'll want to fire up dotPeek, point it at the ReSharper directory, and take a look at these classes:
You'll notice that there are two instances of these classes - one for C# and one for VB. That's because the elements of the parse trees for each file are not compatible with each other (C# and VB are close cousins, but they are different languages, and there are differences in the parse trees). For this instance, you'll probably find the code to be pretty much the same across the two languages.
Hope this helps
Matt
Thanks Matt. I will take a look into this
:)