Home > Uncategorized > Visual Studio Tooling, Resharper, and the Developer Circle of Life

Visual Studio Tooling, Resharper, and the Developer Circle of Life

Visual Studio is pretty good. 2008 came a long way and I really enjoyed jumping to it with some production apps with the beta 2 release. But I also had those same thoughts about VS2005, and to be honest, VS2003 was a god-send after VS2002. I guess the point is that when something is new, such as an IDE or a language, you start to learn all the little tricks, and they’re all great. Productivity is enhanced, you discover new ways of doing things, and you hit this little peak for the year where you really enjoy what you do.

Invariably that peak levels off as the new and interesting becomes the common place. You start looking forward to the NEXT release and the productivity gains it will bring. I call this the ‘Developer Circle of Life’. We are invariably bound to it and cannot escape. Whatever we have now, we want it faster, with new features, and some new technologies to boot.

Its those middle months that suck the most, the longing, wishing you were using V.Next on your current project, and that everything is so hard and slow. So what can you do until that beta 2 ‘go live’ license to improve your developer experience? Where can you get more productivity gains? Well there’s a suite of plugins and tools you can install that work integrated or in parallel with Visual Studio out there. One of the most common is Resharper, and I’d like to share some of its qualities with you.

Resharper

Ok so I used to be that guy that wanted everything vanilla. Default options all the way. It allowed me to move between client sites easily and be completely operational immediately. When I hit a computer with Resharper, I’d immediately know because VS would start closing my brackets and quotations for me automatically; that was the hallmark of R#, and I would immediately disable it. But in the last year I’ve been really focusing on doing WPF work (I’m even launching a new WPF blog – coming soon) and found the VS2008 XAML editor to be loathsome. I mean, it just seems to be notepad with syntax highlighting and a little bit of intellisense – that’s it. Others around me were using R# so I bit the bullet and installed the trial.

Ok I got used to the closing brackets/quotation thing quickly. Even VS will close XML elements and quoted attributes for you. I got over that issue pretty quick and to be honest, I could only find two other griefs with it (I’ll mention them below) – otherwise there wasn’t much else to complain about.

But the benefits? Wow.

There’s so many things that you just keep discovering all the time, but there is definitely a few standouts that I use all the time. Here’s 5 of my favourites:

1. XML Namespacing

In XAML editor, you get a lot of improvements around refactoring but the feature I enjoy the most is the auto-discovery of namespaces. Lets say you have a control that you created and you want to declare it in XAML. In plain old VS (hereto referred to as POVS) you first have to find your namespace with the intellisense in the Window element at the top of your editor, declare the namespace prefix, then come back down to where you want your control, and instantiate it. With R#, you can just declare <myControls:SpecialControl /> and press the R# magic key combo of ALT+ENTER and walla! It discovers where SpecialControl is within your application and inserts the namespace automatically, and even calls it ‘myControls’ for you. This is a very quick operation that makes it easy to get your XAML bashed out faster, but also for the absent minded like me, means I don’t have to remember the namespace for my controls!

2. Convert Property to Backing Fields

You’re probably familiar with code snippets in POVS. In VS2005 I used the ‘prop’ snippet all the time; this created a public property with a private field backing it. However when VS2008 came out, they replaced this snippet with a new one that created an ‘automatic property’ instead. Automatic properties are extremely short and concise already, so its beyond me why the VS team would not leave the original prop declaration as is. R# to the rescue! You can quickly create an automatic property, and then using ALT-ENTER convert it to a property with a backing field. Given I do so much WPF (and love the MVVM pattern), I tend to need properties with backing fields all the time (for my little friend INotifyPropertyChanged). I love this feature. Oh, and it converts back to an automatic property as well if you don’t like it.

3. Go To Implementation

Or CTRL-F12. I also use a lot of IOC which means interfaces hiding my implementations a lot of the time. Also its a services world, and WCF patterns see interfaces for contracts as well. POVS had the F12 ability – go to definition, which bounced your cursor to wherever the item you clicked on was declared. BUT if this was an interface, well you got dumped at the interface. Fear not! R# lets you go to the actual implementation of your interface instead. You can actually count the time this saves in a day in terms of minutes I reckon. Oh and if more than one class implements the interface, it gives you a list to choose from of course!

4. CTRL-T

