[typemap] Trim unused listener implementors from existing bindings - #12404
Draft
simonrozsival wants to merge 2 commits into
Draft
[typemap] Trim unused listener implementors from existing bindings#12404simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
Mark generated listener implementors as managed-created and model their Java peers conditionally so unused implementors can be removed by trimming. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 568c6ce4-aef4-44cd-bd52-d5950a5da923
Replace the explicit managed-created metadata contract with backward-compatible detection of the existing binding-generator implementor shape. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 568c6ce4-aef4-44cd-bd52-d5950a5da923
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Binding-generated listener implementors in non-framework assemblies are currently emitted as unconditional TypeMap entries. This keeps the managed implementor, JCW, ACW map entry, ProGuard rule, and DEX class even when the corresponding C# event is never used.
This change recognizes the binding generator's existing implementor shape:
mono/bool __IsEmpty(TImplementor)helper used by generated event removalMatching implementors now use conditional TypeMap entries and follow managed reachability. Explicit manifest/component roots still take precedence, and ordinary user ACWs remain conservative and unconditional.
Compatibility
This works with existing compiled binding assemblies. It adds no attributes, public API, or generator metadata and does not require bindings to be regenerated. Detection uses the generated metadata shape rather than only an
Implementortype-name suffix.Follow-up to #10911. This also adapts the reachability idea discussed around #12272 to the trimmable typemap.
Validation
Microsoft.Android.Sdk.TrimmableTypeMap.Tests: 802 passedmain, containing no new metadata: