Not handling all combinations of named enum values and booleans should give a CS8509 warning regardless of order, even if warnings are disabled for CS8524 #64698
Labels
Area-Compilers
Concept-Diagnostic Clarity
The issues deals with the ease of understanding of errors and warnings.
Resolution-By Design
The behavior reported in the issue matches the current design
Milestone
[Summary(jcouv):] The ask is to report exhaustiveness problems using named enum values (over unnamed ones) where possible.
Version Used:
dotnet version 6.0.110
Microsoft (R) Build Engine version 17.0.1+b177f8fa7 for .NET
Steps to Reproduce:
A CS8524 warning is given if we forget to handle an unnamed enum value, for instance
(Values)2
. I want to disable warnings for CS8524, in order to get a warning, namely CS8509, if and only if I forget to handle a named enum value, or a combination of named enum values and booleans.The following, with
Value1
at the top, gives "warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '(Values.Value1, false)' is not covered.", as I expect:The following, with the boolean first, also gives the same warning, as I expect:
However, the following, with
Value1
at the bottom and the boolean last, gives no warnings, which I do not expect:If I do handle some unnamed enum values without handling
(Values.Value1, false)
, regardless of whether warnings for CS8524 are disabled or not, I do get the same warning as intest1
andtest2
, as I expect:Expected Behavior:
A CS8509 warning telling me that I forgot to handle the pattern
(Values.Value1, false)
for all of the above examples, regardless of order.Actual Behavior:
No warning for
test3
, even if not all combinations of named enum values and booleans are handled.The text was updated successfully, but these errors were encountered: