Flags 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

FlagsEnumsShouldHavePluralNames

CheckId

CA1714

Category

Microsoft.Naming

Breaking Change

Breaking

Cause

A public enumeration has the System.FlagsAttribute and its name does not end in a plural word.

Rule Description

Types marked with FlagsAttribute have names that are plural because the attribute indicates that more than one value can be specified. 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 learning curve required for new software libraries, 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 plural word, or remove the FlagsAttribute attribute if multiple enumeration values should not be specified simultaneously.

When to Exclude Warnings

It is safe to exclude a violation if the name is plural. For example, if the multiple-day enumeration described previously were named 'DaysOfTheWeek', this would violate the rule's logic but not its intent. Such violations should be excluded.

Mark enums with FlagsAttribute

Do not mark enums with FlagsAttribute

Only FlagsAttribute enums should have plural names

See Also

Reference

System.FlagsAttribute

Other Resources

Value Type Usage Guidelines