ReSharper 2023.3 Help

Go to Declaration

Use this command to navigate to the declaration of a symbol from any symbol usage. You can invoke this command from the Solution Explorer, File Structure, 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.

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 Control+B, or click the symbol while 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).png, press Shift+Enter or + on the numeric keypad .

By default, Go To Declaration works with Ctrl + left-click and with the middle button click. To disable this, clear the Rich mouse navigation in the editor checkbox on the Environment | Search & Navigation page of ReSharper options (Alt+R, O) . You can also Ctrl+Shift-click usages of symbols to display their declarations in the Peek Definition view. If you want to disable this, clear the Use Ctrl+Shift click to open the result in the peek view checkbox.

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 in referenced libraries, ReSharper navigates according to the settings defined on the Tools | External Sources page of ReSharper options (Alt+R, O) .

Invoke this command on 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 Control+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 Control+Alt+F7.

  • Iterate usages — adds the corresponding command to the navigation menu, which enables the 'usage iteration' mode designated with a small popup in the upper-left corner of the editor:

    Usage-aware behaviour of Go to Declaration

    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 Control+Alt+PageDown/Control+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).png, press Shift+Enter or + on the numeric keypad .

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

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

When you invoke Go to Declaration on a usage of an interface member in debug mode, ReSharper will get you to its exact implementation that is used in the current frame instead of the interface declaration.

It will navigate to the member implementation when the member is invoked on local variables, parameters, and fields that hold the interface type.

If Enable property evaluation and other implicit function calls is selected on the Debugging | General page of Visual Studio's options, then navigation to the implementation will also work on properties that hold the interface type.

interface IMyInterface { public void Print(); } class One : IMyInterface { public void Print() => Console.WriteLine("One"); } class Two : IMyInterface { public void Print() => Console.WriteLine("Two"); } class Test { void Test1() => MyTest(new One()); void Test2() => MyTest(new Two()); void MyTest(IMyInterface input) { // 'Go to Declaration' on 'Print()' will navigate to // its implementation in 'One' or in 'Two' // depending on the debugger context. input.Print(); } }

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 in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is available in HTML

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in JavaScript

Feature is available in TypeScript

Feature is available in CSS

Feature is not available in XML

Feature is available in XAML

Feature is available in Resource files

Feature is available in build script files

Feature is available in Protobuf

Feature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.

Last modified: 18 March 2024