GetXmlDocsSummary fails on methods with Expression parameters whose delegate returns a generic type
chris20 opened this issue · comments
Using .NET 4.8 with Namotion.Reflection v2.0.3, if I have a method with a signature like the following:
public void TestMethod(Expression<Func<TModel>> expr)
and then call GetXMLDocsSummary()
on a MethodInfo
instance for it, the call will return an empty string even when there is an appropriate entry in the XML doc file. However if I change the return of the delegate to a concrete type (e.g. Func<string>>
) the summary is returned without issue.
Stepping into the code I can see that GetMemberElementName()
is throwing a "Method may only be called on a Type for which Type.IsGenericParameter is true." exception. This occurs at the point where the code iterates the generic type arguments and references GenericParameterPosition
. The type in question (the Func
) has IsGenericParameter
as false (however its GenericTypeArguments
has a member with IsGenericParameter
true and a valid GenericParameterPosition
- perhaps an additional level of indirection is needed?)
Test case code (based on the Namotion.Reflection.Demo sample) is attached.