Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper Rename Fields

I've been tasked with making some significant modifications to a legacy codebase that was not written using our current code style conventions. The changes are extensive enough that I'm doing some cleanup and refactoring (there was quite a bit of dead code) before getting started. One of the things that's bugging me is that the fields are following the m_FieldName naming convention whereas we now use _fieldName.

Is there some way with Resharper to automatically rename all fields in the project to follow the new convention? Are there other tools that can readily do this? It's not too difficult to remove the prefixing 'm' with even a simple search/replace, but I haven't found an automated way to change the case of the starting letter.

like image 374
Dan Bryant Avatar asked Jan 09 '12 16:01

Dan Bryant


People also ask

How do I refactor with ReSharper?

Press Ctrl+Shift+R or choose ReSharper | Refactor | Refactor This… from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there. The Refactor This list appears. Choose an item from the list and click it or press Enter .

How do I rename all references in Visual Studio?

Select Edit > Refactor > Rename. Right-click the code and select Rename.


1 Answers

It might be better to just find/replace <m_ by _ using Visual Studio (regular expression search/replace).

The < stands for "beginning of word".

Edit: There seems to be no way, using Find/Replace, to modify the casing of that first letter after the underscore.

So you would have to do this operation 26 times in a row, like so:

Replace <m_A by _a
Replace <m_B by _b

and then you're all set. Fun, too :-) But it should only take a few minutes.

like image 193
Roy Dictus Avatar answered Oct 11 '22 13:10

Roy Dictus