Language: C# | Type: CODE_SMELL | Severity: Major
Tags: convention
Delegate event handlers (i.e. delegates used as type of an event) should have a very specific signature:
void.System.Object and named 'sender'.System.EventArgs (or any derived type) and is named 'e'.This rule raises an issue whenever a delegate declaration doesn’t match that signature.
public delegate void AlarmEventHandler(object s);
public class Foo
{
public event AlarmEventHandler AlarmEvent; // Noncompliant
}
public delegate void AlarmEventHandler(object sender, AlarmEventArgs e);
public class Foo
{
public event AlarmEventHandler AlarmEvent; // Compliant
}