Skip to content

Gendarme.Rules.Gendarme.DoNotThrowExceptionRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

DoNotThrowExceptionRule

Assembly: Gendarme.Rules.Gendarme
Version: git

Description

This rule finds Gendarme rules that throw exceptions because runner's behavior in case of rule throwing an exception is undefined.

Examples

Bad example:

public class ExampleRule : Rule, IMethodRule {
    public RuleResult CheckMethod (MethodDefinition method)
    {
        if (method == null)
        throw new ArgumentNullException ("method");
        // other rule logic
    }
}

Good example:

public class ExampleRule : Rule, IMethodRule {
    public RuleResult CheckMethod (MethodDefinition method)
    {
        // method is not null by contract
        return RuleResult.Success;
    }
}

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally