C#

C#

Made by DeepSource

enum with Flags attribute has invalid values CS-W1015

Bug risk
Major

Flags attribute is used to indicate that an enumeration can be treated as a bit field; that is, a set of flags. For this to be possible, the values specified inside the enum must be a power of 2. Either consider providing the right values, or dropping the said enum's attribute altogether.

Bad Practice

[Flags]
enum Permissions
{
    Read = 1,
    Write = 3 // Wrong
};

Recommended

[Flags]
enum Permissions
{
    Read = 1,
    Write = 2
};

Reference