Change base class in binding

Hello,

I am trying to create a Binding for ACRA (https://github.com/ACRA/acra), I created the binding project and added the JAR (https://github.com/downloads/ACRA/acra/acra-4.4.0.zip)... but the generated code includes this:

[global::Android.Runtime.Register ("org/acra/ACRAConfiguration", DoNotGenerateAcw=true)]
public partial class ACRAConfiguration : global::Java.Lang.Object, global::Org.Acra.Annotation.ReportsCrashes {

Which is incorrect, because it cannot inherit from 2 classes.... BUT... the class "ReportsCrashes" already inherits from Java.Lang.Object

[global::Android.Runtime.Register ("org/acra/annotation/ReportsCrashes", DoNotGenerateAcw=true)]
public abstract partial class ReportsCrashes : global::Java.Lang.Object, global::Java.Lang.Annotation.IAnnotation {

So.... How can I change the manifest.xml file so the class "ACRAConfiguration" ONLY inherits from ReportsCrashes?

I read :

http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/api_metadata_reference
http://www.mono-project.com/GAPI#Metadata

And I could not find a way to do it... Any help would be great!

FYI: I tried:

<attr path="/api/package[@name='org.acra']/class[@name='ACRAConfiguration']" name="baseClass">Org.Acra.Annotation.ReportsCrashes</attr>
<attr path="/api/package[@name='org.acra']/class[@name='ACRAConfiguration']" name="base">Org.Acra.Annotation.ReportsCrashes</attr>
<attr path="/api/package[@name='org.acra']/class[@name='ACRAConfiguration']" name="parent">Org.Acra.Annotation.ReportsCrashes</attr>

and nothing happens.

Thank you,
Daniel.

Posts

  • AtsushiEnomotoAtsushiEnomoto JPMember, Xamarin Team Xamurai
    edited March 2013

    TL;DR - this is a bug that cannot be workarounded, so you'd like to use to go on.

    I figured that ARCAConfiguration is of Java annotation. For Java annotations, we have treat them as object, have special code generator path and somehow force "Java.Lang.Object" for every annotation types. This apply to all annotation types. ARCAConfiguration is derived from ReportCrashes and it is derived from Java.Lang.Object in C# for the above reason.

    There is some reason why annotations are treated as Object, yet it is not correct - we use some XML metadata for API. It is not what we originally generated. They are based on historical Android AOSP format:
    https://github.com/OESF/OHA-Android-4.2_r1/tree/master/frameworks/base/api
    In those .xml files, annotation types are somehow represented in "class" element (e.g. look for "Documented" in any xml file). Hence we treated them as classes.
    Though this case shows that such code generation brings some mismatch. I also confirmed that multiple annotation types could be implemented in a single class (which I'm not sure is good but anyhow doable). So we will need to make it better.

    So far, since it is pretty much hard-coded logic to explicitly give Java.Lang.Object by our binding generator, there is no way to workaround this issue - so please "remove" this type by using operation in Metadata.xml. Sorry for inconvenience.

  • DanielUlfeDanielUlfe USMember

    Ok... thank you for letting me know, now I can stop trying to figure out how to do it!

Sign In or Register to comment.