Skip to content

Bindingsgenerator: Callback interface with variadic arguments generates incorrect code #167

@maksimorlovich

Description

@maksimorlovich

We have a class like this in our project jar:

package com.xamarin;

public class MyPublicClass extends MyPackageClass {
    public interface Listener {
        void call(Object... args);
    }

    @Override
    public void bugOne() {
    }

    public void bugTwo(Listener listener) {
        listener.call("abc", "def", new Integer(5));
    }
}

The C# code generated for bugTwo method and callback interface is like this:

public partial class EventArgs : global::System.EventArgs {
			public EventArgs (params global:: Java.Lang.Object[] p0)
			{
				this.p0 = p0;
			}

			params global:: Java.Lang.Object[] p0;
			public params global:: Java.Lang.Object[] P0 {
				get { return p0; }
			}
		}

It converts variadic arguments to array of Object which is fine, but it mistakenly carries through the params declaration which is invalid for member variables and return types.

This bug reproduces with Visual Studio for Mac community edition 2017 and I also built from source the generator.exe and it still repros the problem. I'm attaching a jar which shows the bug. Just create a new visual studio android binding library project and add the attached jar, build, and observe the error.
libxamarinbug.jar.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugComponent does not function as intendedgeneratorIssues binding a Java library (generator, class-parse, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions