JetBrains Rider 2026.1 Help

Code inspection: According to values of the bit masks, expression result will always be the same

This inspection reports enum bitmask comparisons that look dynamic but always evaluate to the same result because of the masks involved. It usually appears in code that compares the result of & or | with a flag combination that can never match.

Example

[Flags] enum Box { Long = 1, High = 2, Colorful = 4 } bool HasColor(Box box) { return (box & Box.High) == Box.Colorful; }
[Flags] enum Box { Long = 1, High = 2, Colorful = 4 } bool HasHigh(Box box) { return (box & Box.High) == Box.High; }

How to fix

This inspection does not have a dedicated quick-fix. The fix is to compare against a flag combination that can actually be produced by the mask.

01 April 2026