-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Misc nativeAOT Windows stability adjustments #31274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces several stability improvements for Native AOT publishing scenarios on Windows platforms. The changes focus on avoiding runtime crashes and improving build configuration by adding dependency attributes for trimming preservation and implementing workarounds for known AOT issues.
- Adds
DynamicDependencyattributes to preserve required types during Native AOT trimming - Implements conditional compilation to avoid Win2D crashes under Native AOT
- Improves Shell navigation timing to prevent WinUI template application failures
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Core/src/Platform/Windows/MauiNavigationView.cs | Adds DynamicDependency attributes to preserve WinUI control types during AOT trimming |
| src/Core/src/Fonts/FontManager.Windows.cs | Conditionally disables Win2D font lookup under Native AOT to prevent crashes |
| src/Controls/src/Xaml/Controls.Xaml.csproj | Disables PRI generation for Windows to avoid conflicts with Core project |
| src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs | Delays MenuItemsSource assignment until NavigationView is loaded to prevent AOT crashes |
| src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets | Sets default build properties for Windows Native AOT publishing |
Comments suppressed due to low confidence (1)
src/Core/src/Fonts/FontManager.Windows.cs:168
- The conditional compilation symbol
USE_NATIVE_AOTappears to be a custom symbol not defined in the standard .NET build system. Consider using the standardNATIVE_AOTsymbol that is automatically defined by the .NET SDK when PublishAot=true, or ensure this custom symbol is properly defined in the project configuration.
#if USE_NATIVE_AOT
src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs
Outdated
Show resolved
Hide resolved
src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs
Outdated
Show resolved
Hide resolved
…namic dependencies
* Misc nativeAOT Windows compatibility fixes * Adjust conditional for font retrieval in FontManager.Windows * Revert ShellItemHandler changes and update MauiNavigationView with dynamic dependencies
* Misc nativeAOT Windows compatibility fixes * Adjust conditional for font retrieval in FontManager.Windows * Revert ShellItemHandler changes and update MauiNavigationView with dynamic dependencies
* Misc nativeAOT Windows compatibility fixes * Adjust conditional for font retrieval in FontManager.Windows * Revert ShellItemHandler changes and update MauiNavigationView with dynamic dependencies
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
This pull request introduces several targeted improvements to support Native AOT publishing and to address issues specific to WinUI and Windows platform builds. The main focus is on increasing stability for Native AOT scenarios, avoiding runtime crashes, and improving build configuration for Windows projects. Inlcuding added
DynamicDependencyattributes toMauiNavigationView.csto ensure required types and members are preserved during trimming for Native AOT scenarios.Issues Fixed
Improving MAUI WinUI nativeAOT stability.
Part of #31227