-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Design.UseFlagsAttributeRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Design
Version: git
This rule will fire if an enum's values look like they are intended to be composed together with the bitwise OR operator and the enum is not decorated with System.FlagsAttribute. Using FlagsAttribute will allow System.Enum.ToString() to return a better string when values are ORed together and helps indicate to readers of the code the intended usage of the enum.
Bad example:
[Serializable]
enum Options {
First = 1,
Second = 2,
Third = 4,
All = First | Second | Third,
}
Good example:
[Flags]
[Serializable]
enum Options {
First = 1,
Second = 2,
Third = 4,
All = First | Second | Third,
}
- This rule is available since Gendarme 2.6
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!