Sunday, January 10, 2010

Resharper 5 Beta Impressions

Being a Resharper user for the past 5 years, I had to jump on opportunity to try out the publicly released beta for the new 5.0 version.  I’m currently using Visual Studio 2008, but I’ll be glad to have the updated VS2010 support from Resharper once it’s released.  As for the changes in this major revision, I’m excited to try out new code inspections, LINQ integration improvements, and native NUnit integration.


  • Resharper5BetaInstallCompleteInstall was quick and easy.  It uninstalled the version 4.5 and questioned me about killing a task that was getting in the way.
  • Starting Resharper, I’m greeted with a “License to version 4.0 is not acceptable”.  This is troubling in two ways:
    • The license that I bought is for 4.5 C# Edition.
    • Why does a beta need a license?
    • For now, using “free evaluation” – this seems to do the trick.
  • As expected, the AgentSmith plugin is no longer installed (duh), but an updated version is available on their site.

New Features

I’d like to be pretty thorough in acquainting myself with the enhancements, so I’ll touch on each of them from the list here.

  • Structure Patterns image
    • Custom built code refactorings.  This could be a godsend for brownfield development – enabling project-wide cleanup for stinky “code smells”.  The real power is in the “Placeholder” templating – it’s much like the Live Templates but for refactoring.  The image onthe right has a pattern that I made to change from timeSpan to happyHour.  Needless to say, this is trivial (and useless!), but I’m readily awaiting the next time I find a code smell I can’t live with.
  • Project Refactoring and Dependencies View
    • I’ve been waiting for the ability to mass-rename namespaces.  Resharper5 : check. 
    • So what does “Project Refactoring” mean?  Does a project have a bunch of types declared in the same files?  After a few clicks, they can all moved into their own:image
    • Dependency View is basically “find usages by project” – which could certainly be useful for larger solutions. 
  • Call Tracking, Value Tracking
    • Examines method, variable, field or property usage through the solution and finds where it’s being generated or called from, as well as the opposite - where it’s being used.  It’s the static-analysis version of the call stack.
  • Internationalization
    • I’ve never worked on a project using Internationalization, but it’s bound to happen sooner than later. Resharper 5 adds the ability to move string to resource files as well as refactoring and inspection to support multiple languages.
    • imageSyntax highlighting!  Check it out - unused namespaces inside ASP.NET markup will now appear grayed out, just as they do in source code.
    • Templates for ASP.NET:
    • imageView name autocomplete from the controller, as well as navigation to and from actions.
    • … and navigation to Views.  Shift+Click on a view name to jump there:
    • Aside: Our project has some calls to HtmlHelper.RenderPartial(“<ViewName>”) called inside of a class instantiated with an instance of HtmlHelper (it’s a Helper for HtmlHelper). Resharper can’t resolve these names… but I wouldn’t expect it to.
  • IntelliSense Changes
    • In addition to performance improvements, completion can now done using abbreviated names based on CamelHumps:
  • imageBookmarks
    • Set and jump to bookmarks with quick keystrokes.  Ctrl+Shift+[0-9] to set, and Ctrl+[0-9] jump back.  Ctr+~  to see which bookmarks are available:
  • Upgrade to LINQ
  • New and Improved Code Inspections
    • So, JetBrain’s says they’ve added a bunch of new code inspections – I’m counting a little over 100 C# Context Actions in 5.0, where as 4.5 had closer to 80.  There appear to be some LINQ related ones in there. They’ve also called out that it can now highlight errors in XML comments (something which the AgentSmith plugin already did quite well).
  • imageNative NUnit Support
    • To be honest, I’ve been using the previous Resharper version’s NUnit support without complaint.  I’m thinking that the that the improvements are “under the hood” – it works just as well now as it did before.
  • XML Formatting
    • Inspection and refactoring support - “Reorder attributes” and “Collapse Empty Tag”, for instance.
  • imageExternal Sources
    • This promises to add navigation to referenced libraries that before could only be accessed at the higher namespace-class-method  level via Visual Studio’s Object Browser.  I poked around a bit on JetBrain’s site looking how to configure the symbol locations, but it doesn’t seem to be documented yet.  Perhaps it might need to have the symbols locations populated in VS->Options->Debugging-Symbols, but perhaps not.


  • Transparently imported settings from 4.5 – horray!  Appears to be able to use the 4.5.resharper shared solution settings
  • imageRunning “Find Usages” on a class is taking much longer – in previous version it was instantaneous, now it appears to be scrounging through files instead of an index (could be External sources feature?)
  • Quick navigate to Type/Filename/Symbol now match partial names – no more needing to put in a “*” to match wildcards.
  • In the day or two I’ve been using it, I don’t think I’ve encountered any crashes.  This is a good thing – the multitude of errors being automatically reported seem to be going to good use.

