VSDiagnostics icon indicating copy to clipboard operation
VSDiagnostics copied to clipboard

Implement EnumParameterNotValidated

Open Vannevelj opened this issue 8 years ago • 1 comments

DO validate enum parameters.

https://msdn.microsoft.com/en-us/library/ms229015(v=vs.110).aspx

void Main()
{
    M((X) 1574);
}

void M(X x)
{
    Console.WriteLine(x); // 1574
    Console.WriteLine(Enum.IsDefined(typeof(X), x)); // false
}

enum X
{
    ABC = 5
}

Vannevelj avatar Mar 09 '16 17:03 Vannevelj

Then again, the next rule says not to use Enum.IsDefined() so we'll have to look into what is the actual appropriate solution.

Vannevelj avatar Mar 09 '16 17:03 Vannevelj