Skip to content

Gendarme.Rules.Design.Generic.AvoidDeclaringCustomDelegatesRule(2.10)

Sebastien Pouliot edited this page Feb 9, 2011 · 3 revisions

AvoidDeclaringCustomDelegatesRule

Assembly: Gendarme.Rules.Design.Generic
Version: 2.10

Description

This rule will fire if custom delegates are defined when either pre-defined Action, Action<T[,...]> or Func<[Tx,...]TResult> could have been used. This rule applies only to code using the framework version 2.0 (or later).

Examples

Bad example (without return value):

delegate void MyCustomDelegate (int a);
private MyCustomDelegate custom_delegate;

Good example (without return value):

private Action<int> action_delegate;

Bad example (with return value):

delegate int MyCustomDelegate (int a, string s);
private MyCustomDelegate custom_delegate;

Good example (with return value):

private Func<int,string,int> func_delegate;

Notes

  • This rule is available since Gendarme 2.8
Clone this wiki locally