This project is read-only.

None of the Generic methods properly support contravarience


Attempting to pass in an enumeration instance assigned to a variable of type System.Enum will cause an ArgumentException to be thrown (in this case, a contravarience issue).


rmiesen wrote Aug 28, 2010 at 10:26 PM

This bug cannot be fixed at this time because C# 4.0 only allows the use of the covarience and contravarience constructs inside interface definitions. I have sent this issue upstream to Microsoft. You can follow the progress of this issue at

Leaving open.

rmiesen wrote Aug 28, 2010 at 10:28 PM

As a work-around, I have added Code Contracts to all methods that check to make sure that all parameters of type TEnum are a subclass of System.Enum. This makes it impossible to trip on the contravarience issue.

wrote Aug 29, 2010 at 4:26 AM

wrote Feb 2, 2013 at 3:19 AM