I\'m currently writing some code for UnconstrainedMelody which has generic methods to do with enums.
Now, I have a static class with a bunch of methods which are
Apparently, Microsoft uses ArgumentException
for that, as demonstrated on example of Expression.Lambda<>, Enum.TryParse<> or Marshal.GetDelegateForFunctionPointer<> in Exceptions section. I couldn't find any example indicating otherwise, either (despite searching local reference source for TDelegate
and TEnum
).
So, I think it's safe to assume that at least in Microsoft code it's a common practice to use ArgumentException
for invalid generic type arguments aside from basic variable ones. Given that the exception description in docs doesn't discriminate between those, it's not too much of a stretch, either.
Hopefully it decides the question things once and for all.