Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New algorithm for matching invoked methods against expected methods #904

Merged
merged 5 commits into from
Aug 24, 2019

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Aug 24, 2019

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
Copy link
Contributor Author

stakx commented Sep 6, 2019

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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant