Skip to content

FlagsEnum to handle zero (0) value specially

Consider the following property in a TestStep:

 [Flags]
        public enum FixturePositions
        {
             [Display("My Fixture Position A")]
             A =0,
             B=1,
             C=2,
             D=4,
             [Display("My Fixture Position E")]
             E =8,
             F=16,
             G=32
        }

This yields odd behavior in the Editor, due to the A (0) value:

flagstep1

Suggested fix is to handle zero value special by deselecting all values when 0 is selected.

As noted in the comment we should also handle other special cases like B|C.

Edited by Vivienne Spence