C# overriden method not being invoked when the underlying swift method gets invoked

78 Views Asked by At

I have a xamarin C# bindings-project that wraps around a trivial swift library. The swift library contains a class like so:

@objc(Foobar)
public class Foobar: NSObject {
    @objc
    public func pingpong() { // <--- this gets invoked in swift at some point
         //...
    }
}

I use sharpie and lipo to generate the C# bindings that look like so:

    [BaseType (typeof(NSObject))]
    [DisableDefaultCtor]
    interface Foobar
    {
        // -(void)foobar:;
        [Export ("foobar")]
        void Pingpong ();
    }

In my C# code I subclass Foobar like so:

public class Fibar : Foobar {
   public override void Pingpong() // <-- this should be getting invoked but doesn't
   {
        base.Pingpong();
        // ...
   }
}

I've verified that the Swift method Foobar.pingpong() does indeed get invoked however the C# override Fibar.Pingpong() never gets invoked.

I would have expected the C# code to be invoked first - so why doesn't it? Am I missing something?

0

There are 0 best solutions below