Skip to content
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

[Mono.Android] Remove problematic default interface method Cursor.getNotificationUris. #5161

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Sep 28, 2020

Context: dotnet/java-interop#699

In #5124 we removed Cursor.setNotificationUris (...) because it causes binding problems when it is overridden. Cursor.getNotificationUris () was not removed because it was believed that the issue was confined to parameters, however it affects return values as well.

Remove default interface method Cursor.getNotificationUris () until generator can be properly fixed.

@jpobst jpobst marked this pull request as ready for review September 28, 2020 19:14
@jonpryor jonpryor merged commit 8c86eda into master Sep 28, 2020
@jonpryor jonpryor deleted the get-uris branch September 28, 2020 19:45
jonpryor pushed a commit that referenced this pull request Oct 12, 2020
Fixes: #5027
Context: dotnet/java-interop#699
Context: dotnet/java-interop#699 (comment)
Context: eadd3bd

The [`Cursor.getNotificationUris()`][0] interface default method was
added in API-29.

Much as with `Cursor.setNotificationUris()` and commit eadd3bd, this
introduces an issue when implementing `Android.Database.ICursor`
in API-30+: when binding a Java class that implements `Cursor`:

	// Java
	public class MyCursor implements android.database.Cursor {
	    // …
	}

In the binding `generator` emits for `MyCursor`, the Java-to-managed
marshal method to support `Cursor.getNotificationUris()` does not
compile, as it tries to use a generic type -- `IList<T>` -- without
providing any generic type parameters:

	// C# binding
	public partial class MyCursor : Java.Lang.Object, ICursor {
	    static IntPtr n_GetNotificationUris (IntPtr jnienv, IntPtr native__this)
	    {
	        var __this  = Java.Lang.Object.GetObject<MyCursor> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
	        return global::Android.Runtime.JavaList.ToLocalJniHandle (__this.NotificationUris);;
	        // ^^ error CS1503: Argument 1: cannot convert from 'System.Collections.Generic.IList<Android.Net.Uri>' to 'System.Collections.IList?'
	    }
	}

We had thought that dotnet/java-interop@262743b47 addressed this
issue, but we were mistaken.

The `generator` fix for this scenario seems tricky, so as a workaround
for now we can simply remove the `Cursor.getNotificationUris()` default
method so users can implement the interface.

(Although the method was added in API-29, we don't support
Default Interface Members in API-29, so it was ignored.  Thus, this
problem doesn't show up until API-30+ is used.)

[0]: https://developer.android.com/reference/android/database/Cursor#getNotificationUris()
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants