You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #732 I brought back the requirement that [Matcher] attributes must be placed on all matchers, including custom ones. This was done to fix a bug and to improve runtime efficiency (Moq being able to statically analyse argument expressions instead of having to compile & execute them.)
This was a good thought, but it also makes it impossible to put argument matchers in local variables to abbreviate a long query expression with repeated matchers; e.g.:
-Func<int> any = It.IsAny<int>;-mock.Setup(m => m.Method(any(), any(), any(), ...);-// ^^^^^ ^^^^^ ^^^^^-// Those will not get recognized as being equivalent to `It.IsAny<int>()` because `any`-// doesn't carry a `[Matcher]` attribute (how could it?!) and therefore won't be executed.-// Instead, Moq will interpret those as the literal value returned by `It.IsAny<int>()`.
Edit: I was mistaken, the use case shown above actually doesn't work in previous versions, either, so it is by itself no reason to bring MatcherAttribute back.
With all the current PRs, it might become possible to fix the bug from #725 in a different way than was done in #732. If so, runtime performance alone perhaps isn't a good enough reason to reintroduce the [Matcher] attribute as mandatory; in that case, #732 should be reverted and #725 reopened to be solved in a different way.
The text was updated successfully, but these errors were encountered:
More a note to myself than an actual issue:
In #732 I brought back the requirement that
[Matcher]
attributes must be placed on all matchers, including custom ones. This was done to fix a bug and to improve runtime efficiency (Moq being able to statically analyse argument expressions instead of having to compile & execute them.)This was a good thought, but it also makes it impossible to put argument matchers in local variables to abbreviate a long query expression with repeated matchers; e.g.:Edit: I was mistaken, the use case shown above actually doesn't work in previous versions, either, so it is by itself no reason to bring
MatcherAttribute
back.With all the current PRs, it might become possible to fix the bug from #725 in a different way than was done in #732. If so, runtime performance alone perhaps isn't a good enough reason to reintroduce the
[Matcher]
attribute as mandatory; in that case, #732 should be reverted and #725 reopened to be solved in a different way.The text was updated successfully, but these errors were encountered: