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

Match indexers used as arguments in setup expression eagerly #796

Merged
merged 3 commits into from
Apr 3, 2019

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Apr 3, 2019

This resolves #714.

It doesn't make sense for indexers to be matched lazily when other properties are being matched eagerly, so this will make Moq a little more consistent.

(While technically a small breaking change, making it anyway seems permissible because Moq has neglected indexers far too long and essentially left its behavior regarding them semi-unspecified.)

The test demonstrates that setup argument expressions using indexers
are apparently evaluated lazily (the `ArgumentOutOfRangeException` is
evidence that the iteration variable is being captured), which doesn't
make much sense since regular property accesses are evaluated eagerly.
They're probably more like properties than like regular methods.
@stakx stakx added this to the 4.11.0 milestone Apr 3, 2019
@stakx stakx merged commit b8aba6e into devlooped:master Apr 3, 2019
@stakx stakx deleted the match-indexer-args-eagerly branch April 3, 2019 20:02
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 this pull request may close these issues.

ArgumentOutOfRangeException when setup expression contains indexer access
1 participant