Follow us
Contact us

Microsoft .NET 6: Top 10 New Features

Each year Microsoft rolls out a new and improved version of .NET. In 2020 we witnessed the release of .NET 5 – the successor of .NET Core 3.1 and .NET Framework 4.8. Being the first unified platform in the series, .NET 5 was everything we were hoping for and more. The version not only managed to fix the universal fragmentation that .NET is known for since its first release in 2002 but also brought us some valuable features for the very first time. 

Ever since the release of .NET 5, however, we have been closely following each new preview of the upcoming .NET 6 and C# 10 that are scheduled for later in November. This is the culmination of all .NET releases up until now and the first LTS (long-term support) version since 2019. In the following article, we are going to share with you some of the features we have found most useful in .NET 5, a year after its release, and give you a sneak-peak of what we are most looking forward to from .NET 6.

Microsoft Release schedule

Beginning in 2020 with .NET 5, each November Microsoft does one major release. Customers can choose their preferred version – LTS or current release. They both offer the same quality, however, the length of the support varies – LTS versions receive free support for the next 3 years, while current ones – for only 18 months.

In September this year, Microsoft rolled out .NET 6 RC (Release Candidate), which essentially is a preview of the version we are all waiting for this November during the .NET Conf – a free virtual event for developers around the world, celebrating all major .NET releases. 

.NET 6

microsoft .net 5

Following the release of .NET Core 3.1, the next big thing from Microsoft was .NET 5. An entire year after the release we can now confidently talk about what we’ve learned about the version. Microsoft successfully created a system covering a wide range of disparate components such as AI, mobile, gaming, web, and desktop. Therefore, we can now use the version to target Windows, Linux, macOS, iOS, Android, tvOS, watchOS, WebAssembly, and more. With this release, Microsoft succeeded in making .NET more comprehensive and seamless to use, while still managing to expand its capabilities. Here are some of the .NET 5 functionalities we have been enjoying for the past year.

.NET FRAMEWORK VS. .NET CORE: WHAT IS THE DIFFERENCE AND THE FUTURE OF .NET

runtime platforms

If we take a look at .NET Core, we’d see that the runtime here is CoreCLR, which is mainly used for IoT, Machine learning, and desktop applications. On the other hand, the cross-platform implementation used in .NET is Mono which targets predominantly iOS and Android devices. CoreCLR and Mono have both unique as well as very similar features to one another. Thus, it only makes sense that we are able to pick a runtime experience of our choice. This improvement is great as it allows you to have the best of both worlds.

compilers and productivity

As we know, Microsoft.NЕТ uses a JIT (Just-in-time compiler) in order to translate IL (Intermediate language) code to actual machine code. If you are a developer using .NET Framework or .NET Core, chances are, you have relied heavily on JIT as it is faster and allows the runtime’s ability to adapt easily to a constrained environment. Thus, it is very convenient that .NET 5 uses JIT-based CoreCLR runtime. The exceptions here are two – client-side Blazor and iOS. The reason for that is both require an AOT (ahead-of-time) native compilation. This .NET 5 improvement makes the ecosystem more flexible to adapt to different environments and improves productivity, speed, and memory usage.

low footprint and fast startup

We know two types of AOT solutions: ones where most of the code is AOT-compiled, but still, a JIT or interpreter is used for code patterns, which are not AOT friendly, and solutions, which require a complete AOT compilation. The new thing in .NET 5 is that now AOT compilation is also possible for applications that are more appliance-like and therefore need a fast startup and low footprint. This combined with the productivity of the compilers, impacts greatly the smoothness of development.

same basics and layout

Something that we found very useful in .NET 5 is that capabilities overlap across the entire version, which makes diagnostics much easier. This also makes it possible to support exactly the same chips and operating systems apart from WebAssembly and iOS. In order to have common command-line tools for all projects, .NET 5 applications all use the CoreFX framework and are buildable with .NET CLI. This helps with optimization when there are multiple workloads, improves diagnostics and support for operating systems.

All these unifying changes throughout the entire version managed to pave the way and make possible the exciting innovations in .NET 6.

microsoft .net 6

.NET 6

 

Microsoft .NET 6 is expected later in November this year. It is the first major release as part of the unified Microsoft platform which will ultimately inherit both .NET Core and .NET Framework.  It is the first LTS version since 2019 and includes various new features and a new version of C# – C# 10, which focuses on simplifying the code, allowing global using as well as file-scoped namespaces. Here are some of the features of .NET 6, that we are most looking forward to:

dateonly and timeonly types

