January 10, 2005

ReSharper 1.5 goes into EAP

Well, it seems like I'm not making any news in the blogsphere announcing start of ReSharper 1.5 Early Access Program. But since it seems like almost all new features of 1.5 are mine I think I'm the one who should write couple words about them.

This version's keyword is “refactorings” (it is even called so in our issue tracking system) which means that current and future ReSharper users will get more quality refactorings this month when 1.5 is released. Next I'll describe each of the new refactorings in a few words.

Extract Interface

A very simple refactoring which can be found in most refactoring add-ins and in VS2005. Our version, however, has interesting enchancement: you can extract not only type members (like methods, events, etc.), but also interface implementations. What I mean can be shown on a simple example:

interface I
{
  void Foo();
}

class C : I
{
  public void Bar() {}

  public void Foo()
  {
    throw new NotImplementedException();
  }
}

If we try to extract interface from class C ReSharper will show the following dialog:

ExtractInterface.png

It gives us option not only to extract members of class C, but also implementation of interface I. If we choose to extract I and Bar, we get the following result:

interface I
{
  void Foo();
}

class C : IC
{
  public void Bar()
  {
  }

  public void Foo()
  {
    throw new NotImplementedException();
  }
}

interface IC : I
{
  void Bar();
}	

Extract Superclass

Extract superclass is like extract interface, but the difference is big enough: since it extracts members with bodies and also can extract constructors the logic is far more complicated than in extract interface. I won't, however, describe these “little details” that should have been taken into account and will only recommend you to try it out.

Copy Type

Copy type is copy type. Take a type declaration, choose Refactor -> Copy Type and you’ll get the same declaration copied under different name.

Introduce Field

Introduce field refactoring replaces usages of an expression or a variable with usages of new field or constant. To use it simply select an expression or place cursor at variable declaration and invoke the refactoring. You will see the following dialog:

IntroduceField.png

The refactoring gives you option to choose where to initialize the new field, which visibility to use (the list misses "protected internal" access modifier since it’s rarely used), whether to introduce constant, declare the field readonly and whether to replace all occurences of the expression. After you decide on each option you can confirm your choice and the field will be created.

Encapsulate Field

This refactoring allows you to create proxy property for a field (like our "Generate Getter/Setter" feature) and replace some or all of its usages with usages of the created property. Simply choose a field and invoke the refactoring. It will give you lots of options including whether to replace reads and writes, external or all usages, new property visibility, etc.

The list is incomplete. This week I'll be working on introduce parameter and maybe some other refactoring(s)...

Posted by Oleg Stepanov at January 10, 2005 07:03 PM | TrackBack
Comments
Post a comment









Remember personal info?