Skip to content

Conversation

@moljac
Copy link
Contributor

@moljac moljac commented Jan 4, 2021

Support Libraries Version (eg: 23.3.0):

Does this change any of the generated binding API's?

Describe your contribution

@moljac moljac self-assigned this Jan 4, 2021
@moljac moljac added do-not-merge PR is still in progress and is not ready to be merged in-progress in progress labels Jan 4, 2021
@moljac
Copy link
Contributor Author

moljac commented Jan 4, 2021

1st run

Browser Mondroid11.0

       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/AndroidX.sln" (Build target) (1:2) ->
       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj" (default target) (43:18) ->
       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj" (Build target) (43:24) ->
       (CoreCompile target) -> 
         /Users/Shared/Projects/d/X/AX/multitargeting/source/androidx.browser/browser/Additions/CustomTabsServiceConnectionImpl.cs(14,11): error CS0534: 'CustomTabsServiceConnectionImpl' does not implement inherited abstract member 'CustomTabsServiceConnection.OnNullBinding(ComponentName)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj]
         /Users/Shared/Projects/d/X/AX/multitargeting/source/androidx.browser/browser/Additions/CustomTabsServiceConnectionImpl.cs(14,11): error CS0534: 'CustomTabsServiceConnectionImpl' does not implement inherited abstract member 'CustomTabsServiceConnection.OnBindingDied(ComponentName)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.Browser.CustomTabs.CustomTabsServiceConnection.cs(157,25): error CS0534: 'CustomTabsServiceConnectionInvoker' does not implement inherited abstract member 'CustomTabsServiceConnection.OnNullBinding(ComponentName)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.Browser.CustomTabs.CustomTabsServiceConnection.cs(157,25): error CS0534: 'CustomTabsServiceConnectionInvoker' does not implement inherited abstract member 'CustomTabsServiceConnection.OnBindingDied(ComponentName)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.Browser.CustomTabs.PostMessageServiceConnection.cs(447,25): error CS0534: 'PostMessageServiceConnectionInvoker' does not implement inherited abstract member 'PostMessageServiceConnection.OnNullBinding(ComponentName)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.Browser.CustomTabs.PostMessageServiceConnection.cs(447,25): error CS0534: 'PostMessageServiceConnectionInvoker' does not implement inherited abstract member 'PostMessageServiceConnection.OnBindingDied(ComponentName)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.browser.browser/androidx.browser.browser.csproj]

car MonoAndroid11.0

       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/AndroidX.sln" (Build target) (1:2) ->
       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.car.car/androidx.car.car.csproj" (default target) (7:19) ->
       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.car.car/androidx.car.car.csproj" (Build target) (7:25) ->
       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/com.google.android.material.material/com.google.android.material.material.csproj" (default target) (105:25) ->
       "/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj" (default target) (84:38) ->
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparingDouble(IToDoubleFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparingInt(IToIntFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IComparator)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IFunction, IComparator)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.Reversed()' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedListAdapterCallback.cs(183,25): error CS0534: 'SortedListAdapterCallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparingLong(IToLongFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.ThenComparingDouble(IToDoubleFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.ThenComparingInt(IToIntFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IComparator)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IFunction, IComparator)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.Reversed()' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(19,24): error CS0534: 'SortedList.BatchedCallback' does not implement inherited abstract member 'SortedList.Callback.ThenComparingLong(IToLongFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparingDouble(IToDoubleFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparingInt(IToIntFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IComparator)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparing(IFunction, IComparator)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.Reversed()' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]
         obj/Release/monoandroid11.0/generated/src/AndroidX.RecyclerView.Widget.SortedList.cs(757,26): error CS0534: 'SortedList.CallbackInvoker' does not implement inherited abstract member 'SortedList.Callback.ThenComparingLong(IToLongFunction)' [/Users/Shared/Projects/d/X/AX/multitargeting/generated/androidx.recyclerview.recyclerview/androidx.recyclerview.recyclerview.csproj]

jonpryor pushed a commit to dotnet/java-interop that referenced this pull request Jan 5, 2021
Context: dotnet/android-libraries#235

Consider the following Java API:

	// Java
	public interface MyInterface {
	    default void doSomething() {}
	}

	public class MyAbstractClass implements MyInterface {
	}

which is then bound in C# as:

	// C#
	[Register (…)]
	public interface IMyInterface {
	    [Register(…)]
	    public void DoSomething() => …; // default interface method
	}

	[Register (…)]
	public abstract class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    // Doesn't override IMyInterface.DoSomething()
	}

`generator` needs to ensure that `Method.IsInterfaceDefaultMethod()`
gets set for `IMyInterface.DoSomething()` so that the
`BoundClass.AddInterfaceAbstractMembers()` logic knows it does not
need to create an `abstract` method `MyAbstractClass.DoSomething()`.

This works correctly if the interface is in the assembly we are
binding, because it uses `XmlApiImporter`.  That is, `generator`
output is valid if `MyInterface` and `MyAbstractClass` are in the
same `.jar`.

However, if the interface is in a reference assembly -- `MyInterface`
and `MyAbstractClass` are in different assemblies -- then `generator`
uses `CecilApiImporter`, and our Cecil importer only marks Java
Interface Default Methods if the method has a
`[JavaInterfaceDefaultMethodAttribute]` custom attribute, which we
don't appear to ever emit.

Consequently, when `MyInterface` and `MyAbstractClass` are in
separate libraries, then `MyAbstractClass` is bound as:

	// C#
	[Register (…)]
	public abstract class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    public abstract void DoSomething();
	}

which causes most bindings that inherit `MyAbstractClass` to fail,
as they typically don't override the interface default method:

	// C#
	[Register (…)]
	public class MyClass : MyAbstractClass {
	}
	// error CS0534: 'MyClass' does not implemented inherited abstract member 'MyAbstractClass.DoSomething()'


Update `generator` and `CecilApiImporter` to properly detect C#8
default interface methods without requiring the presence of the
(unused!) `[JavaInterfaceDefaultMethodAttribute]` custom attribute,
so that classes don't re-declare C#8 interface default methods as
"new" abstract methods.  This fixes the generated `MyAbstractClass`
declaration to be:

	// C*
	[Register (…)]
	public class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    // No `DoSomething()` declaration
	}
