Skip to content

Constructor with ExportAttribute loses managed parameters #111

@outring

Description

@outring

Hi!

When a class constructor is decorated with [Export] in order to provide super arguments string, TypeManager.Activate() call loses constructor parameters types info and wrong (parameterless) constructor is being called instead.

MyView.cs:

public class MyView : Android.Views.View {
       public ItemFieldView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }

        [Export(SuperArgumentsString = "p0, null, proj.droid.proj.droid.R.attr.itemFieldStyle")]
        public MyView(Context context)
            : base(context, null, Resource.Attribute.myViewStyle)
        {
        }

        [Export(SuperArgumentsString = "p0, p1, proj.droid.proj.droid.R.attr.itemFieldStyle")]
        public MyView(Context context, IAttributeSet attrs)
            : base(context, attrs, Resource.Attribute.myViewStyle)
        {
        }

        public MyView(Context context, IAttributeSet attrs, int defStyleAttr)
            : base(context, attrs, defStyleAttr)
        {
        }

        public MyView(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes)
            : base(context, attrs, defStyleAttr, defStyleRes)
        {
        }
}

The reason is that managedParameters are just not being passed to a new Signature at https://github.com/xamarin/java.interop/blob/master/src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGenerator.cs#L251

Metadata

Metadata

Assignees

No one assigned

    Labels

    callable-wrappersIssues with Java Callable Wrappers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions