castleproject / Core

Castle Core, including Castle DynamicProxy, Logging Services and DictionaryAdapter
http://www.castleproject.org/
Other
2.2k stars 467 forks source link

Improve support for covariant returns (where generic types are involved) #643

Closed stakx closed 1 year ago

stakx commented 1 year ago

Fixes #632.

It turns out that we only added support for non-generic covariant return types in #619; however there are two additional cases that we need to support, too:

(I'm counting those as two distinct cases due to the code structure found inside MethodSignatureComparer.EqualSignatureTypes, which is the method that needs to be augmented.)

stakx commented 1 year ago

@jonorossi, I'd appreciate your input on one particular detail here. In principle, this PR is an extension of #619, whose code patterns it duplicates for the most part. After this PR, the IsCovariantReturnTypes check will happen in three code branches inside MethodSignatureComparer.EqualSignatureTypes, instead of just in one. I've tried to keep those checks out of the "hot" code paths as much as possible in order to not affect runtime performance. If you have any suggestions how they could be relegated to run even less frequently, I'd be interested to hear them.