Contact

admin

About Me · Send mail to the author(s) E-mail · Twitter

At GROSSWEBER we practice what we preach. We offer trainings for modern software technologies like Behavior Driven Development, Clean Code and Git. Our staff is fluent in a variety of languages, including English.

Feed Icon

Tags

Open Source Projects

Archives

Blogs of friends

Now playing [?]

Error retrieving information from external service.
Audioscrobbler/Last.fm

ClustrMap

Cleaning Visual Studio from ReSharper 2.5 Leftovers

Posted in Visual Studio at Monday, July 09, 2007 11:58 PM W. Europe Daylight Time

Introduction

Visual Studio 2005 has a vast amount of functionality and makes editing and refactoring code a lot easier than it was the case in Visual Studio .NET 2003. The refactoring and inline-fixing functionality like "using namespace" introduced in 2005 is responsible for a great deal of that. By the time Visual Studio 2005 hit the market I was pretty impressed by the built-in tools, but I wasn't aware of the tools taking the ideas one step further. Since then I had the chance to work with CodeRush and ReSharper. Scott Hanselman likes CodeRush a lot, but was fairly overwhelmed by its vast array of options and tweaks. Sometimes it has even been a productivity killer when some shortcut was misinterpreted, but this might have been a configuration issue on my part.

Half a year the folks at JetBrains introduced me to their productivity solution for Visual Studio named ReSharper. ReSharper has a lots of features that may be comparable to CodeRush, but I like it better primarily because there's not too much pre-configured. Also, ReSharper can reformat code according to your own/your team's conventions, which is a blast. You can slowly work your way into using ReSharper over time, I recommend reading the excellent introduction by Joe White. Read one post per day and try to apply the functionality immediately afterwards. It's very likely you'll be sold to the product, it's a huge productivity gain.

Issues

That's been a rather long introduction, so without further ado let's advance to the core of the discussion. I'm a huge fan of ReSharper but updating has been a real hassle until now. At work I use two ReSharper versions, one for Visual Studio .NET 2003 and another built for Visual Studio 2005. Upgrading one version sometimes seems to have effects on the other. Last week for example I lost my user-defined templates for VS 2003 when I upgraded to ReSharper 3.0 which only runs on VS 2005. Finding a highly customized IDE reset for no apparent reason is pretty much of a dealbreaker for me because I really don't like starting over.

Duplicate Commands

At home, after working with ReSharper 2.5 for about four months, I recently upgraded to ReSharper 3.0. Both versions run as a Visual Studio 2005 Add-In. What I see here is duplicate context menu entries and old entries in the Visual Studio commands window. (The new commands start with "ReSharper.")

Duplicate Menu Entries

These issue have been documented on the support forums and the official excuse is that

… the uninstaller is not always capable of removing [the menus] nicely.

According to the posts on the forums JetBrains has introduced a new method of inserting menu items which hopefully solves these issues in the future. For now they actually recommend resetting your ReSharper settings. Thank you, great idea!

Solutions

Because I didn't want to lose my settings I wrote a couple of macros for Visual Studio that should help you getting rid of ReSharper 2.5 remnants. The macro project has two runnable methods.

Key bindings

The first one, GetKeyboardBindings,  looks at all of Visual Studio's commands and filters those relevant to ReSharper. A Visual Studio command is a unit of work, i.e. "Save that file" or "Refactor this class". Those starting with "ReSharper" will be included, so 2.5 and 3.0 commands will be on that list. You can use the macro to get quick overview of your keyboard bindings specific to ReSharper. Take a look at the output window in the Visual Studio Macro IDE:

Key Bindings

Paste the contents of the window to a text file for later reference.

Getting Rid of the Old Stuff

The CleanupReSharperLeftOvers macro basically scans all menus of Visual Studio, which also include context menus that can't be accessed using the Tools/Customize… menu. Because I couldn't find a way to get the associated command of a specific menu item (is there one?), things are getting a bit tricky.

I've collected a list of duplicate context menu items from my machine. Maybe there are some more on your box, maybe there are less. JetBrains supports our noble intent as they introduced keyboard shortcuts for some of my duplicates, which changes the menu item's name from "Reformat Code…" in ReSharper 2.5 to "Re&format Code…" in 3.0. Some items like "Go to Base/Declaration/Inheritor", on the other hand, didn't change the macro will affect both the old and the new menu items. I couldn't care less since I didn't use them anyway.

Important note: ReSharper will not recreate any of the menu items you removed using the macro. You can change the items to be removed by editing the _reSharperDuplicates list:

Dim _reSharperDuplicates() As String = {"Reformat Code...", _
                                        "Optimize Usings...", _
                                        "Run Unit Tests", _
                                        "Debug Unit Tests", _
                                        "New from template", _
                                        "Refactor", _
                                        "Find usages", _
                                        "Find usages advanced", _
                                        "Go to Base", _
                                        "Go to Declaration", _
                                        "Go to Inheritor"}

To play safe I included a global named _testMode which will keep everything as-is as long is it's set to true, which is the default.

Download

Hopefully these macros don't break anything, at least they didn't for me. Please, make a backup and use at your own risk. Keep in mind that YMMV.

Wednesday, February 06, 2008 10:59:37 PM (W. Europe Standard Time, UTC+01:00)
All comments require the approval of the site owner before being displayed.
(will show your gravatar icon)
 
[Captcha]Enter the code shown (prevents robots):

Live Comment Preview