How I use jetBrains ReSharper

At work I have jetBrains ReSharper, but I haven’t used it that much – mainly because of the kind of coding I have been doing there lately (quick samples and small proof-of-concepts). However, at home, I am always refactoring old, bad code… which I wrote, and now know better! Also, I have several newer projects that I’m working on, where refactoring is a major part too.

Anyhow, I don’t have ReSharper for personal-use, but I am considering buying it (it’s $150 though). I’ve been using the demo/trial version. I find it immensely useful for my personal coding projects. Why?

Let me show you the really cool things this does and why I am now such a fan of this product.

Promote a constructor argument to a property:
Suppose you have a constructor where you pass in an argument. You want to validate to make sure it’s not null and you want to set it to a public property. You can do that in 2 steps (when you are on an actionable item anywhere in code, hit ALT+ENTER, so while my cursor is on gameManager, for example):



Hit ALT+ENTER again:


You end up with this, about 2 full seconds later:


If you were to type that out, that might take 20 seconds maybe? So, a 10x savings? I’ll take it!

Automatically created the constructors from an inherited class:
Suppose you inherit from a class which has constructors which take in arguments. Normally, you’d have to click on the base class name, hit F12, copy, go back to your file, paste and then clean-up. With ReSharper, again, one step – hit ALT+ENTER:



Change visibility and override:
Let’s say you just created this method which you know is in the base class. You meant to override it, but you aren’t sure if it’s public or protected, etc. Again, just ALT+ENTER, you can clean it up:


With my customer on Update, I hit ALT+ENTER, and choose “Make method ‘Update’ override”:




And for other members, if I want to change the visibility – just ALT+ENTER:




Generate code, then move it to files:
A common thing you can (and should) do is to create data structures based off of how you need them. Then, once the API looks correct, in Visual Studio you can right-click and “Generate” that class and method. ReSharper takes this a step farther.

ReSharper first, creates the class and its’ members, in the same namespace, in the same file you are working on. This is of course convenient while you are still figuring out the API. You can easily go between these classes as you are figuring things out.

However, once you have a good idea that the class is stable, you want to move it to it’s own file. Same thing, highlight the new class and ALT+ENTER:



This moves this newly-generated class to it’s own eponymously-named file!

Publishing your exceptions to XML code comments:
This is one of things where I am a big believer in doing it, but it is tedious. Suppose you do argument validation, and you want to add the exception information to your XML code comments. You normally have to type it out. There isn’t any intellisense in the exception name, so you have to have that just right. It’s not a huge deal, but it’s annoying and tedious.

Well, with ReSharper, you can put your cursor on an ArgumentException (or derived exception), hit ALT+ENTER and have it add it for you!!



It adds the lines that are highlighted below. If you do component documentation, you know what a convenience this is


Bottom Line:
The bottom line for me is that when you are cranking through code, and using ReSharper, almost anything you can possible do with the current member, you can do with ALT+ENTER. I can’t tell you how many hundreds (thousands?) of keystrokes this has saved me.

By the way, I am not affiliated with JetBrains at all, I am just really impressed with this product. I know since it can be a complicated program to learn, some people have shied away from it.

So, I thought I’d share the things I use all the time. If you just use ALT+TAB, that will get you up and running and will really have an impact on your efficiency.

Posted in Computers and Internet, Development Tools, New Technology, Professional Development, Uncategorized, Visual Studio
One comment on “How I use jetBrains ReSharper
  1. […] Adding XML code comments to every public class and public member, remembering to “publish” which exceptions can be thrown, in the XML code comments with an <exception cref=””/> tag (PRO TIP: ReSharper can do this for you!) […]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 9 other followers

%d bloggers like this: