g.pickardou
g.pickardou

Reputation: 35822

How to rename refactor all private member variable variables in a C# VS 2013 project?

I am using camelCase convention for private member variables in my C# projects. Because of changed code quality requirements now I "have to"/"would like to" rename/refactor all these members to _camelCase.

For example logger will be _logger.

Additional info:

1) I definitely know that a particular rename/refactor could cause error, and an interactive refactor tool will warm me in that case. Still I want to automate mass rename, I'll take the risk ending with not compilable source what needs manual corrections.

2) I use latest ReSharper if this helps, but still I can not figure solution for my task. (To be clear I do not suggest ReSharper should be the solution, just a possibility.

Thanks in advance

Upvotes: 1

Views: 1618

Answers (3)

Francis
Francis

Reputation: 1904

The only way I found is via the Resharper's "Show Potential Fixes" Menu option as outlined by Jowen here.

How to reformat naming styles with ReSharper?

Upvotes: 0

Mutton92
Mutton92

Reputation: 91

One easy way of doing this is to just you Ctrl + F & Find and replace. This however doesn't give you the security that you have only updated the relevant variables and could end up changing other thing. But you can always undo the changes easily if they cause problems.

UPDATE

Having read other answers I have tried Ctrl + R + R and this is now the way I will be doing things. I would up vote that answer but can't as I don't have enough reputation yet!

Upvotes: 0

Sandman
Sandman

Reputation: 815

There is a guy called Steve Cadwallader who has made a visual studio extension called "CodeMaid" (http://www.codemaid.net/). It has several things you can use for cleaning up code etc and the source code is free i think. If you have strict code quality requirements like this maybe its worth it to download his extension and do a slight modification to it. I know it already do stuff with private member variables so it shouldnt be too hard to modify.

This extension can do stuff on a file or project basis which makes it easy for you if you have a large number of files to modify.

Upvotes: 1

Related Questions