locked
Binding derived interfaces with overridden methods RRS feed

  • Question

  • User67095 posted

    I'm trying to generate the binding for a third-party library (MbientLab MetaWear) but I'm having an issue with derived interfaces.

    The short version of the generated interfaces is the following:

    public partial interface IAccelerometer : IJavaObject  {
        ...
        IAccelerometerSourceSelector RouteData ();
        ...
    }
    
    public partial interface IBma255Accelerometer : IAccelerometer {
        ...
        IBma255AccelerometerSourceSelector RouteData ();
        ...
    }
    

    Notice that both define a RouteData() method with different return types. The compiler issues a CS0108 warning suggesting the use of the new keyword but I think we can ignore it.

    The return types also derive from each other:

    public partial interface IAccelerometerSourceSelector : IJavaObject {
        ...
    }
    
    public partial interface IBma255AccelerometerSourceSelector : IAccelerometerSourceSelector {
        ...
    }
    

    Then there's an implementation of the IBma255Accelerometer interface generated as follow:

    public partial class Bma255AccelerometerImpl : Java.Lang.Object, IBma255Accelerometer {
        ...
        public virtual unsafe IBma255AccelerometerSourceSelector RouteData () {
            ...
        }
        ...
    }
    

    Notice that it implements the IBma255Accelerometer version of RouteData but not the one from IAccelerometer, causing a CS0738 error. This can be fixed by adding the missing code to the additions project folder.

    My issue is that the code generator also created an internal invoker class with the exact same problem:

    internal class IBma255AccelerometerInvoker : Java.Lang.Object, IBma255Accelerometer {
        ...
        public unsafe IBma255AccelerometerSourceSelector RouteData () {
            ...
        }
        ...
    }
    

    This class is internal and not partial, not allowing the missing code to be added.

    Do you have any suggestion on how to fix this issue? Besides editing the generated code.

    Sunday, October 16, 2016 8:59 PM

All replies

  • User67095 posted

    I tried copying the generated files into the Additions folders and remove the duplicates using the Metadata.xml, and then edit them but it's a huge mess. What are the Invoker classes used for? I posted the source code at https://github.com/aalmada/MetaWear.Droid Any suggestions/feedback would be appreciated...

    Monday, October 17, 2016 9:20 PM