As you might have seen, a preview for Visual Studio 2022 was released a few days ago:

Visual Studio 2022 Preview 1 now available!
We’re excited to announce that the first preview release of Visual Studio 2022 is ready to install! This is the first release of a 64-bit Visual Studio and we’d love for you to download it, try it out, and join us in shaping the next major release of Visual Studio with your feedback.

I'm not normally the early-adopter type, but I love Visual Studio and this version is going to be 64-bit, so I jumped all over that preview and have been using it for a few days now. It is pretty dang seamless, especially for a preview, but there's one feature I want to point out that makes this worth your time to download and install: IntelliCode.

IntelliCode

In the MVC project I'm currently working on, a user can check on the status of up to four packages. We have a view model for this that looks like the following:

public class PackageRequestVM
{
    public string PackageNumber1 { get; set; }

    public string PackageNumber2 { get; set; }

    public string PackageNumber3 { get; set; }

    public string PackageNumber4 { get; set; }
}
Code is simplified for this demo.

I then needed, in my controller, to map these items to a List<string> object, which is what the lower-level method needed as a parameter. However, I only wanted to map them if they were not null or whitespace.

So I wrote out the first check:

When I started to write out the same code for the second package number, something amazing happened:

Visual Studio started correctly predicting the next lines of code that I wanted to write!

This is a new feature called IntelliCode, an AI-assisted predictive coding tool. You can read more about it here:

Visual Studio IntelliCode | Visual Studio - Visual Studio
Visual Studio IntelliCode is an experimental set of AI-assisted development capabilities for next-generation developer productivity.

The suggestions IntelliCode provides appear as greyed-out text:

All you have to do is hit Tab, and Visual Studio inserts the suggested line for you!

This is awesome, and it's saving me a lot of time when writing slightly repetitive code like the sample above. Go get this preview and see for yourselves!

Visual Studio 2022 Preview
Join us in shaping our next major release of Visual Studio. Try our 64-bit Visual Studio that is faster and more reliable than ever.

Also, check out the announcement post for IntelliCode!

Type less, code more with IntelliCode completions
In Visual Studio 2022 Preview 1 you can automatically complete code, up to a whole line at a time! Check out the video to see what it can do; it shows writing real code from a controller of the ASP.NET eShopOnWeb reference application.

This article is for paying subscribers only

Sign up now and upgrade your account to read the article and get access to the full library of articles for paying subscribers only.

Sign up now Already have an account? Sign in