ReSharper Downfalls and Anti-Patterns


As part of a dedicated refactoring team in a big customer project, I get to use JetBrains ReSharper quite heavily on a daily basis. If you didn't know already, ReSharper is the best refactoring tool made for Visual Studio. Not only does it increase programming efficiency by multitudes, it also changes the way you think as a programmer. Especially when you've just started out on your programming career. I've been using ReSharper professionally for at least three years, and today I can't even imagine how I survived as a (.NET) programmer without it.

Ironically, it wasn't until I joined a professional refactoring team that I discovered the downfalls and anti-patterns of using ReSharper. Without doubt, the tool is continuously being developed by a brilliant team, so the downfalls that I see today may very well be investigated in the next versions of the tool. There are also some features that ReSharper simply lack today, that I hope will be added in the future. I will explain what I am talking about in the next sections.

Helper Methods are Extracted as Static by Default

If you press Ctrl+RM you'll get the option to extract a method. A local helper method is by default extracted as static:

Capture

You get to choose whether to make it static, but it is static by default. You'll find that this is extremely annoying, as there is a chance that you have to insert non-static content in the method at a later time. So, the fix? Remove the static part manually (!). Note, in the following animation below, the lack of intellisense as I start typing the _webRole object:

animation

This may not be a big deal in a small project, but it quickly becomes cumbersome in a big legacy application.

Lack of Listing Multiple Object Properties Feature

Very often you will create objects and want to set their properties. There is no way to list all the properties of the created object, leaving you having to manually type and set each property:

properties

Wouldn't it be nice to have ReSharper list all the properties for us?

Lack of "Find Usages in Multiple Solutions" Feature

One of the most fundamental things when you are refactoring a huge application with many solutions, is the ability to locate the usage of a component across those solutions. If you right click on a class or method and choose "Find Usages Advanced...":

find_usages

ReSharper will show you a dialog where you can choose where to search:

find_usages_2

What would be nice is to have the option "Solutions..." where you can specify solutions or simply choose all. This makes our life easier, and saves us the need to open each solution manually and perform the search per solution.

Refactoring Overkill

This one falls under anti-patterns. Every now and then, ReSharper will suggest refactorings that actually break readability of your code. Inverted ifs and complicated LINQ expressions fall under this category. How many times has ReSharper asked you to invert your if statement when it looked perfectly readable? Or how many refactorings were you asked to do by ReSharper on your one single LINQ expression? Chances are, many times. There is no need to invert your if, if you and your code reviewer agree that it looks fine. Although you can probably turn off this type of suggestion, ReSharper should be intelligent enough not to ask you to do this.

Complicated LINQ expressions, where do I start? Once you write a LINQ expression that does something, ReSharper will often suggest to write it differently. As the expression gets more complicated, so does ReSharper. It will ask you to keep refactoring, sometimes up to 3 times (!) on a single LINQ expression. The ending result is a hideous piece of code that takes time to understand. So again, ReSharper should be intelligent enough to take readability into account here.

Different Key Binding Schemes?!

Something that has annoyed me recently is that the key binding schemes of ReSharper seem to vary from environment to another. Ever since I installed ReSharper 8.1 (which I upgraded to 8.2 today, by the way), the schema on my development machine has changed, and I have to memorize different key bindings. This is a hassle when I do pair programming with another developer using his machine, as he would have the older schema. Ultimately I memorized both schemes in order to work efficiently. You would think that simply applying the Visual Studio schema would make things consistent in all developer machines:

Capture

In final words, ReSharper is a wonderful refactoring tool that I will be using for years and years to come. That doesn’t by any means make it perfect, and there are still features that I see lacking. Seeing how the ReSharper team is doing an incredible job developing the product (ReSharper 8.2 was just released), I’m not worried that they’ll look into this and make our favorite tool even better. :)

PS: I used LICEcap to create the gif animations in this post.