Developer productivity: should you be using ReSharper with Visual Studio?

occadmin

Given the amount of time that software developers spend writing code, the range and capabilities of the tools available to them should be carefully considered. When coding in C#, Visual Studio is likely to be a top contender among the list of available software packages. OCC often uses it for C# programming – it is after all developed by Microsoft, who created and develop C#.

Many of our developers also use a Visual Studio extension called ReSharper. It has been written by JetBrains, who created the Visual Studio competitor, Rider. ReSharper frequently adds features that do not exist in Visual Studio.  Yet in certain areas, there is debate over whether Visual Studio’s offering exceeds that of ReSharper. ReSharper frequently adds extra features to Visual Studio, or modifies those that exist already. However, it is not without its downsides and some developers prefer the raw Visual Studio experience.

As part of a periodic review of our tools, we looked at whether ReSharper is beneficial overall, and whether it offers value for money. We cannot comprehensively describe the myriad of features available in Resharper and Visual Studio here, but we have covered some important points. The list is focused on C#, but ReSharper does also support other languages.

Code Analysis

FeatureHighlighting of unused items
AnalysisRaw Visual Studio dulls unused function parameters, local variables, private class members and using directives. ReSharper is more global in its analysis and additionally dulls unused class declarations, as well as protected and public members.
WinnerReSharper
FeatureImprovement suggestions and warnings
AnalysisRaw Visual Studio will highlight when a field can be made read-only, when a method can be made static, when code is unreachable and when a null reference exception might arise. ReSharper adds to this, e.g., warnings when virtual members are used in constructors and when a field can be replaced with a local variable.
WinnerReSharper
FeatureCoding standards monitoring
AnalysisVisual Studio allows the authoring of .editorconfig files, which you can use to specify your policies for whitespace, code style, naming and analysis. However, the options for naming styles are very basic. ReSharper offers more options for including prefixes, suffices, capitalisations and underscores to be used on each of the many different named items in the code. Also, it provides useful previews of the conventions as you edit them.

Both allow you to share your choices with your team via version control, but if part of your team is not using ReSharper they will be oblivious to the ReSharper specifications.
WinnerReSharper (if your entire team is using it)

Code refactoring and auto-generation

FeatureNamespace and directory structure synchronisation
AnalysisRaw Visual Studio will create a new class file with a namespace inserted that matches the directory structure. Also, if you later move the file, it will ask you if you wish to update the namespace declaration. It will not, however, offer any help when you rename a folder, nor will it highlight a mismatch. If you put the cursor on the declaration or right click on it, then it will offer a lightbulb icon which you can use to correct the declaration. It can correct the effect of a particular mismatch across the entire project or solution.   ReSharper highlights the issue with a blue underline. It can fix the declaration, move the file to the correct folder, or fix all namespace mismatches across the folder, project, or solution.
WinnerReSharper

Feature

Addition of using directives
AnalysisWhen you introduce code from a namespace that is not registered in in your file, raw Visual Studio will inform you of the issue and suggest adding a using directive to correct it. It will even offer to install a matching package from NuGet if that is the problem. ReSharper’s offering is similar but offers to fix all such issues in one go. It does not hide Visual Studio’s NuGet lookup, which can be a faster option than its own, but when Visual Studio fails to find the correct NuGet library, ReSharper offers a better user interface.
WinnerReSharper
FeatureFunction refactoring
AnalysisRaw Visual Studio’s lightbulb menu gives the option to “Change signature…” of a function. Through this, you can change the order of parameters solution-wide, remove existing ones or add new ones (though the latter two will require code changes or review). ReSharper provides the same from its “Refactor” menu, but it is better. For example, you can make a parameter out or ref.
WinnerReSharper
FeatureConstructor and dispose auto-generation
AnalysisOne of Visual Studio’s much-hyped offerings is its IntelliCode auto-generation feature. If you type out a class with some public properties and then add what looks like the start of a constructor for the class, it will offer to complete that with a function that populates all the properties. In my experience, deviating from the above route, e.g., adding a protected property, can easily make IntelliCode no longer offer this. Raw Visual Studio also has a more traditional means of achieving this via the lightbulb icon and it is more customisable: you can decide which parameters to include. It will also offer to generate Equals and GetHashCode. ReSharper’s offering is similar and available through its Alt+Insert menu. It is slightly better and also offers the generation of CompareTo and Dispose.
WinnerReSharper

Miscellaneous

FeatureSpellchecking
AnalysisReSharper adds green underlines where it detects spelling mistakes in comments or parts of identifiers. It also maintains a user dictionary that can either be shared with your team via a solution-level file or kept personal. Visual Studio does not provide this useful feature.
WinnerReSharper
FeatureValue origin and destination
AnalysisRaw Visual Studio has a “Track Value Source” option that can tell you where a variable value has come from. ReSharper matches this but yields a better user experience via it’s Inspect > Value Origin option. It does the same for value destinations.
WinnerReSharper

Additional considerations

In terms of features, ReSharper has a lot to offer and there are many more options that could have been listed. However, only listing the features would be giving only half the story. There are also the downsides of ReSharper listed below to consider.

Reduced user interface performanceReSharper tries to do more than Visual Studio in terms of code analysis – and must do so via the Visual Studio Extension pattern. Visual Studio therefore runs slower when using ReSharper. This is most noticeable when first opening the solution, and Visual Studio will sometimes even warn you that it has been blocked for some seconds by the extension. You can turn some of the analysis features off, but then you are watering down ReSharper.
Added complexityThere is another layer of software involved and another place where configuration can lie. In some places, ReSharper hides the Visual Studio user interface components (e.g., it replaces Visual Studio’s lightbulb icon with its own) but in others you end up with duplicated options. This means it is a little harder to find the option you want from the longer list.
LicencingThere is the cost of purchasing a licence, and at an organisational level there is the work of managing those.

Overall conclusion

ReSharper is probably a useful extension to Visual Studio and it is most likely worth the licence cost. Although Visual Studio can easily be used on its own, developers who do so are missing out on some useful additions. At OCC we decided to renew our ReSharper licences again and offer it to any team that wants it. However, we expect to continue to review the situation as updates to Visual Studio are released.