What's new in Visual Studio 2022?

Contents

Visual Studio 2022 is now in preview and will be released in November 2021 together with .NET 6, that will be compatible. Includes many new features and improvements, like AI IntelliCode which can autocomplete code snippets for you.

You can download the preview from your website. While it is still “experimental” and is not ready for production, still visual studio, so that, unless you depend on extensions that have not been updated yet, don't be afraid to try.

We'll cover the most important changes starting in the Preview 3, but if you want to read the patch notes line by line, you can do it from microsoft docs. There are also a roadmap describing the general direction.

Finally it is from 64 bits

Visual Studio has always been 32 bits, which means that it has been limited to 4 GB RAM in main process. In general, does not exceed this budget for normal projects, but some users may run into insufficient memory exceptions with particularly large solutions.

With VS 2022, it is fixed and now it is an application of 64 bits. Microsoft has tested projects with 1600 projects and 300k files, and it works fine.

In theory, 64 bits should run faster, and it seems to be a bit faster on startup times, but Microsoft has also been working on performance in general, so it's hard to know how much this really affects you. Either way, a good change.

Of course, you can still develop applications from 32 bits with VS 2022. This only applies to the editor.

AI IntelliCode is awesome

Visual Studio Features 2022 a major upgrade to your IntelliCode autocomplete engine. It is able to autocomplete whole lines and code snippets, and it works very well.

It is a little different from GitHub Copilot, who does a similar job. Copilot will generate full code snippets and works best for small, contained functions with a clear solution. It's great, but it has its own problems, mainly the fact that the code you generate is not guaranteed to be what you want (and can extract code word for word from random GitHub repositories, what is another problem).

IntelliCode takes a much more restricted approach and just fills in a single line, taking into account some of the following factors:

  • Variable names and positions
  • Libraries you are using
  • Functions in the surrounding code
  • The IntelliSense drop-down list, which you can actually press down to give IntelliCode more suggestions

After using it for two weeks, it's something you really have to try for yourself. It's surprisingly smart, and many times while using it I found myself thinking “Woof, I was about to write that!”

For instance, write a function that takes a number from 1 al 12:

To understand and provide this result, IntelliCode is doing a lot more than auto-completing the syntax; Understand that I am waiting for an exception, pretty obvious since i'm typing “throw”, and you may notice that this exception is only thrown if an integer size comparison fails. Know what Width is an argument that is being checked before the code is executed, and that I am throwing an exception because something is wrong with the argument.

Knowing all this, takes a wildly accurate guess about my intentions and decides that a ArgumentOutOfRangeException it must be what i'm trying to write, before I can start writing “new”.

AND, if you advance one page, you can fill in the results for different options. It's still a bit inconsistent (decided to code “Width” and then used nameof) but, usually, It works well.

IntelliCode runs all the time, and all you have to do is press tab-tab to accept it; otherwise, you can continue writing. Currently, only works for C #, but more languages “will arrive soon”.

.NET support 6

.NET 6 it's the latest version, also in preview version. VS 2022 will have built-in support for it and all its features, and it will be default in .NET 6 for new projects.

In particular, VS 2022 will have full support for .NET MAUI, the cross-platform application UI, Microsoft's new standard for cross-platform native application development.

.NET hot reload

One of the most annoying things about programming is looking at the screen, wait for the application to compile, starts up and updates with the latest changes. Hot Reloading is a feature of many other languages ​​like JavaScript, and has been used by web frameworks like React to make quick changes. Nevertheless, up to now, there has been no standardized solution for .NET.

It is not completely universal and requires a specific project setup, but VS 2022 includes hot recharge for “WPF, Windows Forms, .NET MAUI previews, ASP.NET Core applications with code behind, console apps, WinUI 3 and many others”. This excludes class libraries used by another application.

Certain types of changes may not be applied correctly, which will ask you to restart successfully. You can see the complete list of them here, but the essence is:

  • Unmodified method signatures
  • Do not add usage statements
  • Unmodified interfaces
  • Without renaming members of any kind

Basically, you can edit the code in any method, but once you start to touch the structure of the project, you may need to reboot.

It is well integrated into the VS debugging experience, with a new icon for “Apply code changes” which will activate hot recharge. You can also use the new dotnet watch command to automatically hot reload on file changes.

Razor web apps / Blazor can currently make use of hot recharge, but Blazor WebAssembly still has a few things to resolve and currently still not working. Nevertheless, it is working on it and it is possible that it will reach the final version at the end of November.

Remote test

VS 2022 includes an experimental preview that allows you to run tests in other environments, including linux containers, WSL and even via SSH.

It has a bit of setup and, of course, you will need to make sure your environment is configured to run your code correctly, but once i am, you will be able to select different environments when running your tests.

General improvements

There are many small changes in break down from patch notes, so we will list some of the most interesting ones here.

Purification has seen some improvements in quality of life, with new context options for more advanced breakpoints, as well as “Force Cursor Execution”, which will ignore all existing breakpoints and stop at the line of code you selected. This can be very useful if you want to test something without removing all breakpoints or manually skipping everything again.

Breakpoint context menu

Force Cursor Execution

VS Git integrations now support multiple repositories per solution, and committing to many repositories is now easier.

All icons have been redesigned for consistency.

Examples of new icons with light and dark backgrounds

XML comments now support multi-line comments with preserved blanks and CDATA blocks.

Quick Info for XML preserves whitespace

“Search all references” no longer produces garbage repeating results when in a multi-goal project.

Find all reference groups Multi-purpose projects

Razor Pages / Blazor has gotten numerous editing integrations and will now work better with IntelliSense, syntax highlighting and better formatting in @code blocks. Now you can also use “View code” in the archives of Razor, which has been an annoying limitation for a while.

TagHelpers classification support

And there are some more project templates, including Angular and React apps hosted on ASP.NET Core, that can be created with API integrations automatically.

To get the full list of changes, you can check the VS patch notes 2022.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.