JetBrains Rider 2022.2 Help

Code Inspection: Some values of the enum are not processed inside switch statement

When using a switch statement with an enum, it is not required to have a case statement for each enum value — if some values do not have cases, the switch will do nothing for such values.

Although missing cases might be intended by the author, more often than not it is a consequence of adding a new value to the enum and forgetting to update the switch accordingly.

JetBrains Rider flags such switch statements as potential issues and suggests generating case statements for unhandled values.

enum TestEnum { A, B } class Program { void Test(TestEnum testEnum) { // case 'TestEnum.B' is not handled and won't do anything switch (testEnum) { case TestEnum.A: Console.WriteLine("A"); break; } } }
Last modified: 08 March 2021