It was once received wisdom that any developer using Visual Studio should use Resharper.  But its not so clear-cut today.  I’ll argue that when using Visual Studio 2015 Update 2, Resharper is no longer a pre-requisite for C# coding, although you may still want it for JavaScript and TypeScript.

Going native

What got me thinking about whether I need Resharper was trying to use it with a Hyper-V virtual machine on my development PC.

Resharper changed their licensing in 2015 so you can only have one instance of Resharper running on a physical PC at a time. 

So if you have Visual Studio running, then connect to a Hyper-V virtual machine on the same hardware which also has Visual Studio running (which I often do to keep environments separate) Resharper disables all but one instance of itself, with an error message starting:

Another instance of ReSharper with the same License ...

JetBrains did partially respond to feedback on this for personal licences, but it is still a problem with commercial licences.

So in practice, Resharper keeps disabling itself, which felt like a hint that I should try living without it!

C#

Native Functionality

The perception of Resharper is that it patches missing functionality and keyboard shortcuts that Visual Studio doesn’t have.

This may have been the case in the past, but when you uninstall it (or have it disable itself, as above) you suddenly find most of what you were doing via Resharper is now available natively in Visual Studio too.

And in fact Resharper even sometimes hides native functionality that is arguably better.  For example, both Resharper and Visual Studio use the chord Ctrl+R, Ctrl+R to rename a method.  But in Visual Studio you get a nice preview window of the changes which you don’t get with Resharper.

Note: after uninstalling Resharper you may need to reset your keyboard mappings to re-enable Visual Studio’s defaults:

Tools => Options => Environment => Keyboard => Reset

Refactoring Suggestions

Resharper often gives you hints about possible refactorings.  A common example being turning a foreach loop into LINQ.

But now that Visual Studio uses the Roslyn compiler a whole range of Analysers for refactorings can be included with a project. 

A couple of these are included already (eg to give hints about where C# 6 functionality can be used) and more are undoubtedly on the way.

There is also a free refactoring extension using these Analysers Refactoring Essentials for Visual Studio.

What’s Missing?

There are a couple of things I used every day with  Resharper that I can’t find a native equivalent for. 

For example Resharper’s Ctrl+R, Ctrl+F to take a constructor parameter, add a private, read-only backing field and set the field to the parameter’s value in the constructor.

There is a similar refactoring for this in the Refactoring Essentials add-in, but at the moment the refactoring is not configurable for your coding-style preferences, so it results in output like:

readonly IEnumerable<int> items;

public MyClass(IEnumerable<int> items)
{
    this.items = items;
}

Whereas Resharper (along with my personal preference) would have resulted in:

private readonly IEnumerable<int> _items;

public MyClass(IEnumerable<int> items)
{
    _items = items;
}

There is an open issue on the Refactoring Essentials to introduce some coding-style configuration options.

Resharper also have their own comparison chart with Visual Studio 2015.

Useful Links

MSDN

- Default Keyboard Shortcuts

- Tips and Tricks for Visual Studio

- Productivity Tips

Stackoverflow

- Favorite keyboard shortcuts

My Favourites

Below are some of the native commands I’ve found particularly useful myself.

KeyCommand
Ctrl+K, Ctrl+CComment selection
Ctrl+K, Ctrl+UUncomment selection
  
F12Go to definition
Shift+F12Find all references
Ctrl+F12Go to declaration
Alt+F12Peek definition
  
Ctrl+FFind
Ctrl+Shift+FFind in files
  
Ctrl+C, Ctrl+VDuplicate the line the cursor is on
Ctrl+LDelete the line the cursor is on
  
Ctrl+Shift+VPaste/cycle through clipboard contents
  
Ctrl+K, Ctrl+KToggle bookmark
Ctrl+K, Ctrl+NNext bookmark
Ctrl+K, Ctrl+PPrevious bookmark
Ctrl+K, Ctrl+WView bookmark window
  
Ctrl+-Navigate forward
Ctrl+Shift+-Navigate backward
  
Ctrl+,Find & navigate to an item (like Resharper's find type)
Ctrl+;Find matches and show in Solution Explorer
  
Ctrl+]Find matching brace for ( { [
Ctrl+Shift+]Find matching brace and select all between

JavaScript & TypeScript

Somewhat to my surprise, Resharper still has a lot to offer when working with JavaScript and TypeScript in Visual Studio.

Visual Studio won’t even help you rename a variable within a function.  And if you are using TypeScript, there are no code-snippets (so you have to manually type out your “for” loops in full, for example).

However if instead of Visual Studio you use the more front-end targeted Visual Studio Code, you do get these essential refactorings and code-snippets.

Visual Studio Code

This stand-alone editor is meant for front-end coding.  I’ve yet to use it on a live project, but a quick explore shows it has JavaScript refactorings and TypeScript code-snippets that are missing in Visual Studio.

So if Visual Studio with Resharper is not available, Visual Studio Code definitely looks more useful than just working in Visual Studio.

One interesting aside is that Visual Studio Code seems to share many of the keyboard shortcuts with Visual Studio, but as a consequence of it being a newer product has been able to add a few new ones (see Key Bindings for Visual Studio Code).

For example there is a Ctrl+/ for toggling a line comment and Shift+Alt+A for toggling a block comment.

Comments


Comments are closed