The closest thing I can think of is checking the runtime in a static constructor. Like this:
static MyClass<IT>() { if(!typeof(IT).IsInterface) { throw new WhateverException("Oi, only use interfaces."); } }
Using a static constructor, we hope, means that it will work quickly, so the developer will detect the error earlier.
Also, the check will be performed only once for each type of IT, and not for each method call. So you wonβt get a performance hit.
source share