-
Couldn't load subscription status.
- Fork 5.2k
Closed
Labels
api-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementationarea-System.Runtime
Milestone
Description
So rather than doing this:
string DoTheThing(MyEnum argument)
{
if (!Enum.IsDefined(typeof(MyEnum), argument))
{
Log.Warn(...);
return String.Empty;
}
return argument.ToString();
}You can do this:
string DoTheThing(MyEnum argument)
{
if (!argument.IsDefined())
{
Log.Warn(...);
return String.Empty;
}
return argument.ToString();
}Enum.IsDefined(typeof(MyEnum), argument) is also quite slow as it needs to do lots of conversion checks etc; whereas if you already have the enum these don't need to be done.
Suggested change dotnet/coreclr#6687
/cc @terrajobst
jnm2, jamesqo and iam3yal
Metadata
Metadata
Assignees
Labels
api-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementationarea-System.Runtime