8000 New algorithm for matching invoked methods against expected methods by stakx · Pull Request #904 · devlooped/moq · GitHub
[go: up one dir, main page]

Skip to content

New algorithm for matching invoked methods against expected methods - #904

Merged
stakx merged 5 commits into
devlooped:masterfrom
stakx:method-binding
Aug 24, 2019
Merged

stakx merged 5 commits into
devlooped:masterfrom
stakx:method-binding

Conversation

@stakx
@stakx stakx commented Aug 24, 2019 •
Copy link
Copy Markdown
Contributor

This replaces the machinery that was responsible for determining whether an invoked method matches that encoded in a setup or verification expression. This previous machinery is very ad-hoc and performs a bunch of tests, such as method name equality, assignment compatibility, parameter list equality, and return type equality.

Instead of all that, why not let the runtime do that work by leveraging method.GetBaseDefinition(), then simply comparing MethodInfos? (There are some finer points, such as converting generic methods to their (open) generic method definitions; mapping interface methods to the concrete proxy type's methods that provide their implementations; special handling for delegate invocations; etc.)

Fixes #657. Supercedes #658. Fixes #903.

@stakx
stakx commented Sep 6, 2019
Copy link
Copy Markdown
Contributor Author

One thing that isn't explicitly mentioned above is that Moq no longer considers the return type as part of a method's signature like it used to (and that is generally a good thing). This can have some consequences in certain scenarios, see e.g. #922. Marking this PR as breaking change to make this more visible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

1 participant

0