You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: #1263
Context: #1263 (comment)
We want the default trimmer infrastructure to be able to automatically
preserve the `*Invoker` types which are required for interacting with
`abstract` classes and interfaces.
The most straightforward way to do this is to add a new `InvokerType`
property to `JniTypeSignatureAttribute` (and eventually
`RegisterAttribute`):
partial class JniTypeSignatureAttribute {
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors |
DynamicallyAccessedMemberTypes.NonPublicConstructors)]
public Type? InvokerType {get; set;}
}
Update `generator` so that `generator --codegen-target=JavaInterop1`
output sets this new property on abstract classes and interfaces:
namespace Java.Lang {
[Java.Interop.JniTypeSignatureAttribute("java/lang/Runnable", GenerateJavaPeer=false, InvokerType=typeof(Java.Lang.IRunnableInvoker))]
public partial interface IRunnable {
}
internal partial class IRunnableInvoker {
}
[Java.Interop.JniTypeSignatureAttribute("java/lang/Number", GenerateJavaPeer=false, InvokerType=typeof(Java.Lang.NumberInvoker))]
public abstract partial class Number {
}
internal partial class NumberInvoker {
}
}
This allows the default trimmer to automatically preserve the
`*Invoker` type and constructors.
Update `Java.Interop.JniRuntime.JniValueManager` to no longer look
for `*Invoker` types "by string", and instead require use of the
`JniTypeSignatureAttribute.InvokerType` property.
Update unit tests and expected output so that everything works.
Copy file name to clipboardexpand all lines: tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteDuplicateInterfaceEventArgs.txt
public partial interface AnimatorListener : IJavaPeerable {
4
4
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='AnimatorListener']/method[@name='OnAnimationEnd' and count(parameter)=1 and parameter[1][@type='int']]"
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/interface[@name='NotificationCompatBase.Action.Factory']/method[@name='build' and count(parameter)=1 and parameter[1][@type='int']]"
// Metadata.xml XPath method reference: path="/api/package[@name='java.util']/interface[@name='Collection']/method[@name='add' and count(parameter)=1 and parameter[1][@type='E']]"
// Metadata.xml XPath method reference: path="/api/package[@name='java.util']/interface[@name='Deque']/method[@name='add' and count(parameter)=1 and parameter[1][@type='E']]"
// Metadata.xml XPath method reference: path="/api/package[@name='java.util']/interface[@name='Queue']/method[@name='add' and count(parameter)=1 and parameter[1][@type='E']]"
0 commit comments