Skip to content

Gendarme.Rules.Design.ConsiderConvertingFieldToNullableRule(git)

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

ConsiderConvertingFieldToNullableRule

Assembly: Gendarme.Rules.Design
Version: git

Description

This rule checks for pairs of fields which seem to provide the same functionality as a single nullable field. If the assembly targets version 2.0, or more recent, of the CLR then the rule will fire to let you know that a nullable field can be used instead. The rule will ignore assemblies targeting earlier versions of the CLR.

Examples

Bad example:

public class Bad {
    bool hasFoo;
    int foo;
}

Good example:

public class Good {
    int? foo;
}

Notes

  • This rule is available since Gendarme 2.0

Source code

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

Clone this wiki locally