fix: add OverloadResolutionPriority to collection expectations#916
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses overload-resolution issues in aweXpect’s collection expectations by deprioritizing the non-generic IEnumerable overloads, improving call-site behavior (notably around nullability/type inference) across target frameworks.
Changes:
- Added a polyfill for
System.Runtime.CompilerServices.OverloadResolutionPriorityAttributefor TFMs belownet10.0. - Applied
[OverloadResolutionPriority(-1)]to multipleIThat<IEnumerable>collection expectation overloads to prefer the genericIThat<IEnumerable<T>>APIs. - Added regression tests to ensure nullability/type-mismatch scenarios still compile and run without throwing.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/aweXpect.Tests/Collections/ThatEnumerable.IsNotEqualTo.Tests.cs | Adds regression tests for nullability/type-mismatch scenarios for IsNotEqualTo. |
| Tests/aweXpect.Tests/Collections/ThatEnumerable.IsEqualTo.Tests.cs | Adds regression tests for IsEqualTo nullability/type-mismatch scenarios (one added test currently appears inconsistent). |
| Source/aweXpect/That/Collections/ThatEnumerable.StartsWith.cs | Deprioritizes non-generic IEnumerable StartsWith overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.EndsWith.cs | Deprioritizes non-generic IEnumerable EndsWith overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsEqualTo.cs | Deprioritizes non-generic IEnumerable IsEqualTo/IsNotEqualTo overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsContainedIn.cs | Deprioritizes non-generic IEnumerable containment overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.Contains.cs | Deprioritizes non-generic IEnumerable Contains / DoesNotContain overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.All.cs | Deprioritizes non-generic IEnumerable quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.None.cs | Deprioritizes non-generic IEnumerable quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.MoreThan.cs | Deprioritizes non-generic IEnumerable count-quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.LessThan.cs | Deprioritizes non-generic IEnumerable count-quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.Exactly.cs | Deprioritizes non-generic IEnumerable count-quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.AtLeast.cs | Deprioritizes non-generic IEnumerable count-quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.AtMost.cs | Deprioritizes non-generic IEnumerable count-quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.Between.cs | Deprioritizes non-generic IEnumerable count-quantifier overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.HasCount.cs | Deprioritizes non-generic IEnumerable count-related overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.HasSingle.cs | Deprioritizes non-generic IEnumerable single-item overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.HasItem.cs | Deprioritizes non-generic IEnumerable HasItem predicate overload. |
| Source/aweXpect/That/Collections/ThatEnumerable.AreAllUnique.cs | Deprioritizes non-generic IEnumerable uniqueness overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsInAscendingOrder.cs | Deprioritizes non-generic IEnumerable ordering overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsInDescendingOrder.cs | Deprioritizes non-generic IEnumerable ordering overloads. |
| Source/aweXpect/That/Collections/ThatEnumerable.Elements.AreEqualTo.cs | Deprioritizes non-generic IEnumerable elements equality overload. |
| Source/aweXpect/Polyfills/OverloadResolutionPriorityAttribute.cs | Introduces OverloadResolutionPriorityAttribute polyfill for non-net10.0 TFMs. |
Test Results 23 files - 27 23 suites - 27 7m 31s ⏱️ - 1m 11s Results for commit 15b5a45. ± Comparison against base commit 2279ac3. This pull request removes 3110 and adds 3077 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsDetails
|
|
…o collection expectations (#916) by Valentin Breuß
…o collection expectations (#916) by Valentin Breuß
|
This is addressed in release v2.32.0. |



This PR addresses overload-resolution issues in aweXpect’s collection expectations by deprioritizing the non-generic
IEnumerableoverloads, improving call-site behavior (notably around nullability/type inference) across target frameworks.Key Changes:
System.Runtime.CompilerServices.OverloadResolutionPriorityAttributefor TFMs belownet10.0.[OverloadResolutionPriority(-1)]to multipleIThat<IEnumerable>collection expectation overloads to prefer the genericIThat<IEnumerable<T>>APIs.