Commit 0ef5aab
[TrimmableTypeMap] Direct-dispatch interface-implementation proxy methods
Marshal methods collected from an implemented Java interface (e.g. a listener
Implementor) declare their n_* callback as a *private static* method on the
interface type, which lives in the separately ILC-trimmed binding assembly.
Nothing in the trimmable path references that callback within its own assembly,
so ILC trims it away and the generated proxy forwarder 'will always throw' (or,
for generic JavaPeerProxy<TInterface> closed over a bare interface, fails to
load with a TypeLoadException).
Dispatch these methods directly to the managed method instead -- this mirrors
exactly what the static n_* callback does internally (GetObject<TInterface> +
callvirt the interface method) but keeps the generated proxy self-contained and
independent of whether the binding's private n_* survives trimming.
Reproduced with Xamarin.AndroidX.Fragment (IOnBackStackChangedListener et al.):
the ILC 'will always throw' warnings are gone and built-in Mono.Android
listeners (Button.Click/LongClick) still build clean. Fixes the MergeLibraryManifest
and RemovePermissionTest NativeAOT failures.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5e9346d commit 0ef5aab
2 files changed
Lines changed: 27 additions & 2 deletions
File tree
- src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner
- tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Scanner
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
1120 | | - | |
| 1120 | + | |
1121 | 1121 | | |
1122 | 1122 | | |
1123 | 1123 | | |
| |||
1160 | 1160 | | |
1161 | 1161 | | |
1162 | 1162 | | |
1163 | | - | |
| 1163 | + | |
1164 | 1164 | | |
1165 | 1165 | | |
1166 | 1166 | | |
| |||
1170 | 1170 | | |
1171 | 1171 | | |
1172 | 1172 | | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1173 | 1184 | | |
1174 | 1185 | | |
1175 | 1186 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
24 | 38 | | |
25 | 39 | | |
26 | 40 | | |
| |||
0 commit comments