Skip to content

Emit [DynamicDependency] to preserve Invokers #1263

Open
@jonpryor

Description

@jonpryor

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 {
    // …
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementProposed change to current functionalitygeneratorIssues binding a Java library (generator, class-parse, etc.)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions