Working With AI-Assisted IntelliCode In VS 2017 And VS Code

In this post, we will see how to install AI-assisted IntelliCode in Visual Studio 2017 and Visual Studio Code and get IntelliSense with IntelliCode in both Visual Studio and Visual Studio Code

Introduction

IntelliCode was introduced in preview at Microsoft's Build conference, putting artificial intelligence to work to improve the existing IntelliSense that provides code completion tips.
 
It comes in a Visual Studio Marketplace extension and leverages machine learning to supply numerous edges, as well as contextual IntelliSense, inference, and enforcement for code designs and targeted code reviews for pull requests.
 
The IntelliCode extension augments existing developer workflows with machine-learning services that offer an understanding of code and its context. This extension is a Technology Preview released under Microsoft DevLabs. It’s applicable for C#, C++ and XAML code these days, and can be updated in the future to support additional languages. The extension provides you with an early style of what’s to come with IntelliCode and permits you to supply feedback to the Visual Studio product team to help form its future.
 
Currently, IntelliCode works in Visual Studio 2017 (Version 15.8 and above only) and Visual Studio 2019 preview. It supports languages like C#, C++, and XAML in Visual Studio 2019, but only supports C# in 2018 (as of today).
 
IntelliCode also works in Visual Studio Code (which supports Python, TypeScript/JavaScript, and Java).
 
Install IntelliCode in Visual Studio 2017
 
As I mentioned earlier, IntelliCode supports version 15.8 and above. If your Visual Studio 2017 version is below 15.8, please update to the latest version. It is very easy to update the version. You can click the “Check for Updates” option from the "Help” menu.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
 
After updating to the latest version, you can download the IntelliCode. There are two ways available. The first way is to directly download from “Tools” -> “Extensions and Updates” menu. After downloading the extension, you must restart Visual Studio to start the installation. 
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code

Another way is to download it directly from the Microsoft site. Please download it from this URL.

After downloading the VSIX installer, you can click the “Install” button.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
 
After a successful installation, we can open an existing project (You can even create a new project too.) and open IntelliCodeby “View” -> “Other Windows” -> “IntelliCode
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
 
IntelliCode supports training our existing code base. Our code patterns can be used in other projects too. The biggest advantage is that we can share our model with our friends or colleagues. Here I am using my existing Blazor project to train the model. I can use this model in my next Blazor projects for automated code suggestions and tips.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code 
It will take some time to finish the model training based on the size of our code base. After successful training, you can see the suggestions from IntelliCode. The “starred” values are coming from IntelliCode.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
 
As I said earlier, we can share our model with other people easily. It will create a secured URL and you can share with your friends. They can add your model in their Visual Studio easily. You can retrain your model anytime with a new code base. 
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code

Please note one thing, Microsoft is always getting the data from your code base. If you want to inspect the detailed contents of the extracted data, you can do so after extraction when the training process is complete.

To inspect the contents of the extracted data, open the %TEMP%\Visual Studio IntelliCode folder.
 
You can see some files inside this folder.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
You can again open “UsageOutput” folder and see the usage JSON file.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code 
Now, we can see how to install IntelliCode in Visual Studio Code.

Install IntelliCode in Visual Studio Code

Open “View” -> “Extensions” menu.
 
You can search for IntelliCode and click “Install” button.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
 
After successful installation, you can re-open Visual Studio Code. It will take some time to download the IntelliCodemodels into your project.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code
 
You can see the below code suggestions from IntelliCode. Please note currently it supports TypeScript, JavaScript, Python, and Java languages only.
 
Work with AI-assisted IntelliCode in VS 2017 and VS Code

Please note that Visual Studio Code currently does not support training our own model. Custom models are currently only supported in Visual Studio for C#. If you would like to see custom model support for TS/JS in VS Code, please vote on GitHub Issue #26 by adding a thumbs-up. (I already did it.)

Conclusion
 
In this post, we have installed IntelliCode in Visual Studio 2017 and Visual Studio Code. We have seen some basic IntelliSense features from IntelliCode. Please post your valuable comments on IntelliCode. If you like IntelliCode, I will plan a more detailed article utilizing all the IntelliCode features.

References

  • https://visualstudio.microsoft.com/services/intellicode/
  • https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.VSIntelliCode
  • https://github.com/MicrosoftDocs/intellicode/blob/master/docs/intellicode-visual-studio.md
  • https://visualstudiomagazine.com/articles/2018/07/19/intellicode-update.aspx
  • https://blogs.msdn.microsoft.com/visualstudio/2018/05/07/introducing-visual-studio-intellicode/
  • https://blogs.msdn.microsoft.com/visualstudio/2018/07/17/visual-studio-intellicode-inferring-coding-conventions-for-consistent-code/


Similar Articles