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

Chapter 1 Getting to Know Visual Studio 2022

Here, you will see that you can configure the code cleanup options by clicking the link and selecting the available fixes to apply. Once you have configured a code cleanup profile, you can check the option to run the code cleanup profile when saving a file.

Add Missing Using on Paste

Developers often copy and paste code found in another section of the project or from another online resource. Doing this usually requires developers to add the missing using statements. Now you can enable this feature to automatically add the missing using statements when pasting copied code. Go to Tools Options Text Editor C# Advanced, and scroll down a bit, and you will see an option to Add missing using directives on paste.

Features in Visual Studio 2022

Visual Studio 2022 comes packed with a few very nice productivity features. A lot of thought has been put into making Visual Studio easy to navigate and to find things in Visual Studio 2022. The first feature I want to have a look at is Visual Studio Search.

Visual Studio Search

I think that we can all agree that more speed equals improved productivity. The faster I can access a menu item, and the less time I have to spend looking for something, the more my productivity increases. This is where Visual Studio Search comes in.

47

Chapter 1 Getting to Know Visual Studio 2022

If you hold down Ctrl+Q, you will jump to the search bar where you can immediately start typing as seen in Figure 1-46.

Figure 1-46.  Visual Studio Search

Visual Studio will perform the required search and display the results to you that you can further filter by clicking the Menus, Components, or Templates tabs. Visual Studio performs a fuzzy search, which means that even if you misspell a word, chances are that Visual Studio will know what you intended to type and return the correct results for you.

Solution Filters

Sometimes, we have to work on Solutions that contain a lot of projects. More often than not, you as a developer will not be working on every project in that specific solution. This is where Solution Filters come in. They allow you to only load the projects that you care about or are actively working on. Consider the currently loaded solution as seen in Figure 1-47.

48

Chapter 1 Getting to Know Visual Studio 2022

Figure 1-47.  AcmeCorpShipping solution unfiltered

You can see that all the projects are loaded in this solution. If we only work on the ShipmentLocator and ShipMethodLogic projects, we can create a Solution Filter to only load those projects. Right-click the projects that you don’t work on, and click Unload Project from the context menu. Your solution will now look as in Figure 1-48.

49

Chapter 1 Getting to Know Visual Studio 2022

Figure 1-48.  AcmeCorpShipping solution with unloaded projects

Now, with the projects unloaded that you do not work on, right-click the solution and select Save As Solution Filter as seen in Figure 1-49.

50

Chapter 1 Getting to Know Visual Studio 2022

Figure 1-49.  Save As Solution Filter

Visual Studio will now create a new type of solution file with an .slnf file extension as seen in Figure 1-50.

51

Chapter 1 Getting to Know Visual Studio 2022

Figure 1-50.  Save as Solution Filter file

When you open your project using the Solution Filter, you will see as in Figure 1-51 that only the projects you selected to keep will be loaded.

Figure 1-51.  Filtered solution

52

Chapter 1 Getting to Know Visual Studio 2022

Now with the filtered solution, if you click the solution, you will see that you can Load App Projects, Show Unloaded Projects, or Load Project Dependencies from the context menu as seen in Figure 1-52.

Figure 1-52.  Filtered solution context menu

You still have full control of the filtered solution from the context menu and can easily load the full solution as needed.

53