Is there a tool or a compiler flag to help identify switch statements missing one or more case statements?
The idea is
enum Colors { Black, Blue }
and
Colors c = Colors.Black;
then a number of places in the code I have
switch(c)
{
case Black:
...
break;
case Blue:
...
break;
}
When extending the colors enum, I need to visit all my switch statements and extend.
I know that possibly I could refactor the code to using strategies instead, but this was just an exaple.
I am also aware that had I implemented my switch as
switch(c)
{
case Black:
...
break;
case Blue:
...
break;
default: throw new Exception("not supported " + c);
}
that I may have run out of luck.