exceptionz

Thoughts on Technology, Methodology and Programming.

Resource Refactoring Tool

Posted by Marcus Wyatt on 10 November 2006

What a cool utility as part of the Power Toys for Visual Studio. The Resource Refactoring Tool provides you a way to extract hard coded strings from your code to a new or existing resource files. It is a aplha release, but I’ve used it now for about a day and it is stable.

How does the tool work?

The first thing I have done is to give it a keyboard shortcut. I don’t use the standard refactoring tools, so I have re-assigned the Ctrl+R, Ctrl+R keyboard shortcut to the “Extract to Resource” item. The command your looking for in the keyboard scheme is “Microsoft.VSPowerToys.ResourceRefactor.Connect.RefactorLiteral”.

Now you just select some hard coded text and hit your shortcut. You should see the following dialog box.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

What you can do now is select if you want to create a new resource file or use an existing resource file. The screenshot shows an existing resource file. It also tells you if the Resource name you want to assign is already in use. I also like how it shows what the code will look like after the refactoring. I am a big Resharper fanatic, but this is one of the better Microsoft refactoring offerings. Good job MS…

tags: , , ,

Currently listening to: Zee – Dreamtime (Vocal MIx)

Advertisements

4 Responses to “Resource Refactoring Tool”

  1. Todd Gleason said

    The real question is how do I go further? Most of the time I am pretty sure the string is new; I want to click the “Create new resource entry” and “OK”. It would also be good if I knew how to change the .resx file programmatically.

    Also, if the tool automatically sorted by similarity, and automatically selected the checkbox based on whether or not the new entry is identical to another, well, that would be sweet. But they’re 98% there in my opinion.

    It doesn’t look like I’ll be able to make an effective VS macro; calling DTE.ExecuteCommand(“Microsoft.VSPowerToys.ResourceRefactor.Connect.RefactorLiteral”) will hang until the dialog box is dismissed, and even on success it generates an exception. Guess I’ll break out AutoHotkey!

  2. Alexander said

    For the big Resharper fanatic i can to recommend RGreatEx. It’s ReSharper plugin and more powerful then “Resource Refactoring Tool”. You can find overview all RGreatEx features on the http://www.codeproject.com. Good luck.

  3. Yeah, I’m using RGreatEx and it’s great. But I do have an issue with it being compiled against an older version of ReSharper (3.0) than what I’m using (3.1). So I’m having some problems with it at the moment…

  4. Alexander said

    What problems do you have with RGreatEx? Please, send it to the RGreatEx support.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: