Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Problem binding EventArgs with different parameters #461

Description

@jpobst

The following unit test creates a Listener that has the same event with different parameters.

[Test]
public void WriteInterfaceEventArgs2 ()
{
	var iface = SupportTypeBuilder.CreateEmptyInterface ("java.code.AnimatorListener");

	var method1 = SupportTypeBuilder.CreateMethod (iface, "onAnimationEnd", options, "void", false, true, new Parameter ("param1", "int", "int", false));
	var method2 = SupportTypeBuilder.CreateMethod (iface, "onAnimationEnd", options, "void", false, true, new Parameter ("param1", "int", "int", false), new Parameter ("param2", "int", "int", false));

	iface.Methods.Add (method1);
	iface.Methods.Add (method2);

	generator.Context.ContextTypes.Push (iface);
	generator.WriteInterfaceEventHandler (iface, string.Empty);
	generator.Context.ContextTypes.Pop ();

	Assert.AreEqual (GetExpected (nameof (WriteInterfaceEventArgs2)), writer.ToString ().NormalizeLineEndings ());
}

We magically convert these parameters into EventArgs, but we duplicate them as partial classes which doesn't compile:

// event args for java.code.AnimatorListener.onAnimationEnd
public partial class onAnimationEndEventArgs : global::System.EventArgs {

	public onAnimationEndEventArgs (int param1)
	{
		this.param1 = param1;
	}

	int param1;
	public int Param1 {
		get { return param1; }
	}
}

// event args for java.code.AnimatorListener.onAnimationEnd
public partial class onAnimationEndEventArgs : global::System.EventArgs {

	public onAnimationEndEventArgs (int param1, int param2)
	{
		this.param1 = param1;
		this.param2 = param2;
	}

	int param1;
	public int Param1 {
		get { return param1; }
	}

	int param2;
	public int Param2 {
		get { return param2; }
	}
}
The type 'onAnimationEndEventArgs' already contains a definition for 'param1'

This probably doesn't come up in a non-DIM world, but with DIM we hit it binding this interface:
https://developer.android.com/reference/android/animation/Animator.AnimatorListener

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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