Closed JeffreySax closed 1 year ago
Template matching is rather complicated and what's there is what I've been able to figure out on my own when fixing cases as they're reported (see the change history in Reflection.cs). Microsoft wrote the original code and there isn't any documentation on how it works so it was mostly trial and error trying figure out where the necessary information resided and how to use it.
This looks to be a variation on a prior fix in ReflectionUtilities.ParametersMatch
(MyBaseClass<T, T> vs MyBaseClass<T, U>). At a guess, it probably isn't handling the type parameter check correctly in this case for some reason. I'll take a look at it this weekend if I get some time.
Given the following minimal library code:
In the SHFB output for this project, the second overload (with the
Func<U, T, T>
parameter) does not show up in the member list forB<T>
.I was able to track the problem down to MRefBuilder's
Member.GetTemplateMember
method which apparently returns the first overload as the template for the second overload.I don't understand the reasoning behind how this is done. In
MRefWriter.WriteTypeElements
, you first create aMemberDictionary
whose constructor adds members from ancestors that were not overloaded. Then it seems that for each member you just added, you go through some elaborate and error-prone process (inMember.GetTemplateMember
) to trace it back to its original definition.