-
Notifications
You must be signed in to change notification settings - Fork 64
[generator] Extend skipInvokerMethods support to interfaces.
#1202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
03f8edf to
3b5f684
Compare
| <class abstract='false' deprecated='not deprecated' final='false' name='Object' static='false' visibility='public' jni-signature='Ljava/lang/Object;' /> | ||
| </package> | ||
| <package name='com.xamarin.android' jni-name='com/xamarin/android'> | ||
| <interface abstract='false' deprecated='not deprecated' extends='java.lang.Object' extends-generic-aware='java.lang.Object' jni-extends='Ljava/lang/Object;' final='false' name='MyInterface' static='false' visibility='public' jni-signature='Lcom/xamarin/android/MyInterface;' skipInvokerMethods='com/xamarin/android/MyInterface.countAffectedRows()I'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally (always?) //interface/@abstract will be true, not false. (At least, I can find no instances of such a thing in api-34.xml.)
| !options.SupportNestedInterfaceTypes | ||
| }; | ||
|
|
||
| if (elem.Attribute ("skipInvokerMethods")?.Value is string skip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be split out into a helper method, and CreateClass() updated to use the helper method, as I can't imagine any reason why the semantics for skipInvokerMethods should differ between classes and interfaces.
| void AddMethodInvokers (InterfaceGen iface, IEnumerable<Method> methods, HashSet<string> members, HashSet<string> skipInvokers, CodeGenerationOptions opt, CodeGeneratorContext context) | ||
| { | ||
| foreach (var m in methods) { | ||
| if (skipInvokers.Contains ($"{m.DeclaringType.RawJniName}.{m.JavaName}{m.JniSignature}")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Ditto" here: I'd be happier if ClassInvokerClass and InterfaceInvokerClass used the same method to generate the $"m.DeclaringType.RawJniName}.{m.JavaName}{m.JniSignature}" string.
|
|
||
| if (elem.Attribute ("skipInvokerMethods")?.Value is string skip) | ||
| foreach (var m in skip.Split (new char [] { ',', ' ', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) | ||
| iface.SkippedInvokerMethods.Add (m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurs to me: should we "sanity check" this value, asserting that it contains one ., one (, and one )? (And maybe even verify that (…)… constitutes a valid JNI method signature, according to e.g. JniMemberSignature.GetParameterCountFromMethodSignature() + a return type sanity check.)
This request might be a step "too far" for this PR -- as opposed to my other comments, which I think are closer to "code hygiene" and code deduplication -- but this thought hadn't occurred to me before.
3b5f684 to
595625f
Compare
Context: 73ebad2 Context: dotnet/android-libraries#779 Commit 73ebad2 added support for the metadata attribute `//class[@skipInvokerMethods]`, which allowed us to suppress generation of invoker methods for a class. The AndroidX Media3 binding in dotnet/android-libraries#779 hits a similar issue wherein we generate incorrect generics on an invoker type. However, this is an invoker type for an *`interface`*, not a `class`. Extend our `skipInvokerMethods` support so that it can be used as `//interface[@skipInvokerMethods]` as well.
Context: dotnet/java-interop#1203 Does It Build™? Changes: dotnet/java-interop@bec0326...e557044 * dotnet/java-interop@e557044f: [generator] Extend `skipInvokerMethods` support to interfaces. (dotnet/java-interop#1202)
Changes: dotnet/java-interop@14a9470...a7e09b7 * dotnet/java-interop@a7e09b7b: [generator] Extend `skipInvokerMethods` support to interfaces. (dotnet/java-interop#1202) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
#1203) Context: 73ebad2 Context: dotnet/android-libraries#779 Commit 73ebad2 added support for the metadata attribute `//class[@skipInvokerMethods]`, which allowed us to suppress generation of invoker methods for a class. The AndroidX Media3 binding in dotnet/android-libraries#779 hits a similar issue wherein we generate incorrect generics on an invoker type. However, this is an invoker type for an *`interface`*, not a `class`. Extend our `skipInvokerMethods` support so that it can be used as `//interface[@skipInvokerMethods]` as well. Co-authored-by: Jonathan Pobst <[email protected]>
Context: #1086
#1086 added the metadata attribute
skipInvokerMethodsto allow us to suppress generation of invoker methods for a class.The AndroidX Media3 binding hits an issue where we generate incorrect generics in an invoker type. However this is an invoker type for an
interfaceinstead of aclass.Extend our
skipInvokerMethodssupport to cover interfaces as well.