ReSharper, day 18: Adding things with Alt+Enter

Welcome to day 18 of my 31 Days of ReSharper.

Yesterday, I talked about the red light bulb and how you can use it to invoke Change All. Today I’ll talk about a couple more of the quick fixes in the red-light-bulb menu. As before, whenever you see the red light bulb, you can drop down its menu by pressing Alt+Enter.

Context sensitivity

When you have an undefined (red) symbol, ReSharper will give you options to define it. It’s smart about which options to show:

  • Create property (which really should say “create read-only property”, since that’s what it does) is shown if the symbol starts with a capital letter.

  • There’s also Create get/set property, but that’s only shown if this particular usage is the target of an assignment. (It’s not cool enough to look at all the usages and see if any of them are assigned to. Update: they’ve gotten other requests for this, and are already planning to implement it in the next version of ReSharper.)

  • Create field and Create local variable are shown if the symbol starts with a lowercase letter.

  • Create method is shown (instead of property/field/variable) if the symbol is followed by an open parenthesis.

  • Related is Create set accessor, which is shown when you press Alt+Enter where the code is trying to set a read-only property. This one is actually based on a red squiggly, not a red symbol.

These are all smart, but not as eerily smart as Change All:

Type this, and… Create Local Variable
if (a) bool a;
ArrayList.Adapter(b) IList b;
c.PixelOffsetMode = PixelOffsetMode.Half; object c;

If Create Local Variable was as smart as Change All, that third line would generate Graphics c; instead of just plain object. (I suspect the difference is because Change All has to see which already-existing symbols match the usage, so it’s got to look at perhaps a few dozen variables and properties. Create Local Variable doesn’t have the advantage of an already-filtered starting point, so to do the same thing, it would have to look at every one of the tens or hundreds of thousands of classes in the .NET Framework, which might well be pretty slow. But it’d be pretty cool. Update: Support agrees. They’ve added a feature request, and said it would be in the next version of ReSharper!)

Smarts about the type

When it’s building the Alt+Enter menu, ReSharper doesn’t look at how a symbol is used. But once you select an option, it does.

If you just use a symbol one place, like this:

ReSharper will simply declare the variable as the exact type, Bitmap in this case. (It takes the cursor straight to the newly-declared variable, though, with a temporary Code Template; so if you want a different type, you can type it in.)

But if you also use the symbol in a place that expects a base type, like this (DrawImage expects Bitmap’s parent type, Image, for its first parameter):

then Create Variable will give you a choice of which type you want to use, and will default to the base type:

Options for properties

When you create a property, ReSharper again creates a temporary Code Template. You start out at the return type, which you can accept or change. Then when you hit Tab, you get a choice of how to generate the getter/setter code:

ReSharper after using Alt+Enter to create a property, showing the options to use either a backing field or the default body template

  • Backing field will do what its name suggests: it will declare a field with the appropriate type and name (following the Naming Conventions settings you’ve specified in ReSharper Options), return the field from the getter, and (if applicable) set it in the setter. If the field already exists, it won’t be added again.

  • Default body template will throw an exception in the getter and the setter.

Options for methods

When you use Alt+Enter to create a method, the temporary Code Template will let you specify the return type, the parameter types, and the parameter names. Nothing too surprising here.

What’s pretty cool, though, is that ReSharper’s variable name suggestions kick in. If the call site was passing a variable or property, ReSharper will default to using that same variable name for the parameter name; beyond that, it makes the usual suggestions based on the type name.

When you Tab to a parameter that has more than one suggested name, the dropdown completion box will appear. Of course, you can always type a name that isn’t in that list.

ReSharper after using Alt+Enter to create a method, showing the parameter name suggestions

You can even type a prefix (e.g., “first”) and then press Ctrl+Space to suggest the rest of the name. (Unfortunately, this won’t catch the variable name from the call site, it’ll only suggest based on the type name. For example, in the above code, if I typed first and pressed Ctrl+Space, I would get firstInt, not firstCount.)

Limitation: Getting back

When you use any of these commands, ReSharper puts the cursor inside the new declaration, so you can use the temporary Code Template to change the type or the code. But when it’s done, you have to figure out how to get back to where you were.

