I love R# because it reduce mouse usage

I have this piece of code




And doc2 is checked because it could be null, so I can ALT+RET and choose the right action, as example check if doc2 is null


And I got this


With a couple of click on the keyboard, if you to not like all of the code to be indented inside the if you can press ALT+RETURN on the declaration of the doc2 variable


Resharper add an if and the caret is positioned on the default action, that is throw NotImplementedException, so you can just type return; and the game is done


Such operations are so common when you write code, that the ability to issue such check without leaving your finger from the keyboard is invaluable.


How could I work without resharper

In a system that use heavily IoC principle, it is common during component modification, to discover that to add a new functionality that component need to add a dependency on some interface. Here is the constructor of a component

   1: public MainNavigator(

   2:     IEBrochureService brochureService, 

   3:     IBroker broker)

   4: {

Now I need to add dependency from the IWpfSystem interface, so I simply add another parameter to the constructor, and R# suggests me a lot of action that could be triggered from this modification


The first one automatically declare a field called _engine and initialize into the constructor, but I have a lot of other options, like applying change signature refactoring, and change all call to this constructor, creating an overload version without this new parameter or even check for null assignment.

Shortcut like these one can tremendously boost up your productivity.


Resharper live template are the solution to many problems

Surely when you write code you write a lot of similar snippets, as an example, defining properties in objects that should implements INotifyPropertyChanged is usually highly repetitive, I write my properties like this one.

   1: [DataMember]

   2: public Int32 Rank

   3: {

   4:     get { return _rank; }

   5:     set { this.Set(p => p.Rank, value, ref _rank); }

   6: }

   7: private Int32 _rank;

DataMember is needed for WCF, and the setter part is based on some base class and some helpers that raise INotifyPropertyChanged etc etc etc. Writing many of these is really tedious, so it is time to write a VS Snippet or still better, a Resharper Live Template.

The main difference is that R# has the concept of macro, writing such a snippet requires that the name of the field is the same of the property, but with first character lowercase and prefixed with a  _.

Here is the template in R#.


Figure 1: Live template in action

Now You can simply assign a shortcut to this template and defining new properties is really a breeze.


Temporary disable Resharper 5

R# is really useful, but sometimes, when I’m working to very big web forms or winform projects, and I know that I do not need R# feature because I’m only designing the UI, it can be useful to temporary suspend R#, freeing memory and speeding a little bit VS.

In R#5 the option to disable it is in the Tools->Options menu


Where you can easily stop and resume R# functionality. But the coolest feature is that you can simply disable and reenable R# with command Windows


You also have intellisense :), so you can enable/disable in seconds 🙂