Repository navigation
fix: fail instead of silently succeeding when equivalency finds no members - #1051
Merged
Merged
Conversation
…mbers `IsEquivalentTo` walked the public fields and properties of the expected type. When that walk yielded no members at all and both sides had the same type, the comparison returned `true` without verifying anything, so the assertion passed unconditionally. Zero members is now treated as an error, consistent with the existing behaviour for mismatching types, which already reported a failure in that case. Throwing rather than failing keeps the result correct under negation: a comparison that verifies nothing is neither equivalent nor not equivalent. The guard is skipped when the caller excluded every member explicitly via `IncludeMembers.None` for both fields and properties, since comparing nothing is then an explicit choice. This also covers types whose members were removed by the trimmer, which is the failure mode that makes equivalency unsafe under Native AOT. `Generic_For_IgnoringMember_ShouldSetOptionForType` relied on the old behaviour: `MemberToIgnore.ByName` keeps its state in a private field, so the element comparison verified nothing and the test passed even with a completely different expected member name. It now uses the same `It.Is<MemberToIgnore[]>().That.HasCount(1)` form as the four sibling tests in that file; the member name itself remains covered by the `ToString()` assertion below it. Tests live in `aweXpect.Core.Tests` because it references `aweXpect.Core` by project in every configuration, whereas `aweXpect.Tests` compiles against the released `aweXpect.Core` package outside `Debug` and could not observe this change. Front-end `IsEquivalentTo` tests can follow once Core is released. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vbreuss
enabled auto-merge (squash)
September 12, 2026 18:25
|
Contributor
Test Results 23 files - 27 23 suites - 27 11m 17s ⏱️ +18s Results for commit b66031a. ± Comparison against base commit ae28ac8. This pull request removes 3229 and adds 3195 tests. Note that renamed tests count towards both. |
github-actions Bot
added a commit
that referenced
this pull request
Sep 12, 2026
…g when equivalency finds no members (#1051) by Valentin Breuß
github-actions Bot
added a commit
that referenced
this pull request
Sep 12, 2026
…g when equivalency finds no members (#1051) by Valentin Breuß
Contributor
🚀 Benchmark ResultsDetails
|
Contributor
👽 Mutation ResultsaweXpectDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is 86.67%Coverage Thresholds: high:80 low:60 break:0 |
This was referenced Oct 12, 2026
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.



IsEquivalentTowalked the public fields and properties of the expected type. When that walk yielded no members at all and both sides had the same type, the comparison returnedtruewithout verifying anything, so the assertion passed unconditionally.Zero members is now treated as an error, consistent with the existing behaviour for mismatching types, which already reported a failure in that case. Throwing rather than failing keeps the result correct under negation: a comparison that verifies nothing is neither equivalent nor not equivalent.
The guard is skipped when the caller excluded every member explicitly via
IncludeMembers.Nonefor both fields and properties, since comparing nothing is then an explicit choice.Generic_For_IgnoringMember_ShouldSetOptionForTyperelied on the old behaviour:MemberToIgnore.ByNamekeeps its state in a private field, so the element comparison verified nothing and the test passed even with a completely different expected member name. It now uses the sameIt.Is<MemberToIgnore[]>().That.HasCount(1)form as the four sibling tests in that file; the member name itself remains covered by theToString()assertion below it.Tests live in
aweXpect.Core.Testsbecause it referencesaweXpect.Coreby project in every configuration, whereasaweXpect.Testscompiles against the releasedaweXpect.Corepackage outsideDebugand could not observe this change. Front-endIsEquivalentTotests can follow once Core is released.