Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Implementing java interfaces without inheriting Java.Lang.Object should fail early

$
0
0

On stack overflow I answered some questions (e.g. http://stackoverflow.com/questions/38706366/interface-implement-differences-in-c-sharp-vs-java/38707255#38707255 ) where not inheriting from Java.Lang.Object was the cause of the problem. The main problem is, that nobody sees the message on the build output.

Type 'MyListener ' implements Android.Runtime.IJavaObject but does not inherit from Java.Lang.Object. It is not supported.

Usually the interface is implemented with Handle and Dispose like:

public class SomeImplementation : ISomeJavaInterface
{
    public IntPtr Handle
    {
        get
        {
            throw new NotImplementedException();
        }
    }
    public void Dispose()
    {
        throw new NotImplementedException();
    }

    // ...
}

I've added a Stackoverflow documentation for it: http://stackoverflow.com/documentation/xamarin.android/771/bindings/18058/implementing-java-interfaces

I'm wondering if there is any reason for not failing early with a compiler error!? If not, this should be changed :)


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>