All rules
CA1003Design Enabled by default: No

Use generic event handler instances

Use generic event handler instances

Microsoft docs

Description

Before .NET Framework 2.0, in order to pass custom information to the event handler, a new delegate had to be declared that specified a class that was derived from the System.EventArgs class. In .NET Framework 2.0 and later versions, the generic System.EventHandler`1 delegate allows any class that's derived from System.EventArgs to be used together with the event handler.

Cause

A type contains a delegate that returns void and whose signature contains two parameters (the first an object and the second a type that is assignable to EventArgs), and the containing assembly targets .NET.

By default, this rule only looks at externally visible types, but this is configurable.

How to fix violations

To fix a violation of this rule, remove the delegate and replace its use by using the System.EventHandler`1 delegate.

If the delegate is autogenerated by the Visual Basic compiler, change the syntax of the event declaration to use the System.EventHandler`1 delegate.

When to suppress

Do not suppress a warning from this rule.

Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0