views:

132

answers:

1

I am looking for a refactoring plugin which specifically has the ability to take a declaration like this:

Dim myVar as MyType

or

Private MyVar as MyType

and turn it into this:

Private _myVar as MyType
Private Property MyVar as MyType
   Get
      return _myVar
   End Get
   Set (ByVal value as MyType)
     _myVar = value
   End Set
 End Property

My examples are in VB however C# support would be greatly appreciated as well.

I am familiar with the VSS Template for Properties, however using that often feels slower than just typing.

Thanks in advance

+4  A: 

For free you can use the express edition of CodeRush to do this: Get it here. You want the "Encapsulate Field" refactor.

For cold, hard, cash the full version of CodeRush or Resharper will do this and much more. (I'd imagine there are other tools out there too, but this are the two I have experience with)

Martin Harris
I had CodeRush Xpress already and missed this. It appears to be a multi-step process unless there is a keyboard shortcut for the refactoring. When I highlight a variable declaration it offers to promote to a field, then on a field I can generate setter methods.Thanks.
Rob Allen