ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Some values of the enum are not processed inside 'switch' expression and are handled via exception in default arm

Last modified: 11 February 2024

When using a switch expression with an enum, it is not required to have arms for each enum value — these values will be processed in the _ discard.

This might be intended by the author to handle some unimportant values. But if the _ discard throws an exception, all usages of the switch with non-processed enum values will also throw the exception, which is probably a consequence of adding a new value to the enum and forgetting to update the switch accordingly.