title: Using IsAssignableFrom with 'open' generic types
body: <p>Using reflection, I'm attempting to find the set of types which inherit from a given base class.  It didn't take long to figure out for simple types, but I'm stumped when it comes to generics.</p>
  
  <p>For this piece of code, the first IsAssignableFrom returns true, but the second returns false.  And yet, the final assignment compiles just fine.</p>
  
  <pre><code>class class1 { }
  class class2 : class1 { }
  class generic1&lt;T&gt; { }
  class generic2&lt;T&gt; : generic1&lt;T&gt; { }
  
  class Program
  {
      static void Main(string[] args)
      {
          Type c1 = typeof(class1);
          Type c2 = typeof(class2);
          Console.WriteLine("c1.IsAssignableFrom(c2): {0}", c1.IsAssignableFrom(c2));
  
          Type g1 = typeof(generic1&lt;&gt;);
          Type g2 = typeof(generic2&lt;&gt;);
          Console.WriteLine("g1.IsAssignableFrom(g2): {0}", g1.IsAssignableFrom(g2));
  
          generic1&lt;class1&gt; cc = new generic2&lt;class1&gt;();
      }
  }
  </code></pre>
  
  <p>So how do I determine at run time whether one generic type definition is derived from another?</p>