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.

Monday, 11 January 2010 08:32:00 (Eastern Standard Time, UTC-05:00)
Structure patterns: So did you find some documentation for this somewhere? I couldn't puzzle it out, and I didn't see any blog posts detailing it (though I admit, I didn't bother to install the ReSharper help this time -- maybe I need to go back and do that? In previous versions it just added an hour to the install, but maybe it's necessary now.)

Mass-renaming namespaces: I heard this mentioned in passing in the JetBrains blogs, but I don't know how to get to it. Where did you find it? We have code that was translated to C# from another environment, and currently we have one namespace per file, but want to merge them into one namespace per directory; would this help do that?

"Dependency View is basically 'find usages by project'" -- I'm not sure quite what you mean. Find Usages already had an option to group by project. How is this different? (With a name like Dependency View, it could be very cool indeed.)

One other feature it has that I really like is that, when you navigate to a type that's part of the .NET Framework, you're no longer stuck with the Object Browser. You have two new choices -- use Visual Studio's Metadata View (show metadata as code), and use Microsoft's reference sources (which is what I chose -- full source! Better than Reflector!)

I was interested to see that yours gave an informative error about your license key. Ours just said that the key was invalid. Perhaps it's because we had a 3.1 key that we purchased late enough that it was valid for 4.x too. So I, too, am on a trial edition, and I, too, agree that it's odd to require a key for a beta.

And I haven't seen Find Usages being appreciably slower (on our ~million-line code base). Safe Delete is hideously slow (sometimes orders of magnitude slower than Find Usages), but that was already the case in 4.5.
Monday, 11 January 2010 11:59:20 (Eastern Standard Time, UTC-05:00)
Structure patterns: So did you find some documentation for this somewhere?

Unfortunately no, but the syntax appears to be similar to Live Templates. I had to play around with it for a while before I could get it to do anything. I got it to suggest the change from "timeSpan" to "happyHour" by making an identifier placeholder matching "timeSpan", putting "$timespan$" in the Search pattern, and then "happyHour" in the Replace with.

Mass-renaming namespaces

I was able to do this by right clicking on the namespace (the actual text) and selecting Refactor->Rename...

Dependency View is basically 'find usages by project'"

It's not group by project in Find Usages, it's find all the locations anything in the project is used in any other projects.

One other feature it has that I really like is that, when you navigate to a type that's part of the .NET Framework, you're no longer stuck with the Object Browser.

Yes! I'm also very happy to see this for exploring third party/external sources.

Find Usages being appreciably slower

I was actually using it in a solution containing a large-ish MVC project. I tried it in a C# source-code only solution, and it appears to perform fine. Now my guess is that it's scanning the .aspx files perhaps.
Comments are closed.