Repository navigation
Preserve explicit Java exports during full trimming - #13224
Conversation
Treat explicit Export and ExportField declarations as unconditional trimmable typemap entries on CoreCLR and NativeAOT. Preserve the generated proxy's Java-facing methods and constructors without rooting unrelated peers or managed members. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped rooting change has layered regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Preserves explicit Java exports during full trimming on CoreCLR and NativeAOT without retaining unrelated peers or managed members.
Changes:
- Makes explicitly exporting peers unconditional typemap entries.
- Adds model, build, and device regression coverage.
- Documents export preservation behavior.
| File | Description |
|---|---|
| tests/MSBuildDeviceIntegration/Tests/ExportAttributeBuildTest.cs | Tests Java-to-managed exports after full trimming. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Verifies exported peers survive while unrelated members are trimmed. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ModelBuilder.cs | Roots peers declaring explicit exports. |
| src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTrimmableTypeMapTests.cs | Tests export rooting, aliases, and exclusions. |
| Documentation/release-notes/mono-android-export-removal.md | Explains preservation guarantees and limits. |
Review effort: Balanced
|
/review |
|
❌ Android PR Reviewer failed. Please review the logs for details. Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details.
|
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Explicit Export and ExportField declarations, including exported constructors, now become unconditional typemap entries through their generated proxies. The declared-versus-inherited and alias handling preserves the Java-facing callback/constructor surface without blanket-rooting unrelated managed members; Register-only peers remain conditional. I checked the CoreCLR and NativeAOT consumer contracts and the Java-only/negative trimming controls. Source review only; no runtime execution is certified, and the separate automated-reviewer model-endpoint failure is not treated as validation.
|
/backport to release/11.0.1xx |
|
Started backporting to |
|
@simonrozsival backporting to git am output$ git cherry-pick 2b6f3defea928bc13a1aee3c74acf224d3e5e46f
CONFLICT (modify/delete): Documentation/release-notes/mono-android-export-removal.md deleted in HEAD and modified in 2b6f3defe (Preserve explicit Java exports during full trimming (#13224)). Version 2b6f3defe (Preserve explicit Java exports during full trimming (#13224)) of Documentation/release-notes/mono-android-export-removal.md left in tree.
Auto-merging src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTrimmableTypeMapTests.cs
CONFLICT (content): Merge conflict in src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTrimmableTypeMapTests.cs
Auto-merging src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ModelBuilder.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs
Auto-merging tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs
error: could not apply 2b6f3defe... Preserve explicit Java exports during full trimming (#13224)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Preserve explicit Java exports during full trimming
Using index info to reconstruct a base tree...
A Documentation/release-notes/mono-android-export-removal.md
M src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTrimmableTypeMapTests.cs
M src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ModelBuilder.cs
M src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs
A tests/MSBuildDeviceIntegration/Tests/ExportAttributeBuildTest.cs
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): Documentation/release-notes/mono-android-export-removal.md deleted in HEAD and modified in Preserve explicit Java exports during full trimming. Version Preserve explicit Java exports during full trimming of Documentation/release-notes/mono-android-export-removal.md left in tree.
Auto-merging src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTrimmableTypeMapTests.cs
CONFLICT (content): Merge conflict in src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTrimmableTypeMapTests.cs
Auto-merging src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ModelBuilder.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs
Auto-merging tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Preserve explicit Java exports during full trimming
Error: The process '/usr/bin/git' failed with exit code 128 |
Summary
[Export],[ExportField], and exported constructor declarations as Java entry points for trimmable typemap rooting on CoreCLR and NativeAOT.[Register]alone and inherited exports do not root a peer.Validation
make prepare CONFIGURATION=Release— passed.make all CONFIGURATION=Release— passed after generating missing API 37.1 and 37.2 reference outputs with./dotnet-local.sh build src/Mono.Android/Mono.Android.csproj -c Release -p:AndroidApiLevel=37.1 -p:AndroidPlatformId=37.1 -p:AndroidFrameworkVersion=v17.1 -v minimaland the corresponding 37.2/v17.2 command.git diff --check— passed.