As Jacob says, it may be useful to have a mixture of flags ... but perhaps you could indicate that one way or another so that your discovery does not mind.
You cannot write a unit test that goes through each enumeration in an assembly decorated with [Flags] and checks if there is a value for 0 (it is possible that it should be called None or Default ) and that any other specific value (from Enum.GetValues() ) is a power of two. You can verify that with if ((x & (x - 1)) == 0) .
You might have something like the [Combination] attribute to indicate values ββthat are for combinations ... they can even indicate which flag names they should be combinations, so you can check that too.
I know that this is not as good as checking compile time, but assuming you already run the tests regularly, it's pretty close.
source share