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 at Converge 360.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events