C# Extension failed to override base class method

When I try to use C# Extension to refactor my cross platform IDispose interface, there’s a problem for iOS:

public interface IDispose
    #if COOPER
    : java.io.Closeable
    #elif ECHOES
    : System.IDisposable
    #endif
{
    void dispose();
}

public __extension class IDisposeDefault : IDispose {
    #if ECHOES
    public void Dispose() => dispose();
    #elif COOPER
    public void close() => dispose();
    #elif TOFFEE

    // This override won't take effect
    public override void dealloc() => dispose();

    #endif
}

public class TestDisposeClass : IDispose{
    public static bool isDisposed = false;
    public void dispose(){
        isDisposed = true;
    }
}

public class MyTest{
    public static void test(){
        using(var t = new TestDisposeClass()){
        }

        // result is true for ECHOES/COOPER, but false for TOFFEE
        var result = TestDisposeClass.isDisposed;
    }
}

Thanks, logged as bugs://75987

ah I see now what you mean. But that’s because extension don’t ever override, they just implement if needed. This is going to be a lot trickier than it sounds.

bugs://75987 got closed with status fixed.

Oke so in the next build you can do:

  public interface IDispose
    #if COOPER
    : java.io.Closeable
    #elif ECHOES
    : System.IDisposable
    #endif
{
    void dispose();

    #if TOFFEE
    void dealloc();
    #endif
}

(Note the #if TOFFEE block)

this requires the upcoming build to work though

Thank you Carlo :+1:

Logged as bugs://i63921.

bugs://i63921 was closed as fixed.