Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Make guard against unmatchable matchers less strict to enable user-based wildcard matching #1202
Make guard against unmatchable matchers less strict to enable user-based wildcard matching #1202
Changes from all commits
a251966
24b8d8a
f315474
2745506
308d711
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stakx should I switch these back to using
It.IsAny<T>()
? Or should I rely on implicit conversion functions like this never being called? Just thinking about making a source generator for people to use and if possible, I don't want to rely on behavior that may be changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, keep these as
default
. You should only have one call to a matcher per parameter. If you have more than that, you may confuse theSetupSet
/VerifySet
delegate reconstruction machinery (ActionObserver
), which attempts to distribute recorded matchers over the available parameters.Note also this comment in
ActionObserver
, which states Moq's general assumption of matchers returningdefault(T)
:https://github.com/moq/moq4/blob/abc05532d7350c5431a5d89a91b667d569fa4d65/src/Moq/ActionObserver.cs#L127-L128
Meaning, if you want
SetupSet
andVerifySet
to interact correctly with your_
shorthand, it should probably returndefault
/null
instead ofnew AnyValue()
.