Skip to content

Commit 7e347a1

Browse files
committed
Merged main into live
2 parents b511dde + b48a4ca commit 7e347a1

29 files changed

+105
-75
lines changed

docs/get-started/csharp/tutorial-editor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ The code block collapses to just the first line, followed by an ellipsis (`...`)
203203

204204
::: moniker range="<=vs-2019"
205205

206-
The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** or pressing **F12** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-definition). Let's peek at the definition of the `string` type.
206+
The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** or pressing **F12** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-at-a-definition). Let's peek at the definition of the `string` type.
207207

208208
1. Right-click on any occurrence of `string` and choose **Peek Definition** from the content menu. Or, press **Alt**+**F12**.
209209

@@ -217,7 +217,7 @@ The Visual Studio editor makes it easy to inspect the definition of a type, meth
217217

218218
::: moniker range=">=vs-2022"
219219

220-
The Visual Studio editor makes it easy to inspect the definition of a type, method, or variable. One way is to go to the definition, in whichever file has it, by choosing **Go to Definition** or pressing **F12** anywhere a symbol is referenced. An even quicker way that doesn't move your focus away from the code you're working on is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-definition).
220+
The Visual Studio editor makes it easy to inspect the definition of a type, method, or variable. One way is to go to the definition, in whichever file has it, by choosing **Go to Definition** or pressing **F12** anywhere a symbol is referenced. An even quicker way that doesn't move your focus away from the code you're working on is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-at-a-definition).
221221

222222
Let's peek at the definition of the `string` type.
223223

docs/get-started/tutorial-editor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ The code block collapses to just the first line, followed by an ellipsis (`...`)
247247

248248
::: moniker range="<=vs-2019"
249249

250-
The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../ide/go-to-and-peek-definition.md#peek-definition). Let's peek at the definition of the `string` type.
250+
The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../ide/go-to-and-peek-definition.md#peek-at-a-definition). Let's peek at the definition of the `string` type.
251251

252252
1. Right-click on any occurrence of `string` and choose **Peek Definition** from the content menu. Or, press **Alt**+**F12**.
253253

@@ -261,7 +261,7 @@ The Visual Studio editor makes it easy to inspect the definition of a type, meth
261261

262262
::: moniker range=">=vs-2022"
263263

264-
The Visual Studio editor makes it easy to inspect the definition of a type, method, or variable. One way is to go to the definition, in whichever file has it, by choosing **Go to Definition** or by selecting the **F12** key anywhere a symbol is referenced. An even quicker way that doesn't move your focus away from the code you're working on is to use [Peek Definition](../ide/go-to-and-peek-definition.md#peek-definition).
264+
The Visual Studio editor makes it easy to inspect the definition of a type, method, or variable. One way is to go to the definition, in whichever file has it, by choosing **Go to Definition** or by selecting the **F12** key anywhere a symbol is referenced. An even quicker way that doesn't move your focus away from the code you're working on is to use [Peek Definition](../ide/go-to-and-peek-definition.md#peek-at-a-definition).
265265

266266
Let's peek at the definition of the `string` type.
267267

docs/get-started/visual-basic/tutorial-editor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ The code block collapses to just the first line, followed by an ellipsis (`...`)
198198

199199
::: moniker range="<=vs-2019"
200200

201-
The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-definition). Let's peek at the definition of the `String` type.
201+
The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-at-a-definition). Let's peek at the definition of the `String` type.
202202

203203
1. Right-click on the word `String` and choose **Peek Definition** from the content menu. Or, press **Alt**+**F12**.
204204

@@ -212,7 +212,7 @@ The Visual Studio editor makes it easy to inspect the definition of a type, meth
212212

213213
::: moniker range=">=vs-2022"
214214

215-
The Visual Studio editor makes it easy to inspect the definition of a type or class member. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-definition). Let's peek at the definition of the `String` type.
215+
The Visual Studio editor makes it easy to inspect the definition of a type or class member. One way is to navigate to the file that contains the definition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../../ide/go-to-and-peek-definition.md#peek-at-a-definition). Let's peek at the definition of the `String` type.
216216