Wish List

  • Javascript.  Being a dynamic language and all, it’d be pretty difficult to implement the full set of navigation and refactoring helpers Resharper provides for C# and VB.  But oh, wouldn’t it be slick if it could.
  • Community sharing for code-style and and structure patterns. There’s already preference and template sharing with team members via a shared settings file. The next evolution is to extend this to the cloud and create a public library to exchange ideas with all Resharper users.

For every one of the new features I’ve encountered in the past couple of days, I’m sure there are two or three that I haven’t stumbled over yet.  That’s a great thing about this product – utilizing a small subset of it’s features can greatly streamline development and increase productivity.  Even after years of use, I am still happily surprised to discover new facets of the tool I hadn’t noticed or investigated before.

Wednesday, December 30, 2009

Console Launcher Hot Key - “Tilda”

Interacting with your computer using a mouse-driven GUI makes many tasks quick and easy to accomplish.  However, when use of the keyboard is required, a healthy amount of context shifting between these two non-complimentary input devices can occur.  And that’s bad news for turning thoughts into actions in a timely matter. So, what’s the consequence of spending a few extra seconds to switch back and forth?  As John D. Cook points out, it adds up:

It’s a matter of keeping up with your thoughts. Suppose some series of tasks takes 20 seconds with a mouse but you can accomplish the same tasks in 12 seconds using the keyboard. The big deal isn’t that you’ve saved 8 seconds; the big deal is that you’re more likely to finish your tasks before you lose the thought that motivated them.

I interact with theTilda - Console Launcher Hot Key file system on a very regular basis.  I haven’t measured this, but I bet I’ll open Windows Explorer (or xplorer²) at least two or three times for every hour I’m at the computer.  I’m forever poking around for documents and restructuring directories so that they’ll be easier to find next time.  Many times I’ll want to execute a command line statement in the path that I’m browsing.  There are several different strategies for getting a “Open Command Prompt Here” to the explorer context menu, but they all require a right-click (or simulating one with the keyboard).  There’s an easier way.

A couple years ago I read an article on instructables about a “Drop Down”, Quake-style command prompt for Windows.  The project uses AutoHotKey to launch and hide a console window using a keyboard shortcut.  Neat!  It works great, except that it always dumps you in the your %HOMEPATH%.  I’ve taken the script and upgraded it to navigate directly to the currently open path in Windows Explorer – it’s name is Tilda.

For example – I’ve got an explorer window open in C:\console\UnxUtils\usr\local\wbin and I want to string some of those juicy unix command line utilities together.  I can now simply do Win+~, and I’ve got a new console instance in the right place.  As with the original, it will minimize/maximize the console window on subsequent usage of the key combination. 

I have this nasty habit of navigating around the file system when I’m using Windows Explorer.  After running some unix commands, I might have a hankering to run MSBuild.exe (ok, probably not, but who knows?).  I could tediously type the path, or, I could have Tilda automatically enter it for me.  From the new path in Windows Explorer, I type a combination Win+Shift+~ and the chdir command gets sent to the current console window.Tilda - chdir

Please note that I’m using (and recommend) Console as a command line window host.  Tilda is currently set to use this, but the script can be easily modified to use cmd.exe or whichever console window host you prefer.

Tilda - open and close a console window using a hot key.  Automatically navigates to the currently open explorer window.  Save some trips to the mouse and make getting to the command line easier.

Download Tilda (AutoHotKey source and binary)