ReSharper has a Go to last edit location command, accessed via Ctrl+Shift+Backspace. It seems to be able to get you back where you started, some of the time at least. It won’t do anything the first time you hit it, but if you’re lucky, the second time, it’ll take you back to the formerly-red symbol. (But if you then use Alt+Enter to complete something else, and try to get back again, it doesn’t seem to work as expected.)

Limitation: Not naming-convention savvy

These features are not smart enough to follow the “Naming Convention” page in ReSharper Options. Given the semi-standard of fields starting with _, one would expect that symbols that already start with _ wouldn’t get the option to create a local variable; and one would further expect that symbols without the _ would either not get the “Create field” option, or would add the _ when you create a field. ReSharper doesn’t do any of this; Create Field and Create Local Variable are both completely oblivious to Naming Convention settings. (I’ve entered a feature request for this.)

ReSharper, day 17: Change All with Alt+Enter (and, Introducing the red light bulb)

Welcome to day 17 of my 31 Days of ReSharper.

The next few days will continue to cover Alt+Enter. Today I’ll cover the use of Alt+Enter > Change All.

Red light bulbs

I’ll start by noting that yesterday’s feature, Alt+Enter to import namespaces, is atypical, in that it works no matter where the cursor is. Namespaces are the only place Alt+Enter works like that. It’s usually very positional: it only operates on the code at the current cursor position. That will be true of all of the Alt+Enter features I cover from here on in.

When there’s a problem (red, gray, or squiggly) that ReSharper knows how to fix, and you put the cursor on the problem code, ReSharper will show a red light bulb next to that line:

ReSharper's red light bulb, showing a problem you can fix with Alt+Enter

The red lightbulb indicates something that you should fix. There are also yellow lightbulbs, which mean something that you can do, but that’s totally at your discretion; I’ll cover some of these in future posts.

You can either click the light bulb, or press Alt+Enter. Either way, you’ll get a dropdown menu giving you options on how to fix the error.

ReSharper's Alt+Enter dropdown menu, showing options such as Change All to fix a compiler error

Update: The commands in this dropdown menu are referred to as “quick fixes”. (I should’ve mentioned that when I first posted this article.)

About Change All

One of the quick fixes for a red symbol is Change All. It does what its name suggests: it changes all occurrences of the (red) symbol to reference another (already defined and non-red) symbol. This one is handy if, for example, you cut some code from one method and paste it into another, where the variable or parameter names are different.

There are two parts to Change All: the suggestion list, and the sync editing.

The suggestion list: mind-reading at work

The suggestion list from ReSharper's Change All command

When you select Change All, you’ll get a suggestion list. Often there’s only one suggestion, and it’s exactly the one I want. It’s so good it’s spooky.

Now that I’m writing about it, and pushing the boundaries to find out exactly how it works, I’m even more impressed. It’s basically Ctrl+Shift+Space turned inside-out.

What happens is this: it looks at all the places where the symbol appears in red (ignoring any other methods that have same-named symbols that aren’t red), figures out how you’re using it in each place, and suggests symbols that will fit those usages without errors.

So if the symbol appears as the condition in an if statement, ReSharper will only suggest variables of type bool. If the symbol appears with .PixelOffsetMode = after it, ReSharper will only suggest variables of type Graphics (unless you’ve defined another type that has a PixelOffsetMode property).

In a lot of cases, you’ll end up with just one parameter, or just one property, that satisfies the way you’re using that symbol. Which makes it look like ReSharper is reading your mind. (It pretty much is!)

Worth noting: the Change All suggestion list is targeted to variable-like things (variables, parameters, and properties). You can use Change All for method names or type names, but you won’t get those suggestions in the Change All list.

SyncEdit comes to Visual Studio

Here’s kind of a nice touch: instead of popping up a dialog box prompting for the new name, Change All lets you type the new name directly into the editor in one place, and it changes the others as you type.

The ReSharper docs don’t have a name for this rename-it-right-there-in-the-edit-window feature, but it’s almost exactly like the SyncEdit feature from Delphi 2005, so that’s what I call it. It’s nice to have this feature available in Visual Studio.

ReSharper, day 16: Importing namespaces with Alt+Enter

Welcome to day 16 of my 31 Days of ReSharper.

