Skip to content

Compilation error using parameter arrays in EventArgs #817

@vanka78bg

Description

@vanka78bg

I have a C# wrapper library for a native Android Java library. The wrapper library compiles just fine with Xamarin.Android, but gives me compile-time errors when trying to migrate to .NET 6.0 Android.

Given a Java interface like this:

public interface SomeListener {
    void onSomeNotification(long p0, long p1, long p2, Object... p3);
}

The following C# code is auto-generated:

public partial interface ISomeListener : IJavaObject, IJavaPeerable {
    void OnSomeNotification(long p0, long p1, long p2, params global::Java.Lang.Object[] p3);
}

public partial class SomeEventArgs : global::System.EventArgs {
    public SomeEventArgs (long p0, long p1, long p2, params global::Java.Lang.Object[] p3)
    {
        this.p0 = p0;
        this.p1 = p1;
        this.p2 = p2;
        this.p3 = p3;
    }

    long p0;

    public long P0 {
        get { return p0; }
    }

    long p1;

    public long P1 {
        get { return p1; }
    }

    long p2;

    public long P2 {
        get { return p2; }
    }

    params global::Java.Lang.Object[] p3;

    public params global::Java.Lang.Object[] P3 {
        get { return p3; }
    }
}

Take note on the last few lines where the params keyword is used incorrectly.
The above auto-generated code fails to compile with the following build error:
"Invalid token 'params' in class, record, struct, or interface member declaration"

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