Chaining a sequence of refactorings together

I was wondering if anybody knew a way of performing a number of refactorings autmatically, one after the other.

I've found that I've needed to:

Create read-only property 'Name'
Create and use '_name' as backing field
Set backing field to readonly
Change signature of constructor to include 'name'
Initialize '_name' with parameter value

The only input I need to provide is the type of the property and the default value.  Is this what macros are for?

2 comments
Comment actions Permalink

Hello Douglas
     There's no built-in functionality in ReSharper to chain several refactorings together. You could try using the built-in Visual Studio macros, but I'm not sure if that will work. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

I don't know how to do it with macros. But for your special chain you could use some ReSharper shortcuts to be a little bit faster.

1. Write your field: string _name;
2. Place cursor on _name and press Alt+Enter and select Initialize field from constructor(s) parameter and press Enter.
3. Place cursor on _name and press Alt+Enter and select Generate getter and press Enter.
4. Place cursor on _name and press Alt+Enter and select Make field '_name' readonly and press Enter.

0

Please sign in to leave a comment.