Skip to content

Support default interface methods #1883

Closed

Description

@atsushieno

It's been known that C# 8.0 will support default interface methods (DIM) and we will have to wait for 8.0. Turned out that there is already a preview version built within mono sdks, named as csc-dim.

We should make use of it and implement preview support for DIMs that will make Java bindings easier.

So far I observed they exist in xamarin-android built tree as:

/sources/xamarin-android$ find . -name csc-dim*
./external/mono/scripts/csc-dim.in
./external/mono/sdks/builds/android-armeabi-v7a-debug/scripts/csc-dim
./external/mono/sdks/builds/android-x86-debug/scripts/csc-dim
./external/mono/sdks/builds/android-host-Linux-debug/scripts/csc-dim

/sources/xamarin-android$ cat ./external/mono/sdks/builds/android-host-Linux-debug/scripts/csc-dim
#!/bin/sh
exec /sources/xamarin-android/external/mono/sdks/out/android-host-Linux-debug/bin/mono --gc-params=nursery-size=64m $MONO_OPTIONS /sources/xamarin-android/external/mono/sdks/out/android-host-Linux-debug/lib/mono/4.5/dim/csc.exe "$@"

Activity

  1. atsushieno commented on Jun 26, 2018

    @atsushieno
    ContributorAuthor

    Marek Safar said we should use csc-dim from system mono instead (after I noticed there is actually no /sources/xamarin-android/external/mono/sdks/out/android-host-Linux-debug/lib/mono/4.5/dim/csc.exe). What we should do is probably an extension NuGet package that provides these "dim" assemblies and override CscToolPath MSBuild property. So far /p:CscToolExe=/path/to/my/lib/mono/4.5/dim made it to work.

  2. jonpryor commented on Jun 26, 2018

    @jonpryor
    Contributor

    Step 1: update generator within Java.Interop to emit default interface methods.

    This need only support the XAJavaInterop1 and JavaInterop codegen targets, not the XamarinAndroid codegen target.

  3. jonpryor commented on Jun 26, 2018

    @jonpryor
    Contributor

    Existing on-desktop-JVM Java.Interop unit tests: https://github.com/xamarin/java.interop/tree/master/src/Java.Interop/Tests
    https://github.com/xamarin/java.interop/blob/master/src/Java.Interop/Tests/Java.Interop/JavaObjectTest.cs

    These build atop a JavaVMFixture, which creates a desktop JVM: https://github.com/xamarin/java.interop/blob/master/tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs
    https://github.com/xamarin/java.interop/blob/master/tests/TestJVM/TestJVM.cs

    It should be straightforward to add a new generator unit test fixture which uses TestJVM/etc. to create an on-desktop JVM and run tests using generator-emitted code.

  4. self-assigned this
    on Jul 4, 2018
  5. removed their assignment
    on Sep 14, 2019
  6. jpobst commented on Oct 1, 2019

    @jpobst
    Contributor

    Added in #3533.

  7. ghost locked as resolved and limited conversation to collaborators on Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions