When using EventArgs attribute on delegate method it generates event handler class with properties based on method parameters except the first one.
The first parameter is missing in generated event args class.
For example:
[Protocol, Model]
[BaseType(typeof(NSObject))]
public interface TestDelegate
{
// @required -(void)DidReceiveFrom:(NSString * _Nonnull)p1 withP2:(NSString * _Nonnull)p2 withP3:(NSString * _Nonnull)p3 withP4:(NSString * _Nonnull)p4;
[Abstract]
[Export("DidReceiveFrom:withP2:withP3:withP4:")]
[EventArgs("DidReceiveFrom")]
void DidReceiveFrom(string p1, string p2, string p3, string p4);
Then generated EventArgs class becomes:
//
// EventArgs classes
//
public partial class DidReceiveFromEventArgs : EventArgs {
public DidReceiveFromEventArgs (string p2, string p3, string p4)
{
this.p2 = p2;
this.p3 = p3;
this.p4 = p4;
}
public string p2 { get; set; }
public string p3 { get; set; }
public string p4 { get; set; }
}
So it definitely missing p1 property. How to avoid this behavior?
According to the Xamarin documentation this behavior is by default:
For events that take more than one parameter (in Objective-C the convention is that the first parameter in a delegate class is the instance of the sender object) you must provide the name that you would like for the generated EventArgs class to be. This is done with the EventArgs attribute on the method declaration in your Model class.
So is seems that delegates in source library for which I was generating bindings does not strictly follow this rule and the first parameter is semi-sender in string form.