Today, and for the next few days, I’ll talk about one of the keystrokes you’ll use most often with ReSharper: Alt+Enter. I referred to it earlier as ReSharper’s “Swiss Army knife”, because it’s so versatile: it can fix certain compiler errors, complete code, remove code that’s never used, and just in general automate some of the repetitive tasks that come with writing code.

Today’s topic: importing namespaces.

The basics

As I previously mentioned, ReSharper shows unrecognized symbols in red. But if a symbol is known to exist in some other namespace that you’re not yet using, ReSharper will show something else, too: a hint prompting you to fix the error.

ReSharper prompting you to press Alt+Enter to import a namespace

So if you just type PixelOffsetMode into your source file (and you’re not already using System.Drawing.Drawing2D), ReSharper will scan all the namespaces, find a class with that name, and ask you if it’s got the right one. If you confirm by pressing Alt+Enter, it will add using System.Drawing.Drawing2D to your source file.

Here’s more info worth knowing about this feature:

  • Sorting. ReSharper will add usings according to a predictable ordering rule. It’s a modified alphabetical sort: it puts all the System namespaces first (in alphabetical order), followed by everything else (in alphabetical order). Note that this will only sort of work if they aren’t already ordered this way, but you can just do Ctrl+Alt+F to re-sort them.

  • Less position-dependent. I’ll be talking about other things you can do with Alt+Enter, and usually, they’re specific to the code under the cursor. But this particular usage — adding namespace usings — doesn’t have that requirement: it will work even if the cursor isn’t over the red symbol. (If there are multiple red symbols in the file, the one that Alt+Enter will target is whichever one is closest to the cursor position.)

  • Not (quite) instant. As with the color-coding, you may sometimes have to wait a second or two after you stop typing, before you can see the hint and hit Alt+Enter. ReSharper has to look at your code and realize that (a) it doesn’t recognize this type and (b) the type does exist in another namespace. It only shows the Alt+Enter hint after it’s figured this out, and until it does, Alt+Enter won’t do a thing. It doesn’t take long, but occasionally you’ll have to pause to let it do its thing.

  • Disambiguation. If the symbol is found in more than one namespace, ReSharper will ask you which one you mean. The hint will say “(multiple choices)”, and when you hit Alt+Enter, you’ll get to pick the one you want from a list.

    ReSharper prompting you to press Alt+Enter to import one of multiple interfaces
    ReSharper's selection menu after pressing Alt+Enter

  • Depends on references. This shouldn’t be a surprise. If you create a new assembly and add a [TestFixture] attribute to a class, ReSharper will show it in red, but won’t be able to help you fix it until you right-click on your assembly and Add Reference to NUnit.Framework.dll.

Comparison to Ctrl+Alt+Space

Yesterday, I talked about using Ctrl+Alt+Space to autocomplete type names and add using directives.

Alt+Enter will work in circumstances where Ctrl+Alt+Space won’t, e.g. when you’re pasting code that you got from some code sample online, and it doesn’t have all the usings you need. But I think Ctrl+Alt+Space is a probably better feature for general coding. Mind you, I hardly ever remember to use it; it’ll take a while to get used to thinking, “Okay, I’m about to type a type name, not a method name. So I need to hit Ctrl+Alt+Space this time.” But if I did remember to use it, it feels like a better fit than typing something and then hitting Alt+Enter.

The main reason is that, even though both features have a potential to make you wait a second or two, Ctrl+Alt+Space puts that delay at a more opportune time.

With Alt+Enter, you type an identifier and hit Space, and your mind is already moving along to the next thing you have to type. And then suddenly you see your code turn red, and you have to divert your attention back to what you already wrote. Even if it’s just to decide in the back of your mind, “Oh, I’ll just finish typing this statement and then hit Alt+Enter to fix that,” it’s still a distraction.

Whereas with Ctrl+Alt+Space, you type part of an identifier and then hit the keystroke, and it’s all part of typing that identifier. Then you let your brain move on to the next thing in the line. So your flow isn’t interrupted by having to look back at code you already wrote.

Your mileage may vary (and mine may, too). I’m certainly not saying that Alt+Enter is a bad feature! Just consider using Ctrl+Alt+Space when it fits.

