Skip to content

Gendarme.Rules.Gendarme.DoNotThrowExceptionRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

DoNotThrowExceptionRule

Assembly: Gendarme.Rules.Gendarme
Version: 2.10

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;
    }
}
Clone this wiki locally