Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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

Visual Studio IntelliCode

Visual Studio IntelliCode is a really nice feature that has been added to Visual Studio. Microsoft calls it AI-assisted development because it uses machine learning to figure out what you are most likely to use next and put that suggestion at the top of your completion list. These are usually displayed as starred recommendations.

Without IntelliCode, when you dot on an object such as our package object in the AcmeCorpShipping solution, you will see the usual completion list that Visual Studio pops up as seen in Figure 1-53.

Figure 1-53.  Visual Studio completion list

In Visual Studio 2022, hit Ctrl+Q and type IntelliCode to search for IntelliCode. Select IntelliCode Model Management from the search results. You can also go to View Other Windows and click IntelliCode Model Management. You will then see the Visual Studio IntelliCode window pop-up inside Visual Studio as seen in Figure 1-54.

54

Chapter 1 Getting to Know Visual Studio 2022

Figure 1-54.  Visual Studio IntelliCode

Click Create new model to allow Visual Studio IntelliCode to analyze your code and create the model. When Visual Studio has completed the analysis and created the model, you will be able to share the model with other developers (which is great for teams), delete the model, or retrain the model as seen in Figure 1-55.

55

Chapter 1 Getting to Know Visual Studio 2022

Figure 1-55.  Visual Studio IntelliCode model completed

This time around, if you dot on the package in the AcmeCorpShipping solution, you will see the starred recommendations from IntelliCode as seen in Figure 1-56.

Figure 1-56.  IntelliCode starred recommendations

56

Chapter 1 Getting to Know Visual Studio 2022

Compare this to the Visual Studio completion list in Figure 1-53. You can see that IntelliCode has identified the TrackPackage method as the most likely method that you will want to use.

IntelliCode uses open source GitHub projects with 100 stars or more to distill the wisdom of the community to generate recommendations for your code. To demonstrate how clever Visual Studio IntelliCode is, have a look at Figure 1-57.

Figure 1-57.  IntelliCode acting on a string

IntelliCode knows the most likely things I would want to do with a string variable and places those methods at the top of the suggestion list. The suggestions look quite a bit different when I am working with a string array as seen in Figure 1-58.

Figure 1-58.  IntelliCode acting on a string array

57