Constructor with ExportAttribute loses managed parameters
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
Export attribute is NOT supported on constructors.
Hi, @atsushieno! Since when? Because according to the code it works. And, of course, according to this ticket.
It's not supported as in that its implementation is hacky and won't work other than those described on that bug. That cannot be at "supported" state.
Though it's looking something @jonpryor can take a look and fix, if that change makes it to work for you.
If it's not so important to you can leave it as is, and I'll fix it when I find some time for it.