DEV Community

Dirk Strauss
Dirk Strauss

Posted on • Originally published at dirkstrauss.com on

Visual Studio IntelliCode – AI For your Code

Visual Studio IntelliCode allows you to add the power of artificial intelligence to your code. Enabling IntelliCode is super easy, and I’m going to show you exactly how to do this.

LOOKING FOR SOMETHING ELSE? TRY THESE LINKS INSTEAD:

If you are a bit short on time, go and check out the video explainer on this topic.

This should get you up to speed quickly enough. If you enjoy the video, please consider subscribing to the channel and giving the video a thumbs up.

Visual Studio IntelliCode Explained

IntelliCode is a super exciting addition to Visual Studio. Microsoft calls it AI-assisted development. It will save you time by putting what you are most likely to use at the top of your completion list. These are displayed as starred recommendations.

Suggestions based on code context

IntelliCode uses open source GitHub projects with 100 stars or more to generate recommendations for your code. IntelliCode will also build a custom model to provide recommendations from your source code. These are things such as methods from your own classes or domain specific library calls.

Note: IntelliCode features are off by default. To enable these, go to Tools > Options > IntelliCode and enable the features.

Visual Studio IntelliCode features are off by default

This will enable IntelliCode for your project.

Install Visual Studio IntelliCode

If you don’t have IntelliCode installed, head on over to the Extensions > Manage Extensions window to download and install it.

Installing from Manage Extensions

After downloading, you will need to restart Visual Studio in order to install IntelliCode.

Building an IntelliCode Model

In Visual Studio 2019, hit Ctrl+Q and type IntelliCode into the search window. Select IntelliCode Model Management from the results or go to View > Other Windows > IntelliCode Model Management to access the Visual Studio IntelliCode window.

Visual Studio IntelliCode Model Management

From here, you can build IntelliCode models for your projects. You can see the models shared with you, share the model you just built, retrain or delete the IntelliCode model.

Can I Use it in My Code?

At the time of this post, IntelliCode works in Visual Studio 2017 (version 15.8 and up) as wella s Visual Studio 2019. It also supports the following languages:

  • C#
  • C++
  • XAML (In Visual Studio 2019)

IntelliCode also works in Visual Studio Code and supports:

  • Python
  • TypeScript
  • JavaScript
  • Java

Microsoft is bringing the goodness of AI to Visual Studio Code. Now that is really neat!

View Extracted Data

After you have generated your model, you can head over to the following folder:

 %TEMP%\Visual Studio IntelliCode 
Enter fullscreen mode Exit fullscreen mode

Here you should see a UsageOutput folder in one of the created folders. Look for a usage JSON file. This is the contents of the extracted data. Code analysis all happens client side. This data extraction is then fed into Microsoft’s Model Service which is uploaded to the service in the cloud.

It is important to note that Microsoft doesn’t receive any of your code. It only uploads data and information about your code. So your code remains on your machine.

Get the Source Code

If you want to grab a working example of the code used in this blog post, head on over to the following GitHub repo and clone the repo to your local machine.

dirkstrauss/IntelliCodeDemo

If you have any comments or suggestions, please feel free to put those in the comments section below. Give it a try, and see what IntelliCode can do for you!

The post Visual Studio IntelliCode – AI For your Code appeared first on Programming and Tech Blog.

Top comments (0)