217217
1. Right-click on the word `String` and choose **Peek Definition** from the content menu. Or, press **Alt**+**F12**.
218218

docs/ide/go-to-and-peek-definition.md

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: View type definitions with Go To and Peek features
33
description: Explore the Go To Definition and Peek Definition features that enable you to easily view the definition of a type or member in Visual Studio.
4-
ms.date: 01/10/2018
5-
ms.topic: conceptual
4+
ms.date: 08/21/2024
5+
ms.topic: concept-article
66
helpviewer_keywords:
77
- code editor, view definition
88
- go to definition
@@ -13,64 +13,85 @@ author: ghogen
1313
ms.author: ghogen
1414
manager: mijacobs
1515
ms.subservice: general-ide
16+
17+
#customer intent: As a developer, I want to use the Go To and Peek features in Visual Studio, so I can easily view type and member source definitions for my code.
1618
---
19+
1720
# View type and member definitions
1821

19-
Developers often need to view the source code definitions for types or class members they use in their code. In Visual Studio, the **Go To Definition** and **Peek Definition** features enable you to easily view the definition of a type or member. If the source code is not available, metadata is displayed instead.
22+
Developers often need to view the source code definitions for types or class members they use in their code. In Visual Studio, the **Go To Definition** and **Peek Definition** features let you easily view the definition of a type or member. If the source code isn't available, Visual Studio shows the metadata instead.
2023

21-
## Go To Definition
24+
## Go to a definition
2225

23-
The **Go To Definition** feature navigates to the source of a type or member, and opens the result in a new tab. If you are a keyboard user, place your text cursor somewhere inside the symbol name and press **F12**. If you are a mouse user, either select **Go To Definition** from the right-click menu or use the **Ctrl-click** functionality described in the following section.
26+
When you use the **Go To Definition** feature, Visual Studio locates the source code for the selected type or member. If the source code is in a different file, the file opens in a new window. Visual Studio changes the current focus to highlight the relevant entry.
2427

25-
### Ctrl-click Go To Definition
28+
:::image type="content" source="./media/go-to-definition-new-window.png" border="false" alt-text="Screenshot that shows how Go To Definition opens the source file for the selected symbol in a new window." lightbox="./media/go-to-definition-new-window.png":::
2629

27-
**Ctrl**+**click** is a shortcut for mouse users to quickly access **Go To Definition**. Symbols become clickable when you press **Ctrl** and hover over the type or member. To quickly navigate to the definition of a symbol, press the **Ctrl** key and then click on it. It's that easy!
30+
There are several ways you can access **Go To Definition**:
2831

29-
![Mouse click go to definition animation](../ide/media/click_gotodef.gif)
32+
- Position the cursor inside the symbol name and use the **F12** function key
3033

31-
You can change the modifier key for mouse-click **Go To Definition** by going to **Tools** > **Options** > **Text Editor** > **General**, and selecting either **Alt** or **Ctrl**+**Alt** from the **Use modifier key** drop-down. You can also disable mouse-click **Go To Definition** by unchecking the **Enable mouse click to perform Go To Definition** checkbox.
34+
- Right-click the symbol name and select **Go To Definition**
3235

33-
![Enabling mouse-click go to definition](../ide/media/editor_options_mouse_click_gotodef.png)
36+
- Use the **Ctrl**+**Click** keyboard/mouse shortcut on the symbol name
3437

35-
## Peek Definition
38+
### Change action shortcut
3639

37-
The **Peek Definition** feature lets you preview the definition of a type without leaving your current location in the editor. If you are a keyboard user, place your text cursor somewhere inside the type or member name and press **Alt + F12**. If you are a mouse user, you can select **Peek Definition** from the right-click menu.
40+
You can enable or disable the **Ctrl**+**Click** shortcut for **Go To Definition** with the **Enable mouse click to perform Go To Definition** option under **Tools** > **Options** > **Text Editor** > **General**.
3841

39-
To enable **Ctrl**+**click** functionality, go to **Tools** > **Options** > **Text Editor** > **General**. Select the option **Open definition in peek view** and click **OK** to close the **Options** dialog box.
42+
To change the modifier key for the shortcut, expand the **Use modifier key** dropdown list and select **Ctrl** (default), **Alt**, or **Ctrl**+**Alt**:
4043

41-
![Setting the mouse-click peek definition option](../ide/media/editor_options_peek_view.png)
44+
:::image type="content" source="./media/editor-options-go-to-definition.png" border="false" alt-text="Screenshot of the Text Editor options for the Go To Definition feature, including the 'Use modifier key' setting.":::
4245

43-
Then, press **Ctrl** (or whichever modifier key is selected in **Options**), and click on the type or member.
46+
## Peek at a definition
4447

45-
![Peek definition animation](../ide/media/peek_definition.gif)
48+
The **Peek Definition** feature lets you preview the definition of a type without changing the focus from your current file in the editor. Visual Studio opens a condensed **Peek** view window for the source file in place with your current file. You can change the size of the **Peek** view window to see more of the source definition:
4649

47-
If you peek another definition from the popup window, you start a breadcrumb path that you can navigate using the circles and arrows that appear above the popup.
50+
:::image type="content" source="./media/peek-definition-view-window.png" border="false" alt-text="Screenshot that shows how Peek Definition opens the source for the selected symbol in a peek view window within the current view." lightbox="./media/peek-definition-view-window.png":::
4851

49-
For more information, see [How to: View and edit code by using Peek Definition (Alt+F12)](how-to-view-and-edit-code-by-using-peek-definition-alt-plus-f12.md).
52+
When you close the **Peek** view window, your current code file remains open in the editor.
5053

51-
## View metadata as source code (C#)
54+
There are several ways you can access **Peek Definition**:
55+
56+
- Position the cursor inside the symbol name and select **Alt**+**F12** function key
57+
58+
- Right-click the symbol name and select **Peek Definition**
59+
60+
- Use the **Ctrl**+**Click** keyboard/mouse shortcut on the symbol name
61+
62+
### Change action shortcut
5263

53-
When you view the definition of C# types or members whose source code is not available, their metadata is displayed instead. You can see the declarations of the types and members, but not their implementations.
64+
You can configure the **Ctrl**+**Click** keyboard/mouse shortcut for **Go To Definition** to open the source code file in **Peek** view. Use the **Open definition in peek view** option under **Tools** > **Options** > **Text Editor** > **General**.
5465

55-
When you run the **Go To Definition** or **Peek Definition** command for an item whose source code is unavailable, a tabbed document that contains a view of that item's metadata, displayed as source code, appears in the code editor. The name of the type, followed by **[from metadata]**, appears on the document's tab.
66+
:::image type="content" source="./media/editor-options-peek-view.png" border="false" alt-text="Screenshot of the Text Editor options for the Peek Definition feature.":::
67+
68+
### Use breadcrumb path for multiple files
69+
70+
If you peek another definition from the open **Peek** view window, you start a breadcrumb path. You can peek forward and backward along the path by using the circles and arrows above the **Peek** view window:
71+
72+
:::image type="content" source="./media/peek-backward-breadcrumb.png" border="false" alt-text="Screenshot that shows the breadcrumb path of open source files for Peek Definition and the option to peek backward." lightbox="./media/peek-backward-breadcrumb.png":::
73+
74+
When you close the **Peek** view window, Visual Studio closes all open files in the breadcrumb path. For more information, see [View and edit code by using Peek Definition (Alt+F12)](how-to-view-and-edit-code-by-using-peek-definition-alt-plus-f12.md).
75+
76+
## View metadata as source code (C#)
5677

57-
For example, if you run the **Go To Definition** command for <xref:System.Console>, metadata for <xref:System.Console> appears in the code editor as C# source code. The code resembles its declaration, but does not show an implementation.
78+
When you try to look at the definition for a C# type or member and the source code isn't available, Visual Studio shows metadata for the symbol instead. You can see the declarations of the types and members, but not their implementations. The tab label for the window includes the symbol name followed by **[from metadata]**:
5879

