Skip to content

Gendarme.Rules.Design.EnumsShouldDefineAZeroValueRule(git)

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

EnumsShouldDefineAZeroValueRule

Assembly: Gendarme.Rules.Design
Version: git

Description

This rule ensures that every non-flags enumeration contains a 0 value. This is important because if a field is not explicitly initialized .NET will zero-initialize it and, if the enum has no zero value, then it will be initialized to an invalid value.

Examples

Bad example:

enum Position {
    First = 1,
    Second
}

Good example:

enum Position {
    First,
    Second
}

Source code

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

Clone this wiki locally