Hi, Habr!
You probably already guessed what this post is about. Yes, we are pleased to bring to your attention a fresh
ReSharper 8 , our plugin to improve the performance and quality of the code when developing in
Visual Studio . Thanks to our participation in the Microsoft Visual Studio partner program, we were able to quickly bring ReSharper 8.0 in line with the recently announced version of Microsoft Visual Studio 2013 Preview. Now the product supports as many as five versions of Visual Studio, including 2005, 2008, 2010 and 2012. When the final release of Visual Studio 2013 occurs, if necessary, an update supporting it for ReSharper will be released.

')
The G8 included improvements and innovations in the following areas:
- Code completion;
- Navigation;
- XAML support;
- CSS support;
- New refactorings;
- New error correction mechanism “fix in scope”;
- Templates for creating filesets;
- Architectural tools in ReSharper;
- Simplify work with extensions.
In addition, ReSharper 8 goes beyond Visual Studio: we now provide a free standalone tool with hundreds of code inspections available in ReSharper, as well as a duplicate search function in the code. The new product called
ReSharper Command Line Tools can be integrated with your Continuous Integration server or version control system.
Code completion
The code auto-completion mechanism that ReSharper delivers is a more powerful analogue of the “studio” IntelliSense, and this mechanism has undergone several improvements in ReSharper 8:
Autocompletion for unimported types is no longer shown as a separate blue window - this mechanism is simply included in the autocompletion list:

Choosing one of the options, you not only get the opportunity to add a type, but ReSharper also adds a
using
directive to the file. This mechanism works everywhere: just use types, and ReSharper will help you import them:

In addition, many “regular” auto-completion mechanisms now offer several more “smart” options — for example, if you are creating a collection, ReSharper will offer you an expression to initialize this collection to be the first in the auto-completion list:

The radically new autocomplete feature in ReSharper 8 is double completion. The idea is simple - you can press the auto-completion keys more than once, and each time the auto-completion list will be expanded with new elements. For example, smart autocompletion for a class will show you all the matching elements,

but if you press Ctrl + Alt + Space again, then ReSharper will offer all the options of the "second level", i.e. all the possibilities to get string types by calling various methods on class members, including those that do not return
string
by themselves:

Double completion can be used
indefinitely , each time lengthening the call chain.
Double import completion is also available. If you try to add a type that is not available (i.e., the project has no references to any assembly containing the appropriate type), then nothing happens:

But if you press the key combination
again (Shift + Alt + Space), ReSharper will show you the following list:

By selecting one of the list items, you will immediately do three things: add a link to the desired assembly in the current project, add a
using
directive to the current file, and get a replacement for the type name (if you, for example, used the abbreviation).
Another new feature is generative completion. The simplest example of this is stub generation for overloaded methods. It is enough to write the keyword
override
and ReSharper will offer you all the possible options:

A similar situation occurs when you want to encapsulate a field: all you need to do is write the
name of the property that corresponds to this field, and ReSharper will offer you to generate a wrapper property. Given its usage, it can also offer you a “read only” property:

Finally, the constructor generation mechanism has been simplified — the abbreviations
ctorf
,
ctorp
and
ctorfp
allow us to create a constructor with initialization of all fields, properties, or both, right in the code:

Another new
feature is
autocompletion for formatting flags (formatting specifiers). The idea is that by calling
ToString()
on some standard type from .NET, ReSharper helps you understand what formatting elements exist for this type, what they are for, and also what the end result of this formatting might look like:

Auto-completion also works inside the format specification in the call to
String.Format()
:

Navigation
In our attempts to simplify the navigation mechanisms, we created a new mechanism called
Go to Everything (“go to anything”). The idea is that this mechanism searches simultaneously for all files, types, and elements of types:

We also added the ability to go to a specific line in the file - for this you just need to write its number:

In addition, ReSharper supports the
navigation mechanism
to generic substitutions , that is, the ability to find where and with what types generic parameters are replaced:

In addition, navigation to the source code for decompiled types will take you not to Solution Explorer, but already to Assembly Explorer. To do this, you can click on Shift + Alt + L or simply select the corresponding item from the context menu:

XAML support
For XAML, we have so much for a separate article. Let's start with
autocompletion : now, to create an element in XAML, you just need to write its name, you don't even need angle brackets:

Autocompletion also works, for example, to define properties that define a style:

ReSharper also autocompletes in the
x:Shared
and
xml:space
attributes:

In addition, there are many
inspections and quick correction mechanisms for styles . For example, styles contain unnecessary qualifiers:

If a style overrides a property from another style, ReSharper displays an icon to navigate to the basic definition:

If the property definition is duplicated, then ReSharper will suggest deleting it:

And, of course, if you apply control to the style and then begin to duplicate properties, then ReSharper will complain about this:

Also, to support the styles, we have
new refactorings . The first refactoring is the
Extract Style to pull styles out of inline definitions:

By calling this refactoring, a dialog will appear, allowing you to choose which properties you want to put into the style, and where to place this style:

If you later decide to add some properties to the element to which a particular style is applied, add new properties to this same style as simple as:

In addition, refactorings appeared to “pull out” and move resources defined in XAML. This refactoring allows you to pull, for example, the line:

Moreover, the analysis of the homogeneity of the elements will give you pull out either one instance of the resource, or all identical elements:

Selecting items, ReSharper will show you a dialog where you can choose what the resource will be called and where it will be located:

Now you can move resources by elements using the Ctrl + Alt + Shift key combination and the left / right keys:

Also available is
refactoring of inlining resources (inline XAML resource), which, on the contrary, allows you to pull out a resource and insert it "as is":

Calling this refactoring also has several settings:

Well, finally, there are several other possibilities, in particular, support for atomic renaming of “dependent properties” (as well as events), deletion of unused namespace definitions, as well as contextual actions for the voluntary removal of markup properties.
CSS support
CSS support in ReSharper 8 extends not only to CSS files, but also to use CSS in other languages, such as JavaScript and C #.
Auto-completion in these languages ​​is available for well-known CSS attributes:


And also for class names:


Or for element names:


For auto-completion,
live templates are also used - templates that allow you to more efficiently define values. For example, when determining the width of an element, two patterns are presented:
length
and
percentage
:

Selecting, for example, length (
length
), we get the opportunity to enter the size, as well as select units of measurement from the drop-down list:

Also in ReSharper 8 we check the CSS for compliance with a particular version, as well as compatibility with popular web browsers:

Setting up, for example, CSS for version 1.0, the use of an incompatible attribute will be interpreted as an error:

In addition, ReSharper offers contextual actions for various color representations — either as named entities, or through the
rgb()
or
hsl()
functions:

Finally, CSS has
@keyframe
support for things like
@keyframe
,
@view-port
and
@page
.
New Refactors
In ReSharper 8, we have three new refactoring. The first is that the
Inline Parameter allows you to replace a parameter in a method with a different literal. For example, in the following code

we can change the
value
argument to the value
400
:

If there are several options for the parameter, ReSharper will ask which one you want to use:

ReSharper performs a very deep analysis of the use of parameters. In case the user has to replace the parameter with another one, ReSharper will offer a similar option:

The second refactoring is called
Pull Parameter and allows, if a new parameter is added to the method, select one of the options for replacing these calls based on the entire call chain:

And finally, the third refactoring -
Move Instance Method allows you to move a method from one class to another, while maintaining the validity of all calls.
Fix in Scope
Fix in Scope or “fixed in a specific visibility zone” is the ability to apply a fixed specific type not only to a specific element in the code, but also to a file, a project or the entire solution:

Templates for creating filesets
In ReSharper 8, the Live Templates mechanism was extended to support the generation of several files from one template at once. Creating these templates is simple - for this, two buttons for adding additional files appeared in the template editor:

You can add a file from an existing template or create a new one. In this case, the editor is “divided” into several parts for editing files:

All files of a multi-file template can use common variables, which greatly simplifies the creation, for example, of several different application layers:

Architectural tools in ReSharper
We, like many other developers who work with large solutions in Visual Studio, want to see how projects depend on each other. Unfortunately, the representation of dependencies in the source code ReSharper, which builds
Visual Studio Ultimate , is quite difficult to understand:

As a result, we decided to make our own tool
with preference and poetess to display dependencies in the project, which also allows you to save and compare the state of the solution architecture at different points in time.
How does this work? Having opened your solution in Visual Studio, select the
ReSharper | Architecture | Build Architecture Graph command from the menu:

ReSharper will analyze your solution and display a dependency diagram of all its projects. It is characteristic that you do
not need to compile projects for this:

The location of the elements of the dependency graph is determined automatically in such a way as to achieve their optimal representation. If the
Show Code Metrics feature is enabled (and it is enabled by default), then when building a dependency graph, the link analysis will be asynchronous: ReSharper will analyze the entire solution and show the degree of project coherence (number of links).
All this happens in a separate thread, so while ReSharper is doing its job, you can continue to write code.
There are two types of link arrows in the view:
black arrows show valid links to other projects, while
gray arrows indicate unused links that can be deleted without breaking the build. The scale of the architectural diagram can be selected in
Solution Explorer : for example, if you select only a folder with several projects, only these projects will participate in the diagram. You can also select (element-wise) which projects will be included in the view simply by checking the appropriate box:

By checking one or another box, you can show or hide the corresponding element in the diagram. This allows us to see changes in the representation of links between different subsystems immediately after the item in the list on the left has been selected or deleted.

There are also several options for grouping projects:
None (do not group projects),
Solution folders (grouped by project folders) and
File structure (grouped by folders where files are physically located).
The toolbar also has the following buttons:
- Collapse Graph and Expand Graph allow you to collapse or expand the area in which the grouping is used. The collapsed group looks like this:

- Grouped projects can also be minimized or maximized by double clicking on the + or - icon, respectively.
- The Show / Hide Code button Metrics allows you to hide or show the metrics associated with the project code. These metrics show used and unused links (black and gray arrows, respectively):

- To see where these links are invoked, simply right-click on the indicator and select Show Usages ...
- The Show Transitive References button allows you to display not only direct, but also transit links, that is, in addition to the A → B → C display, A → C appears on the diagram. This can lead to a very dense, radio-electronic scheme, representation:

- The Save Architecture Graph command allows you to save a graph to a file.
- The Show Diff command shows the difference between two architectural graphs. This function can also be called from the top menu (even when the solution is not loaded):

Due to the fact that the architectural graphs can be saved to a file, the user can see the changes in the architectural diagram in the process of program development. The following is an example of how ReSharper shows changes when comparing architectural snapshots "before" and "after":

Here is a representation of the development of one of the subsystems of ReSharper itself. Red are the deleted parts of the solution, and dark green are the newly added parts. Similarly, new and deleted links are indicated.
The context menu familiar from Solution Explorer can also be called up in the Architecture View mode by right-clicking on the corresponding node.

Simplify Extensions
Resharper has its own ecosystem of extensions, and for ReSharper 8 we have significantly simplified the search mechanism for these extensions. Using NuGet and placing
the extensions catalog , you can download and install the plugin in one click:

Conclusion
This is probably all that I wanted to talk about in this article. We will be glad to your questions. You can learn more and download the free 30-day trial version of ReSharper 8.0 by visiting the
product page.
Program with pleasure!
Team JetBrains.