I’m really feeling the pain of the simplicity of C#’s generics system. I have found some situations where I could introduce more type safety by being able to refer to a type parameter on the left hand side of a generic constraint which is not a parameter of the immediate definition, but rather that of an enclosing class. For an example of what I mean, see this:

public interface IMarker<T> { }

public class TestList<T>
{
    public void Add<S>(S item) where T : IMarker<S> { }
}

public class Program
{
    public static void Main()
    {
        new TestList<IMarker<int>>().Add<int>(2); // Yep!
        new TestList<IMarker<string>>().Add<int>(2); // Nope!
    }
}

Alas, in their wisdom Microsoft have decided this is too advanced a feature for the unwashed masses to get their hands on, so I will have to struggle forward with runtime checks..