Main image of article Visual Studio 2022: What's New with Microsoft's IDE?

Visual Studio 2022, the latest iteration of Microsoft’s integrated development environment (IDE), came out in November 2021. Compared to Visual Studio 2019, the two are very similar—at first glance, at least. For example, the menus received only slight tweaks. But under the proverbial hood, there are a lot of differences worth discussing. 

For example, Visual Studio 2022 is the first Visual Studio that is 64-bit—but they certainly haven't rushed the move from 32-bit (Windows XP had a 64-bit version available back in 2005!).

The latest version of Visual Studio can also handle thousands of projects and hundreds of thousands of files; Microsoft has a video showing it loading a solution with 1,601 projects and 298,326 files. I wonder how long that takes to compile from scratch!

Upgrading to Visual Studio 2022

I switched over from Visual Studio 2019 to Visual Studio 2022 without breaking a sweat. Solutions and Projects just open; there isn’t the tortured upgrade path of previous versions.  

Microsoft is giving Git much higher priority than its own TFS version control. Incidentally, TFS changed its name to Azure DevOps Server in 2020 (read more about that), though TFS is still easier to pronounce. Team Explorer, the VCS tab in Visual Studio, now defaults to Git, and I had to root about in the options to bring TFS back. As my daily job involves TFS, it makes me wonder what Microsoft’s long-term plans are for it. 

Hot Reload

Microsoft has taken a page out of Flutter's book by adding hot reload for .NET applications, including web forms, WPF .NET Maui, Console, WPF, Blazor, CSS and ASP.NET and native C++ apps. It works in applications running under .NET 5 in the debugger (and in .NET 6 apps outside of the debugger).

What this means: While a program is running, if you make a change in code to a supported element, just click the Hot Reload button and it changes without stopping the program or recompiling. If you can change the property (for example) in the debugger, then you can do it with Hot Reload. 

For instance, in a simple WinForms application, I added a button to a form that displayed the word “Hello” when you clicked the button. I ran this with Ctrl-F5, which was running without the debugger. I changed the source code to display “Go Away,” clicked the Hot Reload button, and, when I clicked the button in the application, it displayed “Go Away.” It is a remarkable feature and could save developers a lot of time. 

C# 10.0

There's nothing major in C# 10 beyond a collection of small improvements. A lot of it is code simplification, with global and implicit usings and removing the need for namespaces to nest code when the file only has one namespace. So instead of:

namespace fred {

  class MyClass {
    ...
  }
}

Now you have:

namespace fred;
class MyClass {
...
}

Other changes include the addition of natural types for lambdas and method groups and improvements on structs. Record structs are a new addition to the Record classes that were introduced in C# 9.0. Records are more suited for defining immutable data classes or structs. Record structs can be more efficient, and two record structs are considered equal if they are the same type and the members have the same values. This is different to classes where two objects are only equal if they refer to the same object. 

The templates for C# have been expanded and revised. When you create a new project, you get a list of templates for the project. C# now holds the record for the smallest “Hello World!” program with just one line of code. 

Console.WriteLine("Hello, World!");

That's it. No usings, namespaces or Public Class Program are needed; it just compiles and runs. It makes use of implicit usings where these usings listed below are now specified in the template file. In C#, a using statement specifies which namespaces you wish to use and imports all the types from it. See this page for more details on templates.

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

More significant is the accompanying launch of .NET 6, which is a three-year Long Term Support version. This is meant to be the version that unifies the SDK Base libraries and runtimes across mobile, desktop, IoT and cloud (i.e. Azure) apps.

Improvements in .NET 6

There are significant speed improvements, particularly in file I/O but also throughout (more details of changes in this Microsoft blog entry).  

One of the more significant changes is improvement in JSON handling. Microsoft started this in .NET 5, and .NET 6 continues it with new features, including serialization and deserialization to and from streams. If you use Newtonsoft for JSON, it might be worth checking out .NET JSON support.

Conclusion

The latest Visual Studio hasn't really altered that much, other than the move to 64-bit, but given all of the small enhancements in C# and other languages, .NET 6 and so on, it's definitely worth the upgrade. If you are using .NET 5, the Hot Reload feature is probably enough justification by itself to upgrade.