Skip to content

[Mono.Android] Generate default interface members for API-30+. - #4353

Merged
jonpryor merged 1 commit into
masterfrom
monoandroid-csharp8
Mar 5, 2020
Merged

[Mono.Android] Generate default interface members for API-30+.#4353
jonpryor merged 1 commit into
masterfrom
monoandroid-csharp8

Conversation

@jpobst

@jpobstjpobst commented Mar 3, 2020

Copy link
Copy Markdown
Contributor

Context: dotnet/java-interop#509

Using the new features provided by C#8 to provide bindings that mirror the original Java android.jar more closely.

Step 1 - Default Interface Members

Enable --lang-features=default-interface-methods to start generating default methods on all interfaces in Mono.Android.dll API-30+.

@jpobst
jpobstforce-pushed the monoandroid-csharp8 branch from 15c0723 to 4c89765CompareMarch 4, 2020 15:59
@jpobst
jpobstforce-pushed the monoandroid-csharp8 branch from 4c89765 to 9046473CompareMarch 4, 2020 16:27
@jpobst
jpobst marked this pull request as ready for review March 4, 2020 20:11
@jpobst
jpobst requested a review from jonpryor as a code ownerMarch 4, 2020 20:11
@jpobst
jpobst requested a review from gugavaroMarch 4, 2020 20:11
@jonpryor
jonpryor merged commit 54beb90 into masterMar 5, 2020
@jonpryor
jonpryor deleted the monoandroid-csharp8 branch March 5, 2020 16:38
jonpryor added a commit that referenced this pull request Mar 6, 2020
Context: dotnet/java-interop#509
Use `generator --lang-features=default-interface-methods` so that we
start binding [Java interface default methods][0] within `android.jar`
and `Mono.Android.dll`, for API-R.
*Note*: `Microsoft.DotNet.ApiCompat.exe` does not currently understand
C#8 [default interface members][1], which we use to bind Java interface
default methods. As such, it reports an error for *every added*
default interface member, e.g.
InterfacesShouldHaveSameMembers : Interface member 'Android.App.Application.IActivityLifecycleCallbacks.OnActivityPostCreated(Android.App.Activity, Android.OS.Bundle)' is present in the implementation but not in the contract.
We are investigating improving `Microsoft.DotNet.ApiCompat.exe` so
that it doesn't report such changes as incompatible.
[0]: https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html
[1]: https://github.com/dotnet/csharplang/blob/f7952cdddf85316a4beec493a0ecc14fcb3241c8/proposals/csharp-8.0/default-interface-methods.md
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jan 24, 2024
Sign up for freeto 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.

4 participants

@jpobst@gugavaro@jonpryor@brendanzagaeski