Only FlagsAttribute enums should have plural names
This warning is supported in the stand-alone version of FxCop only. It is not supported in Code Analysis, which is integrated into Visual Studio.
TypeName |
OnlyFlagsEnumsShouldHavePluralNames |
CheckId |
CA1717 |
Category |
Microsoft.Naming |
Breaking Change |
Breaking |
Cause
The name of an externally visible enumeration ends in a plural word and the enumeration is not marked with the System.FlagsAttribute attribute.
Rule Description
Naming conventions dictate that a plural name for an enumeration indicates that more than one value of the enumeration can be specified simultaneously. The FlagsAttribute tells compilers that the enumeration should be treated as a bit field that allows bitwise operations on the enumeration.
If only one value of an enumeration can be specified at a time, the name of the enumeration should be a singular word. For example, an enumeration that defines the days of the week might be intended for use in an application where you can specify multiple days. This enumeration should have the FlagsAttribute and could be called 'Days'. A similar enumeration that allows only a single day to be specified would not have the attribute, and could be called 'Day'.
Naming conventions provide a common look for libraries that target the common language runtime. This reduces the time that is required to learn a new software library, and increases customer confidence that the library was developed by someone with expertise in developing managed code.
How to Fix Violations
Make the name of the enumeration a singular word or add the FlagsAttribute.
When to Exclude Warnings
It is safe to exclude a warning from the rule if the name ends in a singular word.
Related Rules
Flags enums should have plural names
Mark enums with FlagsAttribute
Do not mark enums with FlagsAttribute