Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
strauss_d_getting_started_with_visual_studio_2022_learning_a.pdf
Скачиваний:
26
Добавлен:
26.06.2023
Размер:
17.04 Mб
Скачать

Chapter 1 Getting to Know Visual Studio 2022

What’s Available?

As mentioned, new code fixes and refactorings are available such as

•\

Add missing usings

•\

Extract block to code-behind

•\

Add usings for component

•\

Fully qualify component

•\

Create component

Navigation support such as Go to Definition on components allows developers to quickly navigate throughout files. This means that when a developer presses F12 on a component tag, they can navigate to the component code. The new Razor editor also supports smarter syntax completions. Visual Studio Live Share is now also supported in Razor.

Hot Reload

A welcome new feature in Visual Studio 2022 is the addition of Hot Reload. This works for both managed .NET and native C++ apps. Hot Reload saves a developer from having to stop the debug process between edits. This means less rebuilding, restarting, and renavigating to the specific location in the application you were debugging.

For a list of supported .NET app frameworks and scenarios, view the document at the following link: https://docs.microsoft.com/en-us/visualstudio/debugger/hot- reload?view=vs-2022#supported-net-app-frameworks-and-scenarios.

Navigating Code

Visual Studio provides several features allowing developers to navigate code throughout the solution. Knowing how to use these navigation features will save you a lot of time.

27

Chapter 1 Getting to Know Visual Studio 2022

Navigate Forward and Backward Commands

If you look at the toolbar in Visual Studio, you will see the Navigate Forward (Ctrl+Shift+-) and Navigate Backward (Ctrl+-) buttons. These allow developers to return to the last 20 locations that the developer was at as seen in Figure 1-22.

Figure 1-22.  Navigate forward and backward

You can also find these commands from the View menu under Navigate Backward and Navigate Forward.

28

Chapter 1 Getting to Know Visual Studio 2022

Navigation Bar

The navigation bar in Visual Studio as seen in Figure 1-23 provides drop-down boxes that allow you to navigate the code in the code base. You can choose a type or member to jump directly to it in the code editor.

Figure 1-23.  Visual Studio navigation bar

It is useful to take note that members defined outside the current code file will be displayed but will be disabled and appear gray. You can cycle through the drop-down boxes in the navigation bar by pressing the tab key.

Each drop-down also has its own individual function. The left drop-down will allow you to navigate to another project that the current file belongs to. To change the focus to another class or type, use the middle drop-down to select it. To navigate to a specific procedure or another member in a particular class, select it from the right drop-down.

29

Chapter 1 Getting to Know Visual Studio 2022

Find All References

Visual Studio allows you to find all the references for a particular element in your code editor. You can do this by selecting the code element and pressing Shift+F12 or by rightclicking and selecting Find All References from the context menu.

Figure 1-24.  Find All References results

The find results are displayed in a tool window as seen in Figure 1-24. The toolbar for the find results tool window as seen in Figure 1-25 is also really helpful.

Figure 1-25.  References window toolbar

From here, you can do the following:

•\

Change the search scope

•\

Copy the selected referenced item

•\

Navigate forward or backward in the list

30