Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor with ExportAttribute loses managed parameters #111

Open
outring opened this issue Dec 23, 2016 · 4 comments
Open

Constructor with ExportAttribute loses managed parameters #111

outring opened this issue Dec 23, 2016 · 4 comments
Labels
bug Component does not function as intended callable-wrappers Issues with Java Callable Wrappers

Comments

@outring
Copy link

outring commented Dec 23, 2016

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

@atsushieno
Copy link
Contributor

Export attribute is NOT supported on constructors.

@outring
Copy link
Author

outring commented Jan 17, 2017

Hi, @atsushieno! Since when? Because according to the code it works. And, of course, according to this ticket.

@atsushieno
Copy link
Contributor

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.

@outring
Copy link
Author

outring commented Jan 17, 2017

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.

@jpobst jpobst added bug Component does not function as intended callable-wrappers Issues with Java Callable Wrappers labels Apr 16, 2020
jonpryor pushed a commit that referenced this issue Mar 8, 2021
Changes: dotnet/android-tools@479931c...554d45a

  * dotnet/android-tools@554d45a: [Xamarin.Android.Tools.AndroidSdk] Fix CS8600 in AndroidSdkBase (#107)
  * dotnet/android-tools@19454f9: Bump to xamarin/LibZipSharp/main@86f8ae57 [1.0.24] (#111)
  * dotnet/android-tools@3582b39: [macOS] fix DirectoryNotFoundException on clean systems (#110)
  * dotnet/android-tools@ca820e5: Bump to xamarin/LibZipSharp/main@521b54ec [1.0.23] (#109)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Component does not function as intended callable-wrappers Issues with Java Callable Wrappers
Projects
None yet
Development

No branches or pull requests

3 participants