Closed
Description
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