Misc nativeAOT Windows stability adjustments#31274
Merged
PureWeen merged 3 commits intoinflight/candidatefrom Sep 18, 2025
Merged
Misc nativeAOT Windows stability adjustments#31274PureWeen merged 3 commits intoinflight/candidatefrom
PureWeen merged 3 commits intoinflight/candidatefrom
Conversation
11 tasks
Contributor
There was a problem hiding this comment.
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
jsuarezruiz
suggested changes
Sep 2, 2025
src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs
Outdated
Show resolved
Hide resolved
…namic dependencies
jsuarezruiz
approved these changes
Sep 18, 2025
github-actions bot
pushed a commit
that referenced
this pull request
Sep 18, 2025
* Misc nativeAOT Windows compatibility fixes * Adjust conditional for font retrieval in FontManager.Windows * Revert ShellItemHandler changes and update MauiNavigationView with dynamic dependencies
github-actions bot
pushed a commit
that referenced
this pull request
Sep 23, 2025
* Misc nativeAOT Windows compatibility fixes * Adjust conditional for font retrieval in FontManager.Windows * Revert ShellItemHandler changes and update MauiNavigationView with dynamic dependencies
github-actions bot
pushed a commit
that referenced
this pull request
Sep 23, 2025
* Misc nativeAOT Windows compatibility fixes * Adjust conditional for font retrieval in FontManager.Windows * Revert ShellItemHandler changes and update MauiNavigationView with dynamic dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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