-
This code shows a CS8524 and CS8509 warning, since the switch is not exhaustive and also requires a default: CS8524: The switch expression does not handle the default case or unnamed enums. public static bool IsRequest(this CommandField command)
{
// Shows squiggles CS8524 that the switch is not exhaustive.
return command switch
{
CommandField.C_STORE_RQ => true,
CommandField.C_STORE_RSP => false,
};
} The problem is that I don't want a default, since everytime a new enum value is added it is not found and and to write tests if every enum value is treated correctly is too much effort since we have thousands of different enums. I really want to have all cases treated and unnamed cases should throw an exception. So there is already a distinction with CS8524 and CS8509. I can configure both with th .editorconfig but it is not possible to change the analyzer behavior in code. There is Do I miss something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Editorconfig and/or #pragmas are the solution here. |
Beta Was this translation helpful? Give feedback.
Editorconfig and/or #pragmas are the solution here.