TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Expansions in Visual Studio 2005

I'm really liking the refactoring tools in Visual Studio 2005. So much that I purchased ReSharper because I can't wait for the VS2005 to RTM! Anyway, I was thinking how nice it would be if the refactoring ability called Encapsulate Field would allow both a name change to the private field and the corresponding property. To do this you would have to first rename the field, then encapsulate it. So, I tried using the class diagram to create a property, but it doesn't create a corresponding private field for you. Bummer...

Then I found the prop expansion...hello!!! Very nice. Simply type in the word "prop" in the code editor and hit TAB twice. You end up with the following...

private int myVar;

 

public int MyProperty

{

    get { return myVar; }

    set { myVar = value; }

}

 

The yellow highlights are areas you can tab to and from to alter the data type and the names of the field and the property. So, the first place I end up is in the  int  and I type "string", press TAB, end up in the myVar area and I can type "_name", press TAB again and end up in the MyProperty area and type "Name" and Viola!!! A private field and public property.

 

private string _name;

 

public string Name

{

    get { return name; }

    set { name = value; }

}

 

 

Expansions rock!
Digg!

posted on Wednesday, June 01, 2005 6:02 PM

Feedback

# ReSharper 1.5 Review 6/7/2005 6:13 PM TheChaseMan's Frenetic SoapBox