Skip to content

[TrimmableTypeMap] Remove ForceUnconditionalEntries workaround#11345

Draft
simonrozsival wants to merge 3 commits into
mainfrom
dev/simonrozsival/remove-forceunconditionalentries
Draft

[TrimmableTypeMap] Remove ForceUnconditionalEntries workaround#11345
simonrozsival wants to merge 3 commits into
mainfrom
dev/simonrozsival/remove-forceunconditionalentries

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented May 14, 2026

Summary

Remove the ForceUnconditionalEntries workaround from the trimmable typemap ModelBuilder. This was a temporary workaround for dotnet/runtime#127004 that forced all TypeMap entries to be emitted as 2-arg (unconditional), preventing unused framework bindings from being trimmed.

Changes

  • Remove the ForceUnconditionalEntries constant and all conditional logic gated on it
  • Restore 3-arg conditional TypeMapAttribute entries for non-essential MCW bindings
  • Keep essential runtime types and user ACWs as 2-arg unconditional entries
  • Update model and PE blob tests for the restored conditional behavior
  • Replace [DynamicDependency] attributes on FindX509TrustManager with a HackToPreserveInvokers method using [MethodImpl(NoInlining)] to prevent the linker from trimming IX509TrustManagerInvoker and X509ExtendedTrustManagerInvoker
  • Remove obsolete API 21-23 Conscrypt TrustManagerImpl workaround (min API is now higher)
  • Rename generated enum from AppFunctionState to AppFunctionEnabledState to fix name collision with the new Android API 37 android.app.appfunctions.AppFunctionState class

Validation

  • All 931 Release/CoreCLR/Trimmable Mono.Android.NET-Tests passed on device (0 failures, 18 expected ignores)
  • All SSL ServerCertificateCustomValidationCallback_* tests pass
  • Standalone typemap unit tests pass
  • Integration tests pass

Restore conditional TypeMap entries for non-essential MCW bindings now that the runtime trimmer issue has been fixed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 08:56
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels May 14, 2026
@simonrozsival simonrozsival changed the title Remove ForceUnconditionalEntries workaround [TrimmableTypeMap] Remove ForceUnconditionalEntries workaround May 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 removes the ForceUnconditionalEntries workaround from trimmable typemap model generation, restoring conditional 3-arg TypeMapAttribute emission for non-essential MCW bindings while keeping essential runtime/user ACW entries unconditional.

Changes:

  • Removes the global force-unconditional switch from ModelBuilder.
  • Restores conditional target references for non-essential MCW entries.
  • Updates model and PE blob tests to expect restored 3-arg behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ModelBuilder.cs Removes workaround logic and reverts unconditional decisions to IsUnconditionalEntry() plus alias-specific rules.
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TypeMapModelBuilderTests.cs Updates assertions and test names/comments for restored conditional MCW typemap entries.

Comment on lines +185 to 186
bool aliasBaseUnconditional = EssentialRuntimeTypes.Contains (jniName)
|| peersForName.Any (IsUnconditionalEntry);
simonrozsival and others added 2 commits May 15, 2026 15:30
…e name collision

- Replace [DynamicDependency] attributes on FindX509TrustManager with a
  HackToPreserveInvokers method using [MethodImpl(NoInlining)] to prevent
  the linker from trimming IX509TrustManagerInvoker and
  X509ExtendedTrustManagerInvoker.
- Remove obsolete API 21-23 Conscrypt TrustManagerImpl workaround.
- Rename generated enum from AppFunctionState to AppFunctionEnabledState
  to avoid name collision with the new Android API 37
  android.app.appfunctions.AppFunctionState class.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival marked this pull request as draft May 16, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot `copilot-cli` or other AIs were used to author this trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants