ReSharper 2019.2 Help

Go to Declaration

ReSharper | Navigate | Go To Declaration
Ctrl+B
ReSharper_GotoDeclaration

Use this command to navigate to the declaration of a symbol from any symbol usage. You can invoke this command from the editor, from the File Structure window and other tool windows.
To navigate in the opposite direction (symbol usages) you can invoke the Go to Declaration command when you are already on the symbol declaration, or you can use the Go to Usages of Symbol command.

If you navigate from a usage of a method or a property, which is declared in an interface, the command will get you not to the interface itself, but to the exact implementation that is used.

To navigate to a declaration of a symbol

  1. Place the caret at a symbol in the editor or select the symbol in a tool window.

  2. Choose ReSharper | Navigate | Go to Declaration in the main menu, press Ctrl+B, or click the symbol holding the Ctrl key.

  3. If the command returns a single result, ReSharper navigates directly there. In case of multiple results, they will be listed in a drop-down where you can do one of the following:

    • Click the desired item to open it in the editor.

    • Select the desired item by pressing Up and Down and then press Enter to open it in the editor.

    • To view and analyze the list of matched items in the Find Results window, click Show in Find Results ThemedIcon SearchResults Screen Gray , press Shift+Enter or + on the numeric keypad.

If the item you navigate to belongs to the current solution, ReSharper opens the corresponding file in the editor and places the caret at the symbol declaration. If it is found in referenced libraries, ReSharper navigates according to the settings defined on the Tools | External Sources page of ReSharper options.

Invoking the command on symbol declarations

As Go to Declaration (including its Ctrl-click access) is one of the most frequently used commands, ReSharper streamlines your navigation experience letting you use this command in navigation scenarios related to usages of the declared symbol, so you can invoke Go to Declaration even if your caret is already at a symbol declaration to study symbol usages.

To configure how Go to Declaration behaves when invoked on a declaration, use the Smart Go to Declaration behavior selector on the Environment | Search & Navigation page of ReSharper options (Alt+R,,O), which provides the following options:

  • Show Navigate To menu — displays the Navigate To menu with all navigation destinations contextually available on the declaration. This menu is also always available with Ctrl+Shift+G.

  • Show Usages of Symbol popup — list all usages of the declared symbol. You can also always get the list of usages with the Usages of Symbol command Ctrl+Alt+F7.

  • Iterate usages — Enables the usage-aware behavior of the Go to Declaration command.

  • Do nothing — Go to Declaration can be only invoked on symbol usages to go to its declaration.

Usage-aware behavior

  • You can invoke the Go to Declaration Ctrl+B command when your caret is already at a symbol declaration. In this case, ReSharper will show a short version of the Navigate To menu only including the command for iterating usages and commands for navigating to other members in the inheritance hierarchy (Base Symbols, Derived Symbols).

    If you choose Iterate usages in the Navigate to menu, ReSharper enables 'usage iteration' mode designated with a small popup in the upper-left corner of the editor:

    Usage-aware behaviour of Go to Declaration
  • Right after you have used the Go to Declaration command on a symbol usage and landed on its declaration, ReSharper enables the 'return to usage' mode, which is also shown in the popup:

    Usage-aware behaviour of Go to Declaration

    In this case, you can invoke Go to Declaration again or use the Next arrow in the popup Ctrl+Alt+PageDown to return to the usage. If you repeat this command yet another time, ReSharper will switch the 'usage iteration' mode.

You can always exit the 'return to usage' and 'usage iteration' modes by pressing Esc or clicking Close (x) in the usage iteration popup.

In the 'usage iteration' mode, you can navigate through the symbol usages as follows:

  • Invoke Go to Declaration to go to the next usage, if any, and so on, subsequently navigating through all symbol usages. The total number of symbol usages in the solution appears in the usage iteration popup.

  • Use Next and Back buttons in the usage iteration popup Ctrl+Alt+PageDown/Ctrl+Alt+PageUp to go to next and previous usages.

  • To view and analyze the list of matched items in the Find Results window, click Show in Find Results ThemedIcon SearchResults Screen Gray , press Shift+Enter or + on the numeric keypad.

  • To navigate through symbol usages in the current document, click the ThemedIcon ErrorStripeFindNext Screen Gray icon at the top of the marker bar.

This feature is supported in the following languages and technologies:

Language: C# Language: VB.NET Language: C++ Language: HTML Language: ASP.NET Language: Razor Language: JavaScript Language: TypeScript Language: CSS Language: XML Language: XAML Language: Resx Language: Build Scripts Language: Protobuf Language: JSON
Feature is available Feature is available Feature is available Feature is available Feature is available Feature is available Feature is available Feature is available Feature is available Feature is not available Feature is available Feature is available Feature is available Feature is available Feature is not available

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

Last modified: 18 November 2019