A [Flags] enum has a member whose value is neither a single bit nor a combination of others
What it finds
Members of a flags enum are combined with | and tested with &; a member such as = 3 that is not one bit and not written as a combination of other members overlaps them by accident, so testing for one flag also matches another. Members written as expressions, and zero, are left alone.
From the rule's source, flags_enum_values.rs.
using System; [Flags]enum Access{ None = 0, Read = 1, Write = 2, Both = 3, Execute = 4, Odd = 9,tx0 reports: Odd is 9, neither a single bit nor a combination of other members All = Read | Write | Execute,} enum Plain{ A = 3,} 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:
[rules]
"tx0/csharp:flags-enum-values" = "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-values] reason="..."tx0 explain tx0/csharp:flags-enum-values shows the same in the terminal. Found a false positive? Report it.