A very convenient improvement is the opportunity to specify types as ‘only’ date or time. Up until now, we had to find a workaround when using the DateTime object – very needed and common for storing any calendar dates such as date of birth, deadlines, anniversary dates, and so on. However, the previous version required the use of Time, often twisting our arm to input midnight as a time portion even when not needed. And if the usage of DateOnly is rather straightforward, the TimeOnly is far more complex and therefore needed as an improvement.

record structs

This new feature may seem familiar to most of us from the C# version 9 and its class-based records. Record structs here have been created in order to provide structs with similar record benefits and functionalities as classes. The change in .NET 6, however, is much bigger. Here we are not simply talking about structifying records, but rather aligning them with ValueTuple just as class records. This design approach makes record structs mutable as properties by default, while record classes – immutable. Still, we also have the option to declare read-only record structs which are also immutable.

priority queue

Another handy feature that we are seeing from Microsoft for the very first time is the official priority queue. This may not seem as revolutionary as other improvements but definitely will become a favorite of the majority of developers. Using this feature, we can dequeue an item and as a result, the one with the highest priority will be removed from the queue regardless of what it is or when it has been added. So, unlike the FIFO – first in, first out and LIFO – last in, first out, with the priority queue the order changes to – the one with the highest priority – out.

global statements

Another favorite one of ours is the opportunity to use global statements. Or in other words, we will be able to declare a statement only once at the beginning of the project instead of having to clutter each file with the exact same statement used over and over again. Sounds simple, yet brilliant, right?

socks proxy support

Security and anonymity while being online have been a top priority for each and every one of us. Whether we use gateways, proxies, or VPNs we are all looking for ways to encrypt and protect ourselves. Therefore, most of us are probably very familiar with the well-known protocol SOCKS proxy. Despite being defined for the very first time in the ’90s, the SOCKS proxy was never supported by .NET until now!

minimal api

The new minimal API framework supported by .NET 6 is a revolutionary change in comparison to the old-school way of building an API using startup files. In .NET 5 we could open a cs. file, add some code and run the file without the need for any nameplaces or classes. However, in .NET 6, all we have to do is open the command prompt and type: “dotnet new web -o MinApi”. Using the minimal API is easy and quick. Everything happens in a single file without any configuration objects. 

implicit using statements

In the new version of Microsoft .NET, project types can import using statements globally instead of doing it manually for every single file. It’s an intriguing feature, which, however, is turned off by default. Once enabled, we will find that implicit usings are an auto-generated file hidden inside the obj folder and which declares global using statements.

maxby and minby

Rather easy to understand, yet a very useful innovation in Microsoft .NET 6. “MaxBy” doesn’t just calculate the “max” property in a complex object, but it actually returns the entire object. For example, if we have a class “Children” and need to find the max-age of those children we need to use “Max”. However, by using “MaxBy” – the output isn’t simply the max-age, but the entire object that contains the max value, for example – the name of the child plus its age. This is one of those useful features that we didn’t know we need before we try it. 

Ienumerable chunks

A big addition to LINQ in this upcoming .NET 6 release is the possibility for chunking. If you tend to work with large collections of objects and prefer to separate them in smaller batches, you will appreciate this new feature. Before this, if we were looking to split large collections, we had to use conditional logic and loops. This method, however, doesn’t include some edge cases and also needs to be carefully tested to ensure all items are included. Luckily, in .NET 6 this whole procedure will be replaced with just one line of C# code, making it more clear, concise, and easy to read.

assignment and declaration in the same deconstruction

Up until now, a deconstruction could initialize new variables or assign all values to existing ones. This is a restriction that we experienced in all previous versions of C# but is going to finally be removed in C# 10.

final words on microsoft .net 6

Given the success of .NET 5, regardless of being rolled out in such a difficult time amid a global pandemic, .NET 6 is not promising anything less. With its compelling improvements, simplified and more straightforward operations for more clear and readable code, .NET 6 will not only allow building more complex and interesting projects but will also make learning C# more accessible and comprehensive. Many new features have already been revealed in the past year. Some of them have been explored briefly in past versions in some way or another, however, the majority are completely new for .NET and are about to lay the foundation for what’s next in the future.

So don’t forget to mark your calendars and tune in to the Microsoft .NET Conf on November 9-11 to witness the official release of the anticipated .NET 6.

Are you looking for a technology partner providing custom .NET development services? Read more about Accedia’s extensive experience in the area

 

Pavel is a software consultant with a proven track record in delivering solutions to the highest quality standards. Expert in developing applications based on the Microsoft .NET stack of technologies with proficiency in ASP.NET and Microsoft SQL Server.

Share

Share on facebook
Share on twitter
Share on linkedin

Related Posts

Subscribe Now

Get exclusive access to company guides and resources and be the first to know about upcoming events! 

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Thank you!

You have been successfully subscribed!