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.

Does the lack of officially supported native AOT option prevent you from using .NET more?
[Click on image for larger view.] "Does the lack of officially supported native AOT option prevent you from using .NET more?" (source: Microsoft).

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:

NativeAOT in .NET 7 Goals
[Click on image for larger view.] NativeAOT in .NET 7 Goals (source: Microsoft).

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 for Converge360.

comments powered by Disqus

Featured

  • What's Next for ASP.NET Core and Blazor

    Since its inception as an intriguing experiment in leveraging WebAssembly to enable dynamic web development with C#, Blazor has evolved into a mature, fully featured framework. Integral to the ASP.NET Core ecosystem, Blazor offers developers a unique combination of server-side rendering and rich client-side interactivity.

  • Nearest Centroid Classification for Numeric Data Using C#

    Here's a complete end-to-end demo of what Dr. James McCaffrey of Microsoft Research says is arguably the simplest possible classification technique.

  • .NET MAUI in VS Code Goes GA

    Visual Studio Code's .NET MAUI workload, which evolves the former Xamarin.Forms mobile-centric framework by adding support for creating desktop applications, has reached general availability.

  • Visual Studio Devs Quick to Sound Off on Automatic Updates: 'Please No'

    A five-year-old Visual Studio feature request for automatic IDE updates is finally getting enacted by Microsoft amid a lot of initial developer pushback, seemingly misplaced.

  • First Official OpenAI Library for .NET Goes Beta

    Although it seems Microsoft and OpenAI have been deeply intertwined partners for a long time, they are only now getting around to releasing an official OpenAI library for .NET developers, joining existing community libraries.

Subscribe on YouTube