A [Flags] enum has no member with the value 0

tx0/csharp:flags-enum-without-zerostrictwarningmaintainability/designdepth fastsmell

What it finds

The default value of every enum is 0. For a set of flags, 0 means "no flag set"; without a member for it, typically named None, a fresh variable holds a value with no name and tests against it read poorly.

From the rule's source, flags_enum_without_zero.rs.

Example from the rule's tests
using System; [Flags]enum Accesstx0 reports: the flags enum Access has no member for 0{    Read = 1,    Write = 2,} [Flags]enum Mode{    None = 0,    Fast = 1,}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp:flags-enum-without-zero" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/csharp:flags-enum-without-zero] reason="..."

tx0 explain tx0/csharp:flags-enum-without-zero shows the same in the terminal. Found a false positive? Report it.