Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
With
WithoutStrictOrdering(),IsEquivalentTocan compare only the first pair of a collection, so an assertion passes on wrong data. The comparer's ignore-order mode matches items by a key built from their settable simple properties. Items without setters, or items whose simple properties match and only a nested member differs, all get the same key. This PR pairs items by full equivalency instead.actualvsexpected[USD, EUR]vs[USD, UAH][USD, EUR]vs[EUR, USD]Moneyhas no setters, so both items get the keyMoney. On main the comparer then checks only the first pair:USDwithUSDin the first case,USDwithEURin the second.EURandUAHare never compared.A failure now points at the member that differs, for example
[1].Amount: expected "3", got "2", instead of the type name. Strings still compare character by character, andWithStrictOrdering()turns the new matching off again.Merge Danger
Reversibility: reversible
Blast Radius: user tests
Tests that use
WithoutStrictOrdering()and passed with differing items will fail after the upgrade; the changelog says so. Matching is now O(n²) item comparisons, fine for test-sized collections but slower on very large ones.