1

I have a Xamarin Android binding error that makes no sense!

The generated class stubs are:

[global::Android.Runtime.Register ("com/scichart/drawing/common/IRenderSurface", DoNotGenerateAcw=true)]
internal class IRenderSurfaceInvoker : global::Java.Lang.Object, IRenderSurface


[Register ("com/scichart/drawing/common/IRenderSurface", "", "Com.Scichart.Drawing.Common.IRenderSurfaceInvoker")]
public partial interface IRenderSurface : global::Com.Scichart.Core.Framework.IInvalidatableElement, global::Com.Scichart.Core.Framework.IView { } 

// Metadata.xml XPath interface reference: path="/api/package[@name='com.scichart.core.framework']/interface[@name='IView']"
[Register ("com/scichart/core/framework/IView", "", "Com.Scichart.Core.Framework.IViewInvoker")]
public partial interface IView : global::Com.Scichart.Core.Framework.IContextProvider, global::Com.Scichart.Core.Framework.IHitTestable 
{

    int Visibility 
    {
        // Metadata.xml XPath method reference: path="/api/package[@name='com.scichart.core.framework']/interface[@name='IView']/method[@name='getVisibility' and count(parameter)=0]"
        [Register ("getVisibility", "()I", "GetGetVisibilityHandler:Com.Scichart.Core.Framework.IViewInvoker, SciChart.Android.Core")] get;
        // Metadata.xml XPath method reference: path="/api/package[@name='com.scichart.core.framework']/interface[@name='IView']/method[@name='setVisibility' and count(parameter)=1 and parameter[1][@type='int']]"
        [Register ("setVisibility", "(I)V", "GetSetVisibility_IHandler:Com.Scichart.Core.Framework.IViewInvoker, SciChart.Android.Core")] set;
    }
}

What's happening is IView.Visibility (which has get, set) is conflicting with a base class Android.View.Visibility. I've worked around the conflict in additions folder but there is this IRenderSurfaceInvoker class which is generated, and not partial, and isn't implementing the IView interface properly.

enter image description here

Normally I'd ignore the property in metadata.xml and create it manually in a partial class, but that isn't possible as IRenderSurfaceInvoker is not partial.

What is a FooInvoker anyway??!

Any ideas? :)

EDIT: UPDATE

After Sven-Michael Stube's answer below, I have this partial solution:

<!-- In EnumMethods.xml -->
<mapping jni-interface="com/scichart/core/framework/IView">
    <method jni-name="getVisibility" parameter="return" clr-enum-type="Android.Views.ViewStates" />
    <method jni-name="setVisibility" parameter="visibility" clr-enum-type="Android.Views.ViewStates" />
</mapping>

But this results in the IView interface being generated as follows:

    global::Android.Views.ViewStates Visibility {
        // Metadata.xml XPath method reference: path="/api/package[@name='com.scichart.core.framework']/interface[@name='IView']/method[@name='getVisibility' and count(parameter)=0]"
        [Register ("getVisibility", "()I", "GetGetVisibilityHandler:Com.Scichart.Core.Framework.IViewInvoker, SciChart.Android.Core")] get;
    }

and the warning output

<attr path="/api/package[@name='com.scichart.core.framework']/interface[@name='IView']‌​/method[@name='setVisibility']/parameter[@name='visibility']"/> matched no nodes

In other words, the EnumMethods.xml declaration above deletes the setter as it cannot find a match.

How can I debug this?

1 Answer 1

1

I think you don't have to workaround your View vs IView problem. You should override the return value of the getter and the parameter of the setter to be Android.Views.ViewStates in EnumMethods.xml. This may solve your problem if you do it consistently.

<mapping jni-interface="com/scichart/core/framework/IView">
    <method jni-name="getVisibility" parameter="return" clr-enum-type="Android.Views.ViewStates" />
    <method jni-name="setVisibility" parameter="p0" clr-enum-type="Android.Views.ViewStates" />
</mapping>
Sign up to request clarification or add additional context in comments.

4 Comments

One small problem. jni-class should be jni-interface otherwise both nodes cannot be found. But even then it replaces the getVisbility and deletes the setVisibility with the warning <attr path="/api/package[@name='com.scichart.core.framework']/interface[@name='IView']/method[@name='setVisibility']/parameter[@name='visibility']"/> matched no nodes Any ideas?
is the parameter called `visibility? This was just a guess.
In java, yes it is. C# still can't find it. I have however named it to p0 and it randomly worked :0
I edited your answer to fix + accepted. Thanks for help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.