[rdnzl-devel] Generic Methods

Iver Odin Kvello iverodin at gmail.com
Tue Nov 1 17:33:40 UTC 2011


> Some years back, Iver Kvello developed a RDNZL patch for Generic Types (in
> the thread titled “Patch for generic types in RDZNL”).  However in his
> offering he notes that Generic Methods are particularly problematic and are
> not covered by the patch.

As I recall, the problem is that you cannot use GetMethod in the
general case with overloaded methods and so forth - you actually have
to iterate over the methods of the function, grabbing the generic
types and try to find your (most specific match) the hard way.
You get no help from the runtime here. In particuluar,  if you want to
find "what C# would have called" this is going to be hard.

This is an old reference describing what one must do in the simple
case (such as for Load<T>):

http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/10/invoking-generic-methods-with-reflection.aspx

This even older describes the issue with GetMethod  in the general case:

http://blogs.msdn.com/b/yirutang/archive/2005/09/14/466280.aspx

More of the same:

http://stackoverflow.com/questions/5934432/how-to-getmethod-on-multiple-function-definitions-where-match-has-generic-para

This last has a 'version' of GetMethod which is supposed to work:

http://stackoverflow.com/questions/4035719/getmethod-for-generic-method

For the simpler cases, you could use reflection directly from RDNZL to
find the methods you need and invoke them; it's possible the last
reference could be compiled into an assembly and used directly (I
haven't tried.)

Unfortunately, I haven't had the opportunity to work with RDNZL for
quite some time, so I'm unable to provide further help.

Regards,
Iver




More information about the rdnzl-devel mailing list