59-
![Metadata as Source](../ide/media/metadatasource.png)
80+
:::image type="content" source="./media/view-source-metadata.png" border="false" alt-text="Screenshot that shows how Visual Studio displays metadata only when the source code for the selected symbol isn't available." lightbox="./media/view-source-metadata.png":::
6081

6182
> [!NOTE]
62-
> When you try to run the **Go To Definition** or **Peek Definition** command for types or members that are marked as internal, Visual Studio does not display their metadata as source code, regardless of whether the referencing assembly is a friend or not.
83+
> If you try to look at the definition for an *internal* type or member, Visual Studio doesn't display the metadata as source code, regardless of whether the referencing assembly is a *friend*. For more information, see [Friend assemblies](/dotnet/standard/assembly/friend).
6384
64-
### View decompiled source definitions instead of metadata (C#)
85+
### View decompiled source definitions (C#)
6586

66-
You can set an option to see decompiled source code when you view the definition of a C# type or member whose source code is unavailable. To turn on this feature, choose **Tools** > **Options** from the menu bar. Then, expand **Text Editor** > **C#** > **Advanced**, and select **Enable navigation to decompiled sources**.
87+
When the source code for the selected C# symbol isn't unavailable, you can set an option to see decompiled source definitions rather than metadata. Use the **Enable navigation to decompiled sources** option under **Tools** > **Options** > **Text Editor** > **C#** > **Advanced**.
6788

68-
![Viewing a decompiled definition](media/go-to-definition-decompiled-sources.png)
89+
:::image type="content" source="./media/view-source-decompiled.png" border="false" alt-text="Screenshot that shows how Visual Studio displays decompiled source code when the definition for the selected symbol isn't available." lightbox="./media/view-source-decompiled.png":::
6990

7091
> [!NOTE]
71-
> Visual Studio reconstructs method bodies using ILSpy decompilation. The first time you access this feature, you must agree to a legal disclaimer regarding software licensing and copyright and trademark laws.
92+
> Visual Studio reconstructs method bodies by using [ILSpy](https://github.com/icsharpcode/ILSpy) decompilation. The first time you access this feature, you must agree to a legal disclaimer regarding software licensing and copyright and trademark laws.
7293
7394
## Related content
7495

75-
- [Navigate code](../ide/navigating-code.md)
76-
- [How to: View and edit code by using Peek Definition (Alt+F12)](how-to-view-and-edit-code-by-using-peek-definition-alt-plus-f12.md)
96+
- [Navigate your code in Visual Studio](../ide/navigating-code.md)
97+
- [View and edit code by using Peek Definition (Alt+F12)](how-to-view-and-edit-code-by-using-peek-definition-alt-plus-f12.md)

docs/ide/media/click_gotodef.gif

-885 KB
Binary file not shown.
Loading
18.7 KB
Loading
Binary file not shown.
-30.6 KB
Loading
Binary file not shown.
282 KB
Loading

docs/ide/media/metadatasource.png

-9.46 KB
Binary file not shown.
86.5 KB
Loading
173 KB
Loading

docs/ide/media/peek_definition.gif

-593 KB
Binary file not shown.
128 KB
Loading
73.9 KB
Loading

docs/ide/media/vs2015_manage_subs.png

1.83 KB
Loading

docs/ide/reference/options-text-editor-advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Selected by default, this option enables the editor to suggest possible completi
5353

5454
## Click to peek in margin
5555

56-
The **Single click** setting is selected by default. The settings you choose from allow you to customize how Peek Definition works when you use it to display the differences between Git commits. You can change the default **Single click** setting to **Double click**, or you can select **None** to turn off the [Peek Difference UI](../../version-control/git-line-staging.md#peek-difference-support).
56+
The **Single click** setting is selected by default. The settings you choose from allow you to customize how Peek Definition works when you use it to display the differences between Git commits. You can change the default **Single click** setting to **Double click**, or you can select **None** to turn off the [Peek Difference UI](../../version-control/git-line-staging.md#view-staged-changes-with-peek-difference).
5757

5858
::: moniker-end
5959

0 commit comments

Comments
 (0)