In the current .NET for Android world order, the .NET for Android workload adds custom linker steps to preserve the *Invoker types when a bound Java type is preserved.
In a possible future NativeAOT world order, there are no custom linker steps. We thus must use the linker-supported custom attributes to cause types to be preserved.
Given:
partial interface IMyInterface : IJavaPeerable {
// …
}
partial class IMyInterfaceInvoker : Java.Lang.Object, IMyInterface {
// …
}
We should place [DynamicDependency] on the interface (and/or abstract class) declaration so that the linker knows to preserve the Invoker:
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(IMyInterfaceInvoker))]
partial interface IMyInterface : IJavaPeerable {
// …
}
partial class IMyInterfaceInvoker : Java.Lang.Object, IMyInterface {
// …
}
In the current .NET for Android world order, the .NET for Android workload adds custom linker steps to preserve the
*Invokertypes when a bound Java type is preserved.In a possible future NativeAOT world order, there are no custom linker steps. We thus must use the linker-supported custom attributes to cause types to be preserved.
Given:
We should place
[DynamicDependency]on the interface (and/orabstractclass) declaration so that the linker knows to preserve theInvoker: