title: Implementing Generic Type Inference in C# reflectively
body: <p>I need to do some generic type inference for a scripting language implementation and I am wondering if I am missing some straightforward approach.  For the moment let me just ask about type structure and ignore bounds.  To illustrate, here is a deeply nested example:</p>
  
  <pre><code>T foo&lt;T&gt;( List&lt;List&lt;List&lt;T&gt;&gt;&gt; ) {...}
  </code></pre>
  
  <p>Now I want to test if I can pass an argument bar of type:</p>
  
  <pre><code>List&lt;List&lt;List&lt;string&gt;&gt;&gt;
  </code></pre>
  
  <p>to that method and later use MakeGenericMethod() with the discovered param type to reify and invoke it.  </p>
  
  <p>From what I can tell, even if I manage to construct an open generic type equivalent to the foo argument (i.e. <code>List&lt;List&lt;List&lt;T&gt;&gt;&gt;</code>), it will not test with isAssignable().  I'm not sure if there is some trick to checking the assignability of open generic types or if it's simply not supported.  I guess if I have to I can do this directly.</p>
  
  <p>On the reification - It looks like I'm going to have to recursively crawl through the types to find the argument type that matches the location of the type parameter and then do the substitution... I had been hoping that I might be able to somehow construct the invocable method from the argument type more directly, but I'm not seeing how to do this.</p>
  
  <p>Any advice from someone who's already gone through this madness would be appreciated :)</p>
  
  <p>thanks,
  Pat Niemeyer</p>