Remove IsTrimmable=false from assemblies that are already AotCompatible#34573
Remove IsTrimmable=false from assemblies that are already AotCompatible#34573kotlarmilos wants to merge 8 commits intodotnet:net11.0from
Conversation
These assemblies already set IsAotCompatible=true (which implies IsTrimmable=true via the SDK), but the explicit IsTrimmable=false overrides that and prevents them from being trimmed in SdkOnly mode. The IsTrimmable=false was added in PR dotnet#10647 (Oct 2022) to lock down the value, but it was never updated when these assemblies were made AOT-compatible in PRs dotnet#21076 and dotnet#21505 (2024). Removing IsTrimmable=false lets IsAotCompatible=true take effect, allowing these assemblies to be trimmed in SdkOnly link mode. This reduces bundle size for both Debug and Release builds. Affected assemblies: - Microsoft.Maui (Core.csproj) - Microsoft.Maui.Controls (Controls.Core.csproj) - Microsoft.Maui.Graphics (Graphics.csproj) - Microsoft.Maui.Controls.Xaml (Controls.Xaml.csproj) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34573Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34573" |
There was a problem hiding this comment.
Pull request overview
This PR aligns trimming behavior with existing AOT-compatibility declarations by removing explicit IsTrimmable=false overrides from key MAUI assemblies, so IsAotCompatible=true can cause them to be treated as trimmable (notably impacting SdkOnly link mode scenarios).
Changes:
- Removed
<IsTrimmable>false</IsTrimmable>fromMicrosoft.Maui(Core). - Removed
<IsTrimmable>false</IsTrimmable>fromMicrosoft.Maui.ControlsandMicrosoft.Maui.Controls.Xaml. - Removed
<IsTrimmable>false</IsTrimmable>fromMicrosoft.Maui.Graphics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Core/src/Core.csproj | Removes the explicit IsTrimmable=false override so the existing non-netstandard IsAotCompatible=true can drive trimming. |
| src/Controls/src/Core/Controls.Core.csproj | Same: drops the override to allow trimming in configurations where IsAotCompatible=true is already set. |
| src/Controls/src/Xaml/Controls.Xaml.csproj | Same: removes IsTrimmable=false to let IsAotCompatible=true imply trimming for applicable TFMs. |
| src/Graphics/src/Graphics/Graphics.csproj | Same: removes IsTrimmable=false so trimming can apply when IsAotCompatible=true is set. |
You can also share your feedback on Copilot code review. Take the survey.
|
/azp run maui-pr-devicetests,maui-pr-uitests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
CI failures (ui tests timeouts, mobile device test crashes) are pre-existing net11.0 baseline issues unrelated to this PR |
Shell MenuItem Trimming Regression AnalysisInvestigation of the 34 Root CauseRemoving Evidence from ADO Test Attachments (Build 1344675)Logcat analysis of Order 1 test (
Page source XML at failure shows what is rendered vs what is not:
No managed exceptions in logcat — no Failure Pattern
Suspected Trimmed Code PathsThe linker likely trims code in the MenuItem→flyout rendering pipeline:
Shell navigation items ( RecommendationThe PR may need |
MenuShellItem is an internal type that wraps MenuItem for flyout rendering. When MAUI assemblies become trimmable (IsTrimmable=true), the ILLink trimmer can strip MenuShellItem and related code paths that are only reached through event-driven and interface-dispatch patterns the linker cannot statically trace. Add [DynamicDependency] on Shell constructor and ShellItem implicit operator to preserve MenuShellItem and its members through trimming. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-devicetests,maui-pr-uitests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Add [UnconditionalSuppressMessage] for IL2026, IL2111, and IL3050 on Shell() constructor and ShellItem.op_Implicit(MenuItem). The warnings originate from the TypeConverter base class hierarchy (ShellItemConverter : TypeConverter) whose inherited members like GetProperties/GetEditor carry RequiresUnreferencedCode. These base methods are never called by MAUI - ShellItemConverter only overrides CanConvertFrom/To and ConvertFrom/To. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-devicetests,maui-pr-uitests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/rebase |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…/remove-istrimmable-false
|
/azp run maui-pr-devicetests,maui-pr-uitests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Trimming Regression:
|
| Build | Android Mono | iOS Mono |
|---|---|---|
| net11.0 build 1363873 | ✅ | ✅ |
| net11.0 build 1360789 | ✅ | ✅ |
| net11.0 build 1360076 | ✅ | ✅ |
| net11.0 build 1358994 | ✅ | ✅ |
| net11.0 build 1357881 | ✅ | ✅ |
| PR #34573 build 1362029 | ❌ crash | ❌ crash |
Likely needs [DynamicDependency] annotations on DragGestureRecognizer (and possibly other gesture recognizer types that are activated via reflection).
|
/azp run maui-pr-devicetests,maui-pr-uitests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
…trimming - Cell.cs: Preserve Cell subtype constructors (TextCell, EntryCell, ImageCell, SwitchCell, ViewCell) - ViewExtensions.cs: Preserve XAML markup extension constructors for runtime XAML parsing - MemoryTests.cs: Add DynamicallyAccessedMembers on Type params for GestureDoesNotLeak, CellsDoNotLeak, CollectionViewHeaderFooterDoesntLeak - ControlsViewTypesTestCases.cs: Add DynamicDependency for all view types used via ClassData - AccessibilityTests.cs: Add DynamicDependency for all control types in AllControlsTestCase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-devicetests,maui-pr-uitests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Description
These four assemblies already set
IsAotCompatible=true(which impliesIsTrimmable=truevia the SDK'sMicrosoft.NET.Publish.targets), but the explicitIsTrimmable=falseoverrides that and prevents them from being trimmed inSdkOnlylink mode.The
IsTrimmable=falsewas added in PR #10647 to lock down the value, but it was never updated when these assemblies were made AOT-compatible in PRs #21076 and #21505.Removing
IsTrimmable=falseletsIsAotCompatible=truetake effect, allowing these assemblies to be trimmed inSdkOnlylink mode.Affected assemblies:
Microsoft.Maui(Core.csproj)Microsoft.Maui.Controls(Controls.Core.csproj)Microsoft.Maui.Graphics(Graphics.csproj)Microsoft.Maui.Controls.Xaml(Controls.Xaml.csproj)Context
While working on reducing Debug bundle size for CoreCLR R2R builds in dotnet/macios (dotnet/macios#24909), we found these assemblies are the main ones not being trimmed in
SdkOnlymode.