Comparison to Visual Studio’s Alt+Shift+F10

Visual Studio 2005 has a similar feature for importing namespaces: when you type a symbol it knows about, it will show a little smart tag, which you can mouse over (or hit Alt+Shift+F10) to show a dropdown menu with the ability to add a using. How does it compare to ReSharper’s Alt+Enter?

  • Keystrokes. If the symbol only exists in one namespace, ReSharper only requires you to press Alt+Enter. Visual Studio requires the more-unwieldy Alt+Shift+F10, followed by Enter. Advantage: ReSharper.

  • Sorting. Visual Studio adds the namespace to the end of the block of usings, leaving your usings in a haphazard order. ReSharper automatically keeps them sorted. Advantage: ReSharper.

  • Positionality. Visual Studio will only show the Smart Tag when the cursor is on the symbol. ReSharper shows its “add namespace” Alt+Enter hint anytime there’s a red symbol scrolled onto the screen, so you don’t have to cursor around to import namespaces. Advantage: ReSharper.

  • Response time. Visual Studio pops up its smart tag instantly after you type the last letter in the type name. ReSharper can take a second or two before it highlights the symbol in red and shows the hint. Advantage: Visual Studio, by a small margin. (This is much more noticeable on my 800MHz/256MB laptop than it is on our 3GHz/2GB development machines.)

ReSharper, day 15: The Ctrl+Space family

Welcome to day 15 of my 31 Days of ReSharper.

Yesterday, I talked about ReSharper’s version of Ctrl+Space. Today, I’ll cover the other two family members that ReSharper adds: Ctrl+Shift+Space and Ctrl+Alt+Space.

(Remember that Parameter Info, which used to be Ctrl+Shift+Space, is now Ctrl+P.)

Ctrl+Shift+Space: Filtered by expected type

Visual Studio’s regular Ctrl+Space (and ReSharper’s too) show every type from all the currently-imported namespaces. ReSharper also gives you a context-sensitive option, which only shows things of the right type — whatever type is expected at the current cursor position. You invoke the context-sensitive version with Ctrl+Shift+Space.

For example, if I type

Stream stream = new FileStream(fileName, FileMode.Open);
StreamReader reader = new StreamReader(

and then I hit Ctrl+Shift+Space, I’ll get a fairly short completion list, because it’s only showing things that could be a first parameter to the StreamReader constructor. stream will be one of the options in that list, and so will Stream.Null. And then, so are a bunch of static methods that return strings, since the StreamReader constructor has overloads that take strings.

They haven’t yet made this work for constructors. If I typed

Stream stream = new

and pressed Ctrl+Shift+Space, I would expect to see all the concrete descendant classes that I could use in this context. But I don’t; it just gives me “No suggestions”. Support tells me that the new scenario isn’t supported yet, but is already in the plans for a future release.

You know, though, this is one time I’d rather be working in Delphi. (Assuming, of course, that the Delphi IDE isn’t locking up for half a minute at a time every time I move the mouse, while it tries to do [and re-do and re-do] its “background” compilation — probably a vain hope, but a guy can dream.) That’s because Delphi’s Ctrl+Space is cooler yet: it’s context-sensitive, but it shows you not just expressions that are exactly the right type; it also shows you expressions you can use to get to the right type. E.g., if you’re in a context that expects an Integer, Delphi would show TForm instances in the list, because they have properties of type Integer (Width, Height, Constraints.MinWidth, etc.) You quickly get used to this, and I have trouble adapting to ReSharper’s much-more-restrictive context completion. Then again, maybe that’s why Delphi is so godawful slow in trying to build that list.

Update: If I create a new, empty method and press Ctrl+Shift+Space inside it, the autocompletion box pops up, even though there doesn’t seem to be a type to complete for. Ilya, one of the ReSharper developers, explains:

Ctrl+Shift+Space in empty method, or at any other place where statement is expected, e.g. between two other statements – it expects “void” type, so it shows just methods which doesn’t have return value.

Thanks, Ilya!

Ctrl+Alt+Space: types from all namespaces

Moving in a different direction, Ctrl+Alt+Space only shows type names — no properties, no methods, no constants; just types. But unlike Ctrl+Space, it looks in all namespaces, not just those you currently have usings for.

(Their documentation for Ctrl+Alt+Space says that it completes names of types within the current solution, but that’s not correct; it also completes types from any other referenced assemblies, so it works for things like FileStream and TestFixtureAttribute that come from Microsoft and/or third-party assemblies.)

So far, this sounds only vaguely interesting. Well, here’s the interesting part: when you select the type, ReSharper automatically adds the appropriate using directive if you don’t already have it.

(ReSharper has other features to add needed usings — in fact, I’m going to talk about one of them tomorrow — but I think I need to learn to use Ctrl+Alt+Space regularly: it promises to be faster and easier.)

Ctrl+Alt+Space requires that you type the first few characters of the type name before hitting the keystroke. I contacted Support to ask if this was on purpose, and they said yes, it was; because they’re building a list from all assemblies, they said it’d take too long if you hadn’t typed something to filter the list. Fair enough (although it’d be nice if they noted the reason in their documentation).

ReSharper, day 14: Suggested variable names

Welcome to day 14 of my 31 Days of ReSharper.

ReSharper replaces Ctrl+Space with its own version. It mostly does the same thing as Visual Studio’s Ctrl+Space, but it has one additional feature: it can suggest variable names for you.

If you type a variable declaration, and hit Ctrl+Space…

ReSharper suggesting variable names

ReSharper shows an AutoComplete dropdown with suggested names, based on the type name. The dropdown list behaves like any other AutoComplete dropdown, so you can cursor to an item and hit Enter, or you can just type ; and it will accept the current selection and type a semicolon.

It’s smart enough to ignore the leading I on interface names. And if the type is only one word, it won’t bother with the dropdown. So if you type ISprite (space) and hit Ctrl+Space, it will go ahead and fill in sprite.

Of course, this isn’t just for local variables; it also works for parameters and fields. You can even teach it your naming conventions, e.g. if all your fields’ names should start with _; see the Naming Convention page in ReSharper Options.

You can also type in a prefix before you press Ctrl+Space:

ReSharper suggesting variable names after you specify a name prefix

Unfortunately, this has a bug in ReSharper 2.5.1. Notice that the suggestions have turned my prefix into all-lower-case, instead of keeping the camelCase that I had originally typed. (They’ve created a ticket for the bug.)

The variable name suggestions aren’t limited to Ctrl+Space when you’re declaring a variable; they appear other places in ReSharper as well. For example, when you’re introducing a parameter, you get a combo box where you can either type a name, or select one of the suggestions. When you’re renaming a variable, the name suggestions pop up. When you’re extracting a method, the suggestions kick in for the parameter names. Etc.

CodeGear and roadmaps

We’ve been looking forward to Delphi Highlander — a Delphi for .NET 2.0 — since before it had a name. You can compile to .NET 2.0 with Delphi 2006 (and we do), but the IDE actively gets in your way, and you can’t use generics, which are the whole point of .NET 2.0 in the first place.

CodeGear’s “Borland [sic] Delphi Roadmapstill says that Highlander will [sic] be released in 2006. Way to keep your roadmap current, guys.

But the latest news is that the next release of Delphi will be strictly Win32. Apparently the next couple of releases won’t even have a .NET compiler.

And here I was hoping that they would actually ship what they’ve been promising us for over a year.

Silly me.

ReSharper, day 13: File Structure view

Welcome to day 13 of my 31 Days of ReSharper.

For several versions, Delphi has had a Structure view, which shows your fields and methods and properties in a treeview. ReSharper takes this several steps further with their File Structure view, which is accessible with Ctrl+F11. Not a great shortcut, but then, you’ll probably only show the window once and then keep it docked.

ReSharper's File Structure view

Sorting methods

Theoretically, you could use this to see your code’s structure at a glance. I don’t really use it for that; my fingers have the shortcut for Collapse All memorized (I think it’s Ctrl+M Ctrl+O, but I never have to think about it… let’s see… yeah, that’s right).

What I do use the File Structure view for is re-ordering. We find life is a lot easier if we keep all our methods alphabetical; but ReSharper doesn’t have an option for that, so it’s always putting extracted methods in the wrong place. But you can drag and drop in the File Structure window…

ReSharper's File Structure view

and when you drop the method in the new place, ReSharper will move the method in the Code Editor.

It sometimes does the wrong thing with respect to blank lines, but until ReSharper adds options to keep things in the right order (which, given the number of different coding styles out there, would be a tall order), drag-and-drop of tree nodes, followed by “collapse all” and a bit of blank-line cleanup, is a far sight faster than cut and paste.

If you like regions…

For those who actually use regions and like them, ReSharper’s File Structure view makes them all pretty and collapsible.

ReSharper's File Structure view, showing an expanded regionReSharper's File Structure view, showing a collapsed region

If you don’t like regions…

Personally, I think that regions make code harder to read — and besides, if your code is so complicated that you need regions to keep it organized, that’s a smell that your class is doing too much.

If you’re in this camp, ReSharper is there for you. See that little blue “X” in the top-right of the region box? A single click on that, and the region tags go away. (It only deletes the #region and #endregion lines, not the region’s contents.) And then, since you’re already in the File Structure window, you can go ahead and drag to reorder the methods.

Of course, if you accidentally remove region tags when you didn’t intend to, it’s a code change like any other, so you can undo it.

ReSharper, day 12: Type Hierarchy view

Welcome to day 12 of my 31 Days of ReSharper.

Today’s topic is a feature I’ve spent so long wishing for that I can never remember it actually exists: the Type Hierarchy view, accessed via Ctrl+Alt+H.

ReSharper's Type Hierarchy, showing the class hierarchy for System.Windows.Forms.Form

If you press Ctrl+Alt+H while the cursor is over a type name, it will pop up the Type Hierarchy window, showing the ancestors and immediate descendants of that type. (Like all the other ReSharper windows, it’s dockable.) You can expand the tree to show lower-level descendants as well. If you’ve got a complicated type hierarchy that you always access through an interface, you can see the whole tree just by cursoring to the interface and pressing Ctrl+Alt+H.

You can right-click on a node and select “Base on this”, which will re-do the tree as if you had pressed Ctrl+Alt+H on that type. If you do this on a class’s parent type, it will open up more classes in the tree (because you only see the based-on class’s direct ancestors; but if you base on one of those ancestors, you see all of its other descendants in the tree as well). The current based-on class is shown in bold.

ReSharper's Type Hierarchy, showing the class hierarchy for System.Windows.Forms.ContainerControl

I think it’s really cool that “Base on this” remembers which types you already had expanded and which were collapsed, and leaves them that way.

The Type Hierarchy window also has a couple of alternative views, accessible through the little object-graph-looking buttons on the right side of the toolbar. Besides the main hierarchy view, there’s a view that shows just the descendants, which isn’t that interesting; it’s just the main hierarchy view with less indentation.

The third view shows just the supertypes. The supertype view is interesting because it inverts the tree (parents are shown as sub-nodes), so it can show the interfaces a class implements, as well as its parent classes.

ReSharper's Type Hierarchy, showing the supertypes of System.Windows.Forms.Form

The right-click context menu, besides “Base on this”, has Find Usages and a Refactor submenu. So if you’re looking at a type hierarchy and feel a sudden need to rename one of the classes in it, you can. (It’s smart enough to gray out things like Rename for classes you don’t have the source code for.)

Finally, you can double-click a type in the tree to jump to it in code. (Although it uses the klunky Class Browser instead of Visual Studio’s new “[from metadata]” code view for types you don’t have the source code for.)

ReSharper, day 11: Code navigation

Welcome to day 11 of my 31 Days of ReSharper.

Today’s topic is navigation through the code. I’ll cover three ReSharper features: the Navigate From Here context menu; the gutter icons; and Go To Declaration.

Navigate From Here context menu

One of the cool things about ReSharper is that they have more than one context menu. They have a couple of keystrokes that bring up targeted context menus, so instead of “everything you might possibly want to do here”, you can see “everything you might want to do related to code navigation” or “everything you might want to do related to refactoring”. (The kitchen-sink context menu is, of course, still available.)

These targeted context menus are a great compromise between brain capacity and coding speed. It’s easy to get started, because you only need to learn one keystroke for a whole group of features. But since each item in the context menu is just another command, and many of them have their own shortcut keys (which are shown on the targeted context menus, unlike the main context menu), you can gradually learn the specific shortcut keys for the features you use all the time, and can access those features even faster.

Here’s an example of the “Navigate from Here” context menu, which you can access with Ctrl+Shift+G:

ReSharper's Navigate From Here targeted context menu

Being a context menu, it only shows you the commands that make sense based on the current cursor position. So if you’re on a class name, it will show you different options than it would if you were on a method name or a namespace name.

I haven’t used all of these options, but my current favorite is Inheritor. When you’re in code that’s calling a method on an interface, this will show you a list of all the classes that implement that interface method:

ReSharper's Navigate From Here - Inheritor, when applied to an interface method, shows all the methods that implement that interface method

It’s even cool enough that if those interface implementations are virtual, it’ll include the descendant classes that override that method. First-level overrides (classes that implement the interface) are shown in bold. Second- and later-level overrides (descendants that further override the method) are non-bold.

Gutter icons

I don’t use this one very often, because it only goes upstream, which is easy enough anyway; and you can do the same stuff with Navigate From Here. But it’s worth noting.

ReSharper shows gutter icons next to method declarations that have something to do with the base class (or an implemented interface). So if method Foo overrides a method in the base class, there’ll be one sort of icon. If it shadows, there’ll be a different icon. If it implements an interface, there’s an icon for that too.

ReSharper's gutter icons, showing an interface implementation, an override, and a shadowed method
ReSharper’s gutter icons. Shown are an interface implementation, an override, and a shadowed method.

(Come to think of it, I should start looking at these icons. The green “I” is a good visual indicator of which methods on a class come from an interface — not something you can otherwise tell just by looking.)

You can also click these gutter icons to jump to the relevant ancestor method. Sounds nice, but I hardly ever use it; I usually end up at the base class without trying! (Template methods are nice for removing duplication, but they can be a hassle for navigation.)

Go To Declaration

This is one of the keystrokes that changed when you installed ReSharper. What used to be F12 is now Ctrl+B; you can also Ctrl+Click on an identifier.

Apart from the keystroke, this works exactly like the Visual Studio version (jump to the interesting bit of code), with one difference. The difference comes up when you’re on an identifier that you don’t have source code for, such as something from a Microsoft assembly. VS and R# both show you a representation of the defining code, but…


ReSharper shows you the old Class Browser, which is klunky and a real pain to use:

ReSharper shows you the Class Browser

It actually does this for all its code-navigation features, not just Ctrl+click. For example, clicking a gutter icon can also land you in the Class Browser.

Visual Studio 2005, on the other hand, has a nifty new feature to show the class’s metadata as code (the “[from metadata]” feature), which replaces the Object Browser in all cases except those relating to ReSharper:

Visual Studio shows you the metadata as code, in a '[from metadata]' window

I think Visual Studio’s code view is far superior, for two reasons:

  1. The Class Browser sucks for navigation. For example, suppose I’m looking at Graphics.DrawImage (see the Class Browser screenshot, above) and I see that it takes a parameter of type Image. What if I want to jump to the Image class to see what methods it has? In the code view, it would be just a Ctrl+click away. But since ReSharper sticks us with the Class Browser, where the important information is split across three different panes, you have to know to first click on the right overload in the top-right pane, and then find the parameter type in the XML doc comments in the lower-right corner and click the hyperlink there. (For a long time, I didn’t even realize there was a way to jump to the parameter type using the Class Browser; I just figured it out while I was writing this.)

  2. The code view looks like code. It’s familiar; I’m used to it; I know exactly how to get around in it. Code is what I work with every day. Why on earth would a productivity tool like ReSharper choose to make me less productive by forcing me to learn another GUI for the exact same thing, when there’s already a better alternative?

I wish ReSharper used the new code view, and I’ve sent in a feature request to that effect. Their response was that, since you can still access VS’s “Go to Definition” from the context menu, they’re going to leave it the way it is. I find this disappointing, especially since it’s not just “Go to Declaration” that’s stuck with the klunky Object Browser — it’s everything in ReSharper related to code navigation.

(If you use ReSharper and this has been frustrating you too, let them know.)