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 method matching algorithm introduces behavioral change wrt return types #906

Closed
stakx opened this issue Aug 25, 2019 · 2 comments · Fixed by #907
Closed

New method matching algorithm introduces behavioral change wrt return types #906

stakx opened this issue Aug 25, 2019 · 2 comments · Fixed by #907
Assignees
Milestone

Comments

@stakx
Copy link
Contributor

stakx commented Aug 25, 2019

Moq used to match return types of the invoked vs. expected method precisely:

https://github.com/moq/moq4/blob/271a12abdaa6edbe042e20d9984b8de64a4dad54/src/Moq/InvocationShape.cs#L108-L111

However, that is now no longer being done (as that check was removed in 1c1a934#diff-75ebcf2b80e95adb61d9a8500dfeb229L108-L111).

This is a task item for myself to figure out whether the old behavior should be brought back. I'll need to research old issues where we were already talking about this, and see what those use cases were, and judge how they will be affected by the new behavior.

Also, a changelog entry should be added if the new behavior stays.

@stakx stakx added this to the 4.13.0 milestone Aug 25, 2019
@stakx stakx self-assigned this Aug 25, 2019
@stakx
Copy link
Contributor Author

stakx commented Aug 25, 2019

In #552 (comment), I wrote:

When Moq looks for a setup matching the invocation, the invoked method's signature is compared with that of the set up method's [...]. Return types must match exactly[.]

And later:

[R]elaxing Moq's method matching logic would be wrong[.]

I can no longer remember what made me think so. I also haven't yet been able to think of a use case where that matching rule would be actually helpful—which is probably because method resolution in C# ignores return types completely. Moq should perhaps follow C#'s lead, thereby removing issues people have faced with setting up generic methods (see e.g. #343 (comment), #552 (comment), possibly #656).

@stakx
Copy link
Contributor Author

stakx commented Aug 25, 2019

Closed by #907.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant