0

I've been writing a Xamaring Bindings Library for a third party Android JAR and become stumped at how to convert an int field in a class to an enum.

I've created a C# enum for the int fields using EnumFields.xml and have also got this successfully return out of methods using EnumMethods.xml but in one place a class is instead returned which exposes an int field which should be my enum.

I've tried:

<method jni-name="error" parameter="return" clr-enum-type=....

Within EnumMethods but couldnt get it to work, i then tried

<attr path=".......[@name='Result']/field[@name='error']"
    name="managedType">

Within Metadata.xml but also couldn't get it to map. I can change its property name but not its return type.

Within the JavaDoc it says the following:

public final int error

And in my generated C# I get:

// Metadata.xml XPath field reference: path="/api/package[@name='cn.com.aratek.util']/class[@name='Result']/field[@name='error']"

Have I missed something obvious?

MJJames
  • 735
  • 6
  • 22
  • https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-a-jar/ – Leon Mar 11 '19 at 11:50
  • Hi @LeonLu-MSFT I'm not sure what you are adding to my question? I've actually used the link and the one on the microsoft docs to get to where I am. I just can't see how to change a field of type final int to the enum – MJJames Mar 11 '19 at 15:45

1 Answers1

0

A year later I ended up stumbling across my own post after hitting the same issue again. For reference my error was trying to use managedType as the name. You simply use type.

e.g within metadata.xml

<attr path=".......[@name='Result']/field[@name='error']" name="type">NewEnumName</attr>

References I used to help figure this out:

MJJames
  • 735
  • 6
  • 22