Comments
1 comment
-
After digging for another hour I finally figured out at least one way to do it
. Funny enough figuring this out required opening Reflector in Reflector. So it turns out that each of the Generic arguments is of a derived IType interface type, and guessing ad-hoc which derived interface type it is and moving on from there works just fine (however inefficient that way of doing it may be). A Generic argument IType is always implementing one of these interfaces (all derived from IType):
IArrayType IDefaultConstructorConstraint IFunctionPointer IGenericArgument IOptionalModifier IPointerType IReferenceType IReferenceTypeConstraint IRequiredModifier ITypeReference IValueTypeConstraint
Use the 'as' construct or something similar to attempt casting to each type:IType argument; IArrayType arrayTypeArgument = argument as IArrayType;
If it fails the derived instance will be null so try to cast to next derived interface, otherwise if it is successful you found the right type. The Generic argument will always derive from one of the above interface types (and not more than one of the above).
Add comment
Please sign in to leave a comment.
One example of what I get is 'KeyValuePair<Object, Object>', but what I want is 'System.Collections.Generic.KeyValuePair<System.Object, System.Object>'. I would ask Lutz himself, but given that Reflector isn't on his plate anymore I don't really want to bother him with it. Though I hope he reads this post and helps me out