I’m sure this has a proper name, but I just call it “THE GREEN BUTTON” since it is such an enabler. Basically, need to know where something is? CTRL-T will find it. Its the enhanced search aspect of R# but its killer feature is that you can type in the letters of your class based on its pascal case definition, and it will be returned as a search result. I know that crappy description really does describe it correctly, so I’ll use an example. Lets say you have a class called ‘VolumeIntegrationProvider’ (which I do) – you can press CTRL-T and type “VIP” and it will find that class! So you see what I mean about the pascal case?

5. Initialise Field From Parameter

Another thing about IOC is that you inject a lot of classes into your constructors. Its then a manual task to create a private field within your class to store that parameter, and of course the code in the constructor to assign it:

private IVolumeIntegrationProvider _volumeIntegrationProvider;
public MyClass(IVolumeIntegrationProvider volumeIntegrationProvider)
{
    _volumeIntegrationProvider = volumeIntegrationProvider;
}

This really is time consuming, but with R#, you only need to declare the constructor parameter and ALT-ENTER takes care of the rest! This is another one of those features that saves you minutes a day (hmm, there seems to be a few of them!).

Dislikes

The first is that sometimes the R# intellisense/autocompletion is not fast enough for me. Somehow I just know that a class name is unique after the first 4 characters (perhaps I’ve just typed it 3 times before) and so I’ll bash out the keys really quickly. For example, imagine I wanted to type this:

if (_volumeIntegrationProvider is IVolumeIntegrationProvider) …

So I’d type the following characters: 
i f SPACE ( _ V o CTRL-SPACE SPACE i s SPACE I V o CTRL-SPACE ) ENTER

(CTRL-SPACE is auto-completion, so it should fill in the remainding characters for that class/interface)
Generally I’ll bash out those key commands so quick that Resharper can’t react in time, and the result is a complete mess on my screen. This takes time to mend. Subsequently I’ve become tuned to slowing down on auto-completion.

The only other dislike I have is that R# leaves your VS in a bit of a mess when you uninstall it, the worst part being that your intellisense and other features might actually be disabled. However this is pretty rare and really isn’t such a big deal.

All I can say is that you have to give R# a try. Install the trial and see how you go. I bet that after the trial expires you’ll be forking out the measley few USD it takes to get it going again. =)

Other Tools

As a user of TFS, I quite like the TFS Power Tools. This provides some must-have extensions to the command line configuration of TFS, as well as shell integration for your source control. I also usually install the VS2008 Power Tools which gives you some useful functions like being able to copy-paste your assembly references. I used to think RockScroll was cool, but lately I think it just steals too much screen real-estate and it doesn’t deal with collapsed code very well.

Its not very 3rd party but when it comes to dealing with the designer aspect of XAML (building UI that looks good) I actually prefer to use Expression Blend, and I’ve even taken the leap into Expression Design lately to build some of my assets and icons. I’m really enjoying those products but am also suffering some of those random crashes people have been complaining about. Even still, Blend 3 is awesome and sometimes I just sit in there and bash out ideas for fun.

About these ads
Categories: Uncategorized
  1. Rachel
    October 16, 2009 at 11:20 pm

    Hi Steven,Really interesting post. How long did you work with ReSharper for before you realised that it was actually working out well for you?I was wondering if you had considered trying out CodeRush from DevExpress as a possibility too? [DISCLAIMER: I work for DX] I find the ways that people come across different "productivity" addins really intruiging … I wonder, do you think there is a significant hump that you have to get over with any productivity tool before you actually mould and adapt yourself to it to allow it to improve your day-to-day work, like you experienced with the lag in the intellisense? Presumably the other benefits you were seeing must have almost instantly outweighed that?Just curious :)Best wishes,Rachel.(rachel h at devexpress dot com)

    • November 15, 2010 at 5:01 pm

      Hi Rachel, well this reply is a little late I guess :) I’ve just ported my blog to wordpress and noticed it filtering out some of the spam comments now, which allowed yours to filter to the top!

      Even to this day I sometimes find some lag in the intellisense but it does get far outweighed by the other features. As a XAML developer I find the value it adds there is enormous. I used to balk at the idea of installing Resharper due to having to learn it and not being ‘power of defaults’ however nowadays I even use it as the style guidelines for projects with multiple developers (eg. all private fields start with _underscore). I haven’t tried CodeRush although I’ve seen another developer use it daily on a project we were both working on. For me it seemed to add a lot of spam on the screen, but I really shouldn’t comment until I try it out properly.

      Steve

  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: