C#

C#

Made by DeepSource

enum marked with Flags attribute is missing required initialization CS-W1049

Bug risk
Critical

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, each member inside the enum must be explicitly initialized to a value that is power of 2. Either consider providing the right values, or dropping the said enum's attribute altogether.

Bad Practice

[Flags]
enum SingleHue
{
    None = 0,
    Black = 1,
    Red = 2,
    Green = 4,
    Blue
};

Recommended

[Flags]
enum SingleHue
{
    None = 0,
    Black = 1,
    Red = 2,
    Green = 4,
    Blue = 8
};

Reference