jonpryor pushed a commit to dotnet/java-interop that referenced this pull request Jan 5, 2021
Context: dotnet/android-libraries#235

Consider the following Java API:

	// Java
	public interface MyInterface {
	    default void doSomething() {}
	}

	public class MyAbstractClass implements MyInterface {
	}

which is then bound in C# as:

	// C#
	[Register (…)]
	public interface IMyInterface {
	    [Register(…)]
	    public void DoSomething() => …; // default interface method
	}

	[Register (…)]
	public abstract class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    // Doesn't override IMyInterface.DoSomething()
	}

`generator` needs to ensure that `Method.IsInterfaceDefaultMethod()`
gets set for `IMyInterface.DoSomething()` so that the
`BoundClass.AddInterfaceAbstractMembers()` logic knows it does not
need to create an `abstract` method `MyAbstractClass.DoSomething()`.

This works correctly if the interface is in the assembly we are
binding, because it uses `XmlApiImporter`.  That is, `generator`
output is valid if `MyInterface` and `MyAbstractClass` are in the
same `.jar`.

However, if the interface is in a reference assembly -- `MyInterface`
and `MyAbstractClass` are in different assemblies -- then `generator`
uses `CecilApiImporter`, and our Cecil importer only marks Java
Interface Default Methods if the method has a
`[JavaInterfaceDefaultMethodAttribute]` custom attribute, which we
don't appear to ever emit.

Consequently, when `MyInterface` and `MyAbstractClass` are in
separate libraries, then `MyAbstractClass` is bound as:

	// C#
	[Register (…)]
	public abstract class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    public abstract void DoSomething();
	}

which causes most bindings that inherit `MyAbstractClass` to fail,
as they typically don't override the interface default method:

	// C#
	[Register (…)]
	public class MyClass : MyAbstractClass {
	}
	// error CS0534: 'MyClass' does not implemented inherited abstract member 'MyAbstractClass.DoSomething()'


Update `generator` and `CecilApiImporter` to properly detect C#8
default interface methods without requiring the presence of the
(unused!) `[JavaInterfaceDefaultMethodAttribute]` custom attribute,
so that classes don't re-declare C#8 interface default methods as
"new" abstract methods.  This fixes the generated `MyAbstractClass`
declaration to be:

	// C*
	[Register (…)]
	public class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    // No `DoSomething()` declaration
	}
jonpryor pushed a commit to dotnet/java-interop that referenced this pull request Jan 5, 2021
Context: dotnet/android-libraries#235

Consider the following Java API:

	// Java
	public interface MyInterface {
	    default void doSomething() {}
	}

	public class MyAbstractClass implements MyInterface {
	}

which is then bound in C# as:

	// C#
	[Register (…)]
	public interface IMyInterface {
	    [Register(…)]
	    public void DoSomething() => …; // default interface method
	}

	[Register (…)]
	public abstract class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    // Doesn't override IMyInterface.DoSomething()
	}

`generator` needs to ensure that `Method.IsInterfaceDefaultMethod()`
gets set for `IMyInterface.DoSomething()` so that the
`BoundClass.AddInterfaceAbstractMembers()` logic knows it does not
need to create an `abstract` method `MyAbstractClass.DoSomething()`.

This works correctly if the interface is in the assembly we are
binding, because it uses `XmlApiImporter`.  That is, `generator`
output is valid if `MyInterface` and `MyAbstractClass` are in the
same `.jar`.

However, if the interface is in a reference assembly -- `MyInterface`
and `MyAbstractClass` are in different assemblies -- then `generator`
uses `CecilApiImporter`, and our Cecil importer only marks Java
Interface Default Methods if the method has a
`[JavaInterfaceDefaultMethodAttribute]` custom attribute, which we
don't appear to ever emit.

Consequently, when `MyInterface` and `MyAbstractClass` are in
separate libraries, then `MyAbstractClass` is bound as:

	// C#
	[Register (…)]
	public abstract class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    public abstract void DoSomething();
	}

which causes most bindings that inherit `MyAbstractClass` to fail,
as they typically don't override the interface default method:

	// C#
	[Register (…)]
	public class MyClass : MyAbstractClass {
	}
	// error CS0534: 'MyClass' does not implemented inherited abstract member 'MyAbstractClass.DoSomething()'


Update `generator` and `CecilApiImporter` to properly detect C#8
default interface methods without requiring the presence of the
(unused!) `[JavaInterfaceDefaultMethodAttribute]` custom attribute,
so that classes don't re-declare C#8 interface default methods as
"new" abstract methods.  This fixes the generated `MyAbstractClass`
declaration to be:

	// C*
	[Register (…)]
	public class MyAbstractClass : Java.Lang.Object, IMyInterface {
	    // No `DoSomething()` declaration
	}
@moljac moljac closed this Feb 1, 2022
@moljac moljac deleted the multitargeting branch February 1, 2022 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge PR is still in progress and is not ready to be merged in-progress in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants