ReSharper 7: release in detail

ReSharper7 Two weeks ago, we announced the release of ReSharper 7.0 , only briefly listing the new products that were implemented in this major release.
Today, MSDN and TechNet subscribers will have the opportunity to download Visual Studio 2012, and this is a great occasion to talk about the new features of ReSharper 7.0 in as much detail and detail as possible.

Summary of the article (which at the same time will help you navigate this voluminous material):

Visual studio 2012

Windows runtime

Code Generation


New refactoring

Unit testing

New language support in the ReSharper SDK

Visual studio 2012

One of the main tasks of the new Resharper is to provide full and transparent support for VIsual Studio 2012. This support concerns both new aspects of the interface and new technologies. Let's start with an interface that has undergone very significant changes.

Theme Support

Visual Studio 2012 supports the “themes” paradigm and comes with two themes - Light and Dark. We have added support for both themes for all of our menus, icons, etc., to Resharper, in order to fully harmonize with the Studio.

Monochrome icons also appeared in the new Studio, but we, in turn, received a lot of feedback from users who asked us not to convert our icons in this style. Since visual preferences are a subjective thing, we decided to give users the right to choose:
Thus, you can choose the icons that will be displayed in various menus, windows, etc., as well as icons for different elements of the project - types, properties, etc. Icons can be configured through ReSharper | Options | Of General . Yes, and we also improved our original icons a bit.

Asynchronous loading of projects

In VS2012, Microsoft added support for asynchronous project loading (ASL), which allows projects in the solution to load independently when opened. This actually allows the user to get started before the entire solution loads.

In the 7th Resharper, despite a number of difficulties that we encountered in working with ASL and the corresponding API, we managed to fully support this feature - so now you can immediately get faster loading of projects and all the working capabilities of Resharper.

As an example of increasing productivity, a solution containing more than 300 projects when opening with Visual Studio 2010 & ReSharper 6 takes 5 minutes. 12 sec., And with Visual Studio & ReSharper 7 - only 1 min. 17 sec

Quick launch

In VS2012, if you do not know exactly where this or that element or command is located, you can use the Quick Launch panel for instant search. As a Studio plugin, we were able to add our own teams to this menu. Now, if you type Go to in the panel, QuickLaunch will give you all the relevant Resharper commands:

Preview tab

Another new feature of VS2012 is the “preview tab”. Its essence is that, unlike the usual tab for a document, this tab opens on the right side of the window, but as soon as you start editing it, it moves to the left side. The meaning of this tab is to show a fixed browser that you can navigate without spawning new open tags.

Resharper supports the use of this special tab in features such as Go To Type / Member / File / Declaration as well as in Find Usages and related windows.

Solution explorer

In the new Solution Explorer, you can open a specific file and see its structure — classes, methods, and so on. The resharper, in turn, provides a context menu for these elements, so that they can be refactored, find usages, and other familiar commands - both through the use of pop-up menus and through keyboard shortcuts.

Architecture explorer

In the Ultimate edition, VS2012 comes with an Architecture Explorer, which allows you to progressively delve into a solution from namespaces to specific fields or methods. And here Resharper provides the same support for contextual actions on code elements using the Navigate To or Refactor This pop-up menus .

Dependency graph

In addition to supporting Architecture Explorer, Resharper also provides the same features in the dependency graph that Studio can generate.

Windows runtime

The upcoming releases of Windows 8 and Visual Studio 2012 give us a new programming model for writing applications called Windows Runtime (or WinRT for short). Since development on WinRT can be done using languages ​​that Resharper already supports (C #, VB.NET, JavaScript), we have added WinRT support to Resharper.

C #, VB.NET and XAML

Resharper continues to develop support for C # / VB.NET and XAML. The following features were made specifically for WinRT:

  • Code completion is provided both in code and in XAML files. In XAML, Resharper is familiar with the new namespaces and formats, and is able to provide the necessary addition options depending on the editing context:

  • Inspections continue to provide relevant information about possible code problems in WinRT-specific projects:

  • Error correction (quick-fixes) also helps to quickly fix problems:

  • Contextual navigation allows you to quickly move around the solution. This mechanism is aware of the specifics of WinRT projects such as, for example, resource naming options:

  • Optimization links (reference optimization) is also supported in C # / VB.NET-oriented WinRT projects:


Unlike C # / VB.NET WinRT projects that have inherited the development model from WPF and Silverlight, the development model for WinRT using JavaScript (also known as WinJS) is fundamentally different. However, Resharper provides many different features to support it:

  • Code completion is supported in HTML, CSS and JavaScript, and even in JSON attributes inside HTML:

  • Auto-completion is also available for imported WinRT components . For example, this class
    being imported into JavaScript allows Resharper to display the following auto-completion list:

  • Of course, navigation and search work great with WinRT projects. If we take the example above and look for the use of the class Person in the C # project, we will get a link to the WinJS project:

  • The create from usage
  • mechanism (creating code elements from examples of their use) also works in cross-project scenarios. For example, if you create a new property for the imported WinRT component:
    then it will be automatically created in the definition of this component:

  • Refactorings (such as Rename , for example) also work in cross-project scenarios. For example, an attempt to rename a property name projected from a WinRT component into WinJS will open a dialog for renaming the original property:
    Accordingly, after this change, the property name will become in the C # project FullName , and - in the projected component fullName .

Well, as you might imagine, most of the existing features for supporting C #, VB.NET, XAML, HTML, CSS and JavaScript remain available to anyone who plans to work with projects based on WinRT.

Code Generation

If there was a competition between the different subsystems of Resharper about who brings more changes and a minimum of effort, then the Generate mechanism would be an undeniable winner. And, of course, in the new Resharper, we added several new features and improvements to this mechanism.

Partial Method Generation

Many code generation frameworks produce code consisting of partial classes so that users can subsequently change or supplement the behavior of the generated components. For example, the Entity Framework does this by defining entity classes as partial .

Resharper now supports this use case and allows the generation of signatures of partial methods. Для этого, нужно всего лишь создать partial тип и вызвать Generate | Partial Methods :
Now you just need to select the methods that you want to implement:
... and all the selected methods will be added to the selected class:

Improvements to Generate Equality Members

When comparing types, many of our users wanted to regulate the mechanisms by which types are compared. Therefore, we added three different type comparison options
to the Generate Equality Members :
Depending on which option you choose, a condition that checks for type matching in a method Equals() can be implemented in one of the following ways:

  • The type should be the same as this :

  • The type must be the same as the class type:

  • The type must be a type or an inheritor of the class:

Generate Equality Comparer

In addition to the inline comparison implementation for a specific class, the new Resharper comes with a new generator called Generate Equality Comparer . The purpose of this generator is to create a separate class that implements the interface IEqualityComparer<T> . This is sometimes necessary to implement specific comparison criteria, as well as in cases where this interface requires a specific API with which you are working.

Here is a small example. Suppose we have a class Person in which there are two properties. We call the action:
... and, having selected those elements on which we want to make a comparison, Person get the following generated private nested class:
In addition to this, there is an option to generate a nested static instance of this class as a field:

Support INotifyPropertyChanged

If your class implements INotifyPropertyChanged or inherits from a class that uses this mechanism (for example, NotificationObject from the Prism framework), then the Generate Properties NotificationObject action will offer you various options for implementing properties based on this interface:


Since the time of Windows Forms, the interface has been INotifyPropertyChanged used to let properties communicate changes to everyone who needs it (usually this is the UI). Support for change notification, which is used today in many platforms (WPF, Silverlight) and frameworks, we were often asked to do and in the new release, we did it.

Automatic implementation

As soon as you add a declaration INotifyPropertyChanged to your class, Resharper will offer you a quick correction for implementing this interface:
Applying this fix, you will automatically receive not only the declaration of the event, but also a method that facilitates calling this event. Now you can take any property (be it an auto property or a property with a field) and apply a context action to it that will add a call to the notification method:
If you use fields instead of properties, you can also use the Generate Properties command and the Resharper will offer you to implement notifications on the generated ones properties:

ID Tracking

Linking a property through a string is not the safest solution. But if you need to do this, then Resharper will help you. Firstly, it will track the names of the properties, so if you make a mistake or refer, for example, to a private property, the Resharper will immediately display an error:
Secondly, if you decide to call the notification method manually somewhere, you will Autocompletion is presented in a line with the names of possible properties:

Support for various frameworks

There are many different implementations INotifyPropertyChanged . Third-party libraries often use their own method for notifications, and come with base classes from which to inherit. One of the main differences is that many frameworks use a lambda expression instead of a string literal to pass the method name.

Resharper comes with support for the following frameworks:

  • MVVM Light (WPF 3 and 4; Silverlight 3, 4 and 5; Windows Phone 7 and 7.1)
  • Caliburn.Micro (WPF 3 and 4; Silverlight 4 and 5; Windows Phone 7.1)
  • Prism (WPF 4; Silverlight 4)
  • Catel (WPF 3 and 4)
  • MVVMHelpers (WPF 3 and 4, only lambda expressions are supported)

In practice, this means that if, for example, you inherit a type NotificationObject from the Prism framework, then when you create the properties, you will be offered the choice of the method RaisePropertyChanged that you want to call:
If you choose the lambda-oriented option, your properties will look like this :
And, of course, these same implementation options will be presented in context menus:

New refactoring

Resharper has already gained a reputation as a tool that helps manage complexity well, and in the 7th release we are pleased to introduce two new refactoring created to simplify the task of managing large amounts of code.

Extract class

What do you do if in your code the class grows to unmanageable sizes? Most likely, you are trying to split a class of several smaller classes. To simplify this operation, we have added refactoring called Extract class . The essence of this refactoring is simple: you choose which members of the class you need to “pull out”, decide what to do with various access problems (if any), and ReSharper does the work of creating a new class for you.

Let's imagine that we have a class Person that has too many address fields that would be nice to put in a separate class:

To provide a separate class for various address properties, we can call refactoring both from the context menu and, for example, from the new Solution Explorer. All you need is to select the properties you want
and use the Refactor This menu : A
dialog box appears in which you can select the elements you want to extract (neologism?) And also name the new class and the variable that will contain the instance of this class in its “Parent”:
Refactoring also gives several options regarding how you can access the pulled property:
There are options:

  • None means that the class member will only be available through the new variable.

  • Create copy will create in the original class an exact copy of the member that you pulled into the new class. If a section of code uses this variable, it continues to use the original , not what it pulled out.

  • Create delegating wrapper creates a delegating wrapper around a drawn item. In other words, all calls are forwarded, for example:

In addition, the Extract Class dialog box clearly illustrates all the possible problems with accessibility of elements that arise when pulling out a new class. For each element selected in the list, the Resharper will show all the other elements that use it:
And in a similar manner, when you select the check box of the element that you want to put in a separate class, the Resharper will show all other elements that will also be rendered in order to save correct execution. For example, when you try to make a method PrintCity() , you will see the following:
... and get the following code:
Well, finally, there will be situations when you have a full-fledged usage conflict: for example, an attempt to pull out private property that is still used in the original class. In this case, Resharper will show you the Stop icon and offer several solutions to this problem:
Options for possible fixes are:

  • Make public just makes the element public.

  • Create accessor leaves the element “as is” but makes it a public proxy element so that the original class can still reach this element.

  • Do not apply fix does nothing, thus you will have uncompiled code.

Please note that at the moment refactoring supports only the C # language. Support for VB.NET may appear in one of the future versions of Resharper.

Transform out parameters

We all had a situation in which we started working with a method that had one return value, and then we wanted to add another one. A typical solution to this problem is to add out parameters, for example:
As an alternative to the approach above, you can use the return type Tuple<Person,bool > and Transform out parameters implements this approach. It is enough to simply call this refactoring on the out parameter ...
... and you will get a dialog box that will show you all the existing out parameters and let you select the ones you want to translate into a tuple:

After applying refactoring, we will have a method in which there are no more out parameters, and which returns a tuple. The internal use of parameters will be rewritten accordingly:
This refactoring is available for C # and VB.NET. Since the class is used here Tuple , refactoring is mainly applicable to projects on the .NET Framework 4 and higher, although in the case of a single out parameter in the void method, refactoring will allow you to translate this parameter into a return value.

And finally, I want to note that if you already return a tuple as a return value, this refactoring will allow you to expand this tuple based on out parameters.

Unit testing

Resarper's unit-test launch mechanism has already become a familiar part of the toolkit for many developers. The ability to run and debug tests from anywhere in the code, coupled with an integrated test launch mechanism, make the process of running tests convenient and intuitive, and the presence of a large number of third-party plug-ins makes it possible to use many popular test frameworks.

Here is a short overview of the new testing features in the 7th Resharper.


In the previous version of Resharper, we made support for the QUnit test framework. In the same release, we added support for Jasmine , a BDD framework for testing JavaScript.

As elsewhere, Jasmine test results fall into the test run window:


In addition to the ability to run tests in a browser, ReSharper 7 offers users an alternative mechanism: the ability to use Phantomjs - the console interface to the WebKit engine - to run tests. To start using it, you just need to open the settings ( Unit Testing | JavaScript Tests tab ) and indicate the path along which PhantomJS is installed: Now all JavaScript tests performed will be executed through PhantomJS and the browser window will not appear. | To start using it, you just need to open the settings ( Unit Testing | JavaScript Tests tab ) and indicate the path along which PhantomJS is installed:
Now all JavaScript tests performed will be executed through PhantomJS and the browser window will not appear.

Improvements to NUnit

Support for the attribute TestCaseSource in NUnit has been added to the testing functionality TestCaseSource . This attribute allows you to set the location of test cases for parameterized tests:
Since this attribute refers to a variable by name, Resharper also checks this name for validity:
... and also provides auto-completion options:

Support for other frameworks

If you want to use a test framework that Resharper does not support "natively" - this is not a problem, because many plugin writers provide support for one or another test framework. To date, frameworks that support Resharper include AgUnit , Gallio / MbUnit , xUnit, and MSpec .

New language support in the ReSharper SDK

From the very first release of the ReSharper SDK, we have been asked about how to add support for new languages ​​in Resharper. There was always the possibility of adding such support, but it was not so simple, so in this version we decided to present users with a complete set of tools for creating lexers and parsers for new languages.


Support for new languages ​​in Resharper requires the creation of lexers and parsers for these languages, as well as the subsequent adaptation of these generated structures to the Resharper API. To simplify this process, we added a folder under the name in the SDK Tools where you can find the following useful tools:

  • CsLex - a tool for creating lexical analyzers for various languages
  • parserGen - a tool for creating parsers compatible with Resharper
  • Java - this folder contains the IKVM infrastructure, which allows you to run the parser generator (which itself is written in Java)
  • MSBuild - contains tasks that allow the project to automate the creation of parsers and lexers


One of the provided tools, parserGen , uses a special format for defining parsers (PSI files) which themselves use a special language. Therefore, we decided to kill two birds with one stone, putting together with the SDK a plug-in that supports the language of PSI files. This allows us to:

  • By providing the source code of the plugin, illustrate the process of creating support for a new language
  • Provide plugin support for creating new languages


In addition to the features described above, Resharper 7 also supports:

  • SharePoint and LightSwitch Projects
  • ASP.NET 4.5 and ASP.NET MVC 4
  • Advanced settings for variable naming (will be useful to those who use different naming schemes for applications and tests).
  • …and much more!

You can try ReSharper 7 by downloading the distribution kit with a 30-day free period .

Developers of open-source projects can apply for free licenses .

Educational institutions may also receive .