7-inch .NET closer to NativeAOT in Preview 2 – Visual Studio Magazine
.NET 7 inch closer to NativeAOT in Preview 2
Native Ahead of Time (AOT) compilation – a much-requested and long-awaited feature for .NET – is getting closer in the new .NET 7 Preview 2.
NativeAOT (sometimes called “Native AOT” by Microsoft) was deemed so important that a survey a few years ago indicated that its absence was holding back .NET adoption.
In this week’s Preview 2, work continued on the project, which is now in the main development stream after being labeled “experimental”. As part of this, some basic housekeeping had to be done, moving the project from one GitHub repository to another. With that done, it’s time to tweak things for real-world testing.
“This work is now complete, but we have not yet added first-class support in the dotnet SDK for publishing projects with NativeAOT,” said Angelos Petropoulos, product manager for .NET, in an announcement on 14 March of Preview 2. “We hope this work will be done soon, so you can try out NativeAOT with your apps. In the meantime, try minimizing your app and make sure there are no Minification warnings. Minification is a NativeAOT requirement. If you have libraries, there are also instructions for preparing libraries for slicing.”
The NativeAOT issue in .NET 7 #61231 GitHub shows the initial work being verified and what remains in the first phase:
As for the new features available in Preview 2, Microsoft introduced a new Regex source generator, which was actually included in Preview 1 but didn’t make the announcement, so Microsoft is detailing it now. Provided by the C# compiler, source generators help C# developers inspect user code as it is compiled and generate C# source files on the fly that are added to the user’s compilation.
Now, as a GitHub issue explains, developers can precompile their Regex code for faster startup under certain conditions.
“It brings all the performance benefits of our compiled engine without the startup cost, and it has additional benefits, like providing a great debugging experience while being slicing-friendly,” Petropoulos said. “If your pattern is known at compile time, then the new regex source generator is the way to go.”
Other minor features have also been added, including improvements to tab completion when using
dotnet Command line interface (CLI) commands.
You can read all about it and more in the What’s New in .NET 7 Preview 2 documentation.
What’s new for ASP.NET Core in .NET 7 Preview 2
Meanwhile, improvements to the web-dev component of .NET 7, ASP.NET Core, include:
You can learn more about all of these here and in the ASP.NET Core Roadmap for .NET 7.
David Ramel is an editor and writer for Converge360.