I have a enum Color
:
enum Color {
red,
blue,
noColor // This will be deprecated.
}
And a function PrintColor
:
public void PrintColor(Color color) {
Console.WriteLine(color);
}
Because I want to noColor
to be deprecated, so I don't allow PrintColor
's parameter color
to be Color.noColor
. Is it possible to be checked by Roslyn that when color would be Color.noColor
, we raise an error at compile time?
comments
I think this one is easy to check:
PrintColor(Color.noColor);
But how to check this one:
public void GetNoColor() => Color.noColor;
PrintColor(GetNoColor());