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;
}
}