Jet Brain's Resharper FTW!

by jmorris 26. January 2015 14:01

For the last 8 years, Jet Brain’ Resharper has been a must have add-on to Visual Studio for me and many other .NET developer’s. Simply put, the productivity and features that Resharper provides enables me to write quality code, faster and with less bugs than by using Visual Studio alone.  When I started working on Open Source projects a couple of years back at Couchbase, nothing change: Resharper and Visual Studio remain my primary tools.

In this post I’ll go over some of the features that I believe make the Resharper and Visual Studio combination a win!

Running Unit Tests

One thing that Visual Studio has lacked is first class support for 3rd party Unit Test Frameworks, such as NUnit; instead you are forced into using MSTest (although support was added in later years for other frameworks if you have the correct license). Additionally, depending upon you license you may not even have the ability to run Unit tests directly from the IDE. You simply right click on the project and select “Run Unit tests”.  Resharper adds support for running Unit Tests from the context menu if you are using NUnit or MSTest; there are plugins for other 3rd party libraries such as Importantly, it’s “frictionless”: right click, “run unit tests” or CTRL + U, R. Boom. Tests are running!

A couple of cool and useful features that I use quite a bit are:

  • “Show Time”: The ability to enable timings for each test which is very helpful for identifying slow tests which may indicate issues for further investigation or refactoring.
  • “Track Running Tests”: will show the running test at the top of the current Session dialog. This make it easy to see which test is currently in progress.

These are both just toggled on/off from the unit test Session Dialog:

In the image above, the “paw” is the “Track Running Tests” toggle and the “clock” is the “Show Time” toggle. Cool stuff.


Refactoring is one thing that Resharper excels in. Most of the features that Resharper have seem to be borrowed from the Java world of Eclipse or Intellj, which makes switching between IDE’s easier. The refactoring features I use most often are:

  • “Rename”: rename a method, Type or namespace
  •  “Change Signature”: safely change the signature of a method
  •  “Push member up”: make an existing method, field or property a member of a base class or interface
  • “Extract Interface/Super Class/Class” – make the a new Type from the existing type

The refactoring features make it easy to make changes to large class libraries without fear of introducing bugs. The refactoring allows you to review proposed changes and also cancel the changes if you detect a conflict. In addition, Resharper will make recommendations based off “Code Smells” and warnings and offer quick fixes. In general these are spot on, but you must ensure that the proposed change doesn’t have any or side effects and or matches your intention. If not you can ignore the recommendation and provide a hint to Resharper to tell it to longer warn or suggest the change to you.

Namespace Suggestions

I am not sure what the exact feature is called, but I like it! What is it? Well, when you start typing the name of a type you wish to use in your code or when you cut and paste code from an example and want to try out, the project may not have references to it or the file may not have the correct using statements. This feature will inspect your project and try to reconcile the using statement to add.

This makes it so much easier to get up and running. I can’t tell you how many times I have answered forum questions where a user simply cannot find the reference. You can also use this as a development tool to create classes, properties, etc. while you write your Unit tests or other code. Very useful.


For me, Resharper is a must have add-on for Visual Studio. Without it, I simply don’t feel as productive as I could be. In a way I feel like I am coding with blinders on, I simply don’t have the information (about the code) and tools I need to succeed. I only went over a handful of features, but those are the ones that I use most often and the ones that I feel add the most value. If you haven’t tried Resharper, take it for a spin; you may just find that missing addition to Visual Studio that makes your productivity skyrocket and your code quality increase.

Tags: , , ,

Refactoring 101: Method Groups

by jmorris 4. November 2010 14:10

C# allows method group conversions, which simplify the invocation of delegates within your code. This is a feature that was added to C# 2.0 and when combined with the Linq extensions provided with .NET 3.5, you can drastically shorten and simplify code.

“Similar to the implicit anonymous method conversions described in §13.5, an implicit conversion exists from a method group (§14.1) to a compatible delegate type. If D is a delegate type, and E is an expression that is classified as a method group, then D is compatible with E if and only if E contains at least one method that is applicable in its normal form (§ to any argument list (§14.4.1) having types and modifiers matching the parameter types and modifiers of D.”

Basically what the above means that the compiler is “smart” enough to infer the correct overload to call given that their is an adequate candidate method available. For example, given the following two methods:


First we can refactor the for loop using lambda expression and the Linq extensions:


Then simplify the lambda expression even further by substituting for the implicit method group conversion:


Note that the green squiggly lines are hints made by Resharper that the line of code can be refactored. If your not aware of Resharper, it’s a Visual Studio add on that turns VS from a Pinto to Ferrari! If you don’t believe me, try the free trial here. Ok, enough cool-aid and free marketing for resharper…

So, your probably thinking one of three things about now (assuming  you made it this far):

  1. “Big fricken deal, he saved five lines of code”
  2. “Eh, old news. Moving on.”
  3. Wow, that’s fricken awesome dude!”

Personally, I tend towards #3. I am a huge fan  (obviously) of method group conversions because they reduce complexity. They simply make the code easier to read and digest. Code that is easier to read and digest is more easily maintained. Code that is easier to maintained, tends to be of higher quality and less error prone.


Tags: , , , ,

Refactoring | Resharper | C#

Resharper Hides Configuration File Error

by jmorris 21. January 2010 16:14

I just spent a frustrating two hours trying to get a unit test to run via Resharper for nada. The test would start and then exit as if the it was working but instead of showing a green or red icon as expected when the test was finished, it would remain 'grayed' out. I tried the usual: delete bin folders, run solution 'clean' via VS2008, delete the code directory and do a fresh SVN checkout. I even rebooted for nothing: no red, no green all gray:

I finally noticed that I had closed the output window of VS, so I couldn't see the build results. When I opened the output window I saw this exception at the very bottom of the list:

A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in JetBrains.ReSharper.TaskRunnerFramework.dll
The program '[1012] JetBrains.ReSharper.TaskRunner.exe: Managed' has exited with code 0 (0x0).

What the f#*k? A configuration error was causing the Resharper taskRunner to die quietly? You have to be kdding me! Shouldn't the user be alerted if the software could not recover and had terminate? I mean, yeah it _did_ notify me, but not very explcitly - a pop up would have been nice!

Anyways, issue was found: I commented out the starting element of the ConnectionStrings section of the App.Config and when Resharper process tried to load the config it bombed. Crises averted, now back to work.

Tags: , , ,

I Broke Resharper! Or was it TypeMock?

by jmorris 15. May 2009 22:56

I was trying to test a IEqualityComparer implementation today, when Resharper kept crashing:


I tried rebooting, rebuilding everything. I finally clicked 'Debug' and waited...nothing happened after a few minutes, so I tried re-installing Resharper to no avail. By this time I was bruning through  my day, running out of time (deadlines, blah).

I clicked 'Debug' again and once again nothing happened....for awhile. I got up and ran a few 'errands' and came back an viola, I found my problem:


It was just a StackOverFlowException caused by my poor implementation of IEqualityComparer. Once I saw this I knew immediatly what was going on and how to resolve it. Of course, Resharper stopped crashing after I fixed the bug.

The big issue was why Resharper didn't handle this and just display the stacktrace as usual. It might be related to the fact that the exception was generated in TypeMock.dll, AFAIK I was not using TypeMock for this Unit test and there are no references to it in my project...weird

Tags: , ,

Jeff Morris

Tag cloud

Month List

Page List