Skip to content

.NET Celebrates 20 years and brings us a GIFT🎁: New .NET 7 Features Revealed

4 de April de 2022
dotnet 7 is coming with new features

Who better person to announce the 20th anniversary of .NET than Bill Gates? Well, that’s how it went at the 2002 VSLive!

It’s amazing! But in case you didn’t know, the .NET framework, according to Stack Overflow survey, has been the most loved framework by developers for the past 3 years.

Yes, the .NET Framework celebrated 20 years since its creation in 2002 and just a couple of days ago, Microsoft has released new features of .NET 7, which is expected to be officially released in November this year. Let’s see what these features are and analyze them!

Index

Improved Regex source generator

The new Regex Source Generator means that you can shave off up to 5x the time spent optimizing patterns from our compiled engine without having to sacrifice any of the associated performance benefits.

Additionally, because it operates within a partial class, there is no overhead of compiling-time for instances when users know their pattern at runtime. With this feature, if your pattern can be known at compile-time, then this generator is recommended instead of our traditionally compiler based approach.

All you need to do is set up a partial declaration with an attribute called RegexGenerator which points back to the method that will return an already precompiled regular expression object (with all other features enabled). Our generator will take care of creating that method and updating it as needed according to changes made to either the original string or passed in options (like case sensitivity etc…).

Let’s take a look at the comparison of the Microsoft example:

Before:

After:

SDK improvements

For those who work with .NET Framework, using dotnet newwill be a much easier task. With major updates such as an improved intuitiveness and an increased speed of tab completion, it would be hard to find anything negative about this change.

If you want to go deeper, here is the original example from Microsoft:

New command names

Command lines in general were changing — specifically, every command shown in this output will no longer include the --prefix as it does now. This was done to align with what a user would expect from a subcommand for an app built for command lines.

The old versions of these commands (--install, etc) are still available just in case it breaks scripts but we hope that one day there will be deprecation warnings included to those commands so you can transition over without risk.

Tab key completion

For a long time now, the dotnet command line interface has had support for tab completion on shells such as PowerShell, bash, zsh, and fish. The commands themselves are able to decide what they want to show when given input.

Now in .NET 7, the newcommand allows quite a lot of functionalities:

If you are interested in knowing how to enable it, I recommend you to check the Microsoft’s guide. And likewise, if you want to know all the possibilities of this feature, I recommend you to consult again the original source.

Dynamic PGO improvements

Microsoft has recently introduced a new breakthrough for program optimization. Called the Dynamic PGO, it is designed to make some key changes from the Static PGO we already know about. Where Static PGO requires developers to use special tools separately from training, Dynamic PGO doesn’t require any of that; all you need to do is run the application you are interested in optimizing and then collect data for Microsoft!

Now, according with Andy Ayers in GitHub, the following is added:

“Extend ref counting done by local morph so that we can determine
single-def single-use locals.”

“Add a phase that runs just after local morph that will attempt to
forward single-def single-use local defs to uses when they are in
adjacent statements.”

Fix or work around issues uncovered elsewhere:

  • gtFoldExprCompare might fold “identical” volatile subtrees
  • fgGetStubAddrArg cannot handle complex trees
  • some simd/hw operations can lose struct handles
  • some calls cannot handle struct local args

You can check the original pull for more details.

Conclusion

These features are the last ones that have come to light by Microsoft and we will have to see what more features they show us.

As far as we can all see (and as far as Microsoft lets us see), everything is going according to plan and we can expect the official launch of .NET 7 at the end of this year (more specifically in November).

So for the moment, we will be watching for any announcement or news from Microsoft on .NET 7!

Settings