Besides that, the feature I want most in C# is enum exhaustion checking. So I can write:
enum Color { red, green, blue };
public static string SuperheroFromColor(Color c)
{
if (c == Color.red)
{
return "Superman";
}
else if (c == Color.green)
{
return "Green Lantern";
}
else if (c == Color.blue)
{
return "Spiderman";
}
}
and not get a compiler error (that not all code paths return a value). But if I added "yellow" as an enum option, then I would get a compiler error. I realize that Color can be cast from an out-of-range int, so it's a little complicated. I'm willing to put something extra after the last else: unreachable return null;
or use a special switch statement. I just want something so the compiler checks that I have accounted for all normal enum values.Is anyone talking about such a feature, or where would I request it? Can I write it myself as a Roslyn extension?