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

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube