News
.NET 7 Inches 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 conducted a couple years ago indicated its absence was holding back .NET adoption.
In this week's Preview 2, work continued on the project, which is now in the mainline development stream after previously being labeled "experimental." As part of that, some foundational housekeeping had to be done, moving the project from one GitHub repo to another. With that done, polishing up the bits for real-world testing is in order.
"That work has now been completed, but we have yet to add first-class support in the dotnet SDK for publishing projects with NativeAOT," said Angelos Petropoulos, product manager for .NET, in a March 14 announcement of Preview 2. "We hope to have that work done shortly, so you can try out NativeAOT with your apps. In the meantime, please try trimming your app and ensure there are no trim warnings. Trimming is a requirement of NativeAOT. If you own any libraries there are also instructions for preparing libraries for trimming."
The NativeAOT in .NET 7 #61231 GitHub issue shows the initial work being checked off and what's remaining in the first phase:
As far as new features that are available in Preview 2, Microsoft introduced a new Regex Source Generator, which was actually included in Preview 1 but which didn't make the announcement post so Microsoft is detailing it now. Provided by the C# compiler, Source Generators help C# developers inspect user code as it is being compiled and generate on-the-fly C# source files 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 of the performance benefits from our compiled engine without the startup cost, and it has additional benefits, like providing a great debugging experience as well as being trimming-friendly," Petropoulos said. "If your pattern is known at compile-time, then the new regex source generator is the way to go."
Other bits of minor functionality were also added, including improvements to tab completion when using the dotnet
command-line interface (CLI) commands.
You can read all about that and much 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 made to the web-dev component of .NET 7, ASP.NET Core, include:
You can read more about all of those here and in the ASP.NET Core Roadmap for .NET 7.
About the Author
David Ramel is an editor and writer at Converge 360.