What’s new in Visual Studio 2022 and C# 10.0?

iteo
5 min readDec 10, 2021
visual studio 2022

Visual Studio 2022 is a new version of an IDE designed for compiling and implementing innovative applications on any platform. After many updates and long term support of Visual Studio 2019, the Visual studio 2022 is launching with new features along with .NET 6 and C# 10.0 language. So, what exactly does Microsoft offer in the latest versions?

News in Visual Studio 2022

One of the many highly anticipated features in the newest release is the 64-bit architecture. It makes the development environment in many cases substantially faster than the previous version. Now, larger solutions load much faster and running truly enormous solutions doesn’t cause out of memory exceptions. Unfortunately, it comes at a cost of overall more memory usage than before. Microsoft developers are still working on performance of their products which constantly makes them even better.

The new iteration of the product focuses on productivity, better code navigation and improved debugging experience. The included Artificial Intelligence extends the operation of IntelliCode through code suggestions. The functionality works well, but it still contains some rough edges, such as the property hints sometimes not corresponding to the actual properties. It also has a built-in spell checker to help you code more accurately with fewer errors. The new Visual Studio also allows you to take advantage of hot reloading in .NET applications, and editing ASP.NET Web pages with Web Live Preview. Below is a list of some of the new features in Visual Studio 2022:

1. Hot reload for .NET, C++, Blazor and CSS

Now if you are making changes in your code and you hit save, all your changes will automatically take effect in your program without recompiling.

2. XAML Live Preview & hot reload

When your application is running, you can bring the running application window to Visual Studio and make specific changes that will immediately affect the project view.

3. Build and Debug C++ projects on WSL 2

By using CMake cross-platform support you can build and debug the same project on different systems. When targeting WSL 2 distro, Visual Studio will automatically copy files from Windows to WSL 2.

4. Multi-repo git support

Visual studio has the ability to recognize multiple repositories connected to one solution and will display it in the status bar. Multi repos make it possible to commit any changes across the active repositories from the git changes window.

5. Live Share

Real-time collaboration is now improved with integrated text chat fostering quick conversations about code without any context switches.

6. Dependent Breakpoints

This is a new feature which lets you hit a specific breakpoint only when a previously specified breakpoint has been hit first. For example, it can be useful in the scenario where you have to break at method B only if this method has been called from method A.

7. New dark theme and redesigned icons

The new theme is more polished and looks better. Redesigned icons are bigger, more visible and color-matched to the new look of the new environment. The whole UI experience is now more coherent.

And many many more news which I didn’t describe here you can see in the Microsoft documentation.

News in C# 10.0

C# 10.0 adds the following features and enhancements to the C# language:

  • Record structs

Record structs are value type structs. Incoming parameters inside the constructor are converted to properties which are automatically bound as public.

internal record struct Rectangle(int Height, int Width);

  • Improvements of structure types

Here we can use the ‘with’ expression to accept the RectangleTwo constructor parameterless and field initializers section of the structure. A operand of the with expression can be of any structure type

internal struct Rectangle

{

public int Height { get; set; }

public int Width { get; set; }

public Rectangle()

{

Height = 0;

Width = 0;

}

public Rectangle(int height, int width)

{

Height = height;

Width = width;

}
}

var rectangle = new Rectangle(100, 100);
var rectangleTwo = rectangle with { Height = 20, Width = 10 };

  • Record types can seal ToString()

Now in record types the ToString method can be marked with the sealed keyword to prevent the compiler from generating new ToString implementations for the derived classes.

  • Global using directives

The new global modifier now can be added to the using directive, applying it to all files in the project. Great way to minimize redundancy.

global using Matrix.Helpers;

  • File-scoped namespace declaration

This new declaration allows the removal of a pair of brackets below namespace saving horizontal space.

namespace Matrix.Helpers;

internal static class RandomGenerator
{
//…
}

  • Extended property patterns

Extended property patterns make it cleaner to do a condition on a nested property.

Person person = new Person
{
FirstName = “Gregory”,
Address = new Address { City = “London” }
};

if (person is { Address.City: “London” })
{
//…
}

  • Allow const interpolated strings

Now, if the placeholders of an interpolated string are all constant strings, then the resulting string is also constant.

const string Name = “Visual Studio”;
const string InterpolationName = $”{Name} 2022″;

  • Interpolated string handlers

Allows you to write custom handlers to execute your own code to process the placeholder expressions in an interpolated string. Might come in handy if your output string needs to be formatted in a specific way, for example in loggers.

  • Allow both assignment and declaration in the same deconstruction

The latest change in C# removes the limitation of full initialization or declaration at the point of value deconstruction.

internal class Point

{

public int X { get; set; }

public int Y { get; set; }

public void Deconstruct(out int x, out int y)

{

x = X;

y = Y;

}

}

var point = new Point { X = 10, Y = 20 }

int y = 0;

(int x, y) = point;

What will be in the future?

In my opinion, Microsoft is going in the right direction to make their products much better and easier to use. They are focusing on performance and continuous support of their products. If they keep a good pace, we can expect more projects using their technologies in the future.

--

--

iteo

iteo is an international digital product studio founded in Poland, that helps businesses benefit from technology better. Visit us on www.iteo.com