static void

Visual Studio navigation

Published Tuesday 04 May 2010

In a large Visual Studio solution, there are better ways of finding a particular class or method than visually hunting through the solution explorer tree.

Visual Studio 2008

Good old Goto Definition (F12) is great.
To quickly go back to where you pressed F12, Control - (minus) is useful but not very well known.

 vs_findallrefsBut what if you want to find where an interface is implemented, a method overridden or called from elsewhere?
Find All References (Control K, R) is painfully slow and it dumps everything in the Find Symbol Results window with the full file path (you can hack the registry to fix the format, but still...).

Within a source file, incremental search (Control I) is a great hidden secret - no dialog box, just start type and it immediately jumps to the first match. It has a big flaw: it doesn't look in hidden sections (closed regions).

To find a class or method which isn't in the source in front of you, you use Quick Find (Control F) or Find In Finds (Control Shift F). It's slow, and opens in a docked Find window. All those docked windows quickly become confusing.


Visual Studio 2010

VS 2010 still has Slowly Find All References, but it now has a couple of extra goodies.

vs2010_callhierarchy View Call Hierarchy (Control K, T) has a nice graph of calls to/ calls from which is recursive. In other words, just like Reflector's Analyzer.

vs2010_navigateto There's a neat new Navigate To window (Control comma). It's not a docked window, and has a really cool incremental search of the solution. The search box allows camel hump searching (just the capitals), as well as sub-strings.


coderush_referencesIf you're using Coderush Pro, you've had a nice version of call hierarchy in VS 2005 and 2008- it's the References window. There's a live-sync mode (overkill really), or you update it with Shift-F12 (or use the Refresh button). 

coderush_jumpto Also in Coderush, the jump to... context menu also shows context-sensitive overrides/ implementations and the next/prev reference can be tabbed to within a file (VS 2010 catches up with some features of this by highlighting other uses of a variable when the caret is on it).

My favourite feature of Coderush (and the free version, Coderush Xpress) is the Quick Nav dialog (Control Shift Q), which VS2010's Navigate To emulates. Quick incremental search, with camel-humps and substrings, and filter by members. coderush_quicknav

UPDATE: In the forthcoming Coderush Xpress for 2010, Quick Nav is gone. Damn. You must have the full Coderush or Resharper (see below). Okay, the built-in Navigate-To does the basic task, without the filtering, but still...


resharper_findsymbol resharper_findtype

Resharper also has an equivalent of QuickNav/NavigateTo, with all the camel humps goodness (no substrings, but you can do * and ? wildcards). (Note that Resharper has two keyboard mappings; I'm using the Visual Studio mappings here).
Find Symbol - Shift Alt T  - finds types and type members. Find Type - Control T - just looks at types. 

resharper_contextnav The right-click context menus for implementors, base and especially usages very handy.
resharper_findusages You can get to Find Usages with Shift-F12. If there's only one usage (or base or inheritor), you go straight to it.

The reason that Coderush and Resharper can do the quick navigation is that they parse the solution, so for the first minute or so a large solution will show one of their processing messages (theoretically you can type away, but things are slow while they are working).


I've just started playing with NDepend. There's a lot here to find your way around large code bases - even graphs - but for now I'll just note that the Visual Studio integration includes context menus which have similar functionality to the find usages described above:



Wrap Up

Having been a Resharper user for many years, the powerful find symbol / type commands became something I used practically every few minutes while coding. It was a shock to find myself in an office with no Resharper, but fortunately the free Coderush Xpress came to the rescue. Visual Studio 2010 vanilla edition with no Resharper or Coderush is actually not as bad as VS 2008 and earlier were- Navigate To/control comma is quite handy and an easy key combo too. Of course I then installed the betas/ trials of the latest Coderush/ Resharper and saw what I was missing. Please boss, can I have a license??? :)

Previously: Visual Studio 2010 editions (22 Apr 2010)