Skip to content

fix: add OverloadResolutionPriority to collection expectations#916

Merged
vbreuss merged 2 commits into
mainfrom
topic/add-overloadresolutionpriority
Apr 1, 2026
Merged

fix: add OverloadResolutionPriority to collection expectations#916
vbreuss merged 2 commits into
mainfrom
topic/add-overloadresolutionpriority

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Apr 1, 2026

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.

Key Changes:

  • Added a polyfill for System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute for TFMs below net10.0.
  • Applied [OverloadResolutionPriority(-1)] to multiple IThat<IEnumerable> collection expectation overloads to prefer the generic IThat<IEnumerable<T>> APIs.
  • Added regression tests to ensure nullability/type-mismatch scenarios still compile and run without throwing.

@vbreuss vbreuss self-assigned this Apr 1, 2026
@vbreuss vbreuss added the bug Something isn't working label Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 04:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.OverloadResolutionPriorityAttribute for TFMs below net10.0.
  • Applied [OverloadResolutionPriority(-1)] to multiple IThat<IEnumerable> collection expectation overloads to prefer the generic IThat<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.

Comment thread Tests/aweXpect.Tests/Collections/ThatEnumerable.IsEqualTo.Tests.cs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

Test Results

     23 files   - 27       23 suites   - 27   7m 31s ⏱️ - 1m 11s
 19 514 tests  - 33   19 513 ✅  - 33  1 💤 ±0  0 ❌ ±0 
101 024 runs   - 57  101 023 ✅  - 57  1 💤 ±0  0 ❌ ±0 

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.
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message07d688b0-f637-47ae-87cb-ad6e6c130ce0")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message1aa3481b-1004-412e-8285-251a2a3ce2eb")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message1ce01f3e-6e0e-4537-8e77-225191f5ad8b")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message9088430f-9800-42e8-b639-c19924fba280")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messageca07a820-655d-4648-9dc8-4c0dcc064009")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messaged78ad371-90d1-40fb-beb2-e90503cd0fa0")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message3f95bc7f-0fb2-4692-a9c2-c9d43bc6076a")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message50afbef4-1883-428b-baff-8fb4f9bcf464")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message62ab41e7-5556-46e3-952a-67783c698efa")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message81e12452-82de-479c-92ad-193e7693447c")
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message37714208-0b23-4e92-93ee-db24d3eea54c")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message79b7d288-b73e-48af-ac40-ada80a68ff22")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagea3cb1527-fbcf-437b-affb-46f224a06210")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messageb8a2cf17-fbb4-4301-aae6-fb32ec28125c")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagec3a2c252-efc8-49bf-beed-8fc95430af20")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagee04b7252-525a-491f-8a8b-cf1fce7ae73d")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message29c4d9b2-57a4-416f-b15d-d1f5fe049328")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message3c1d7113-bee6-465e-b6f1-16e0a2130efc")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message4b232d87-75cd-4565-9494-8f128f64fab6")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message9d2cf0dd-d627-4335-9bbd-39d1321d1edb")
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 3.24GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.201
[Host] : .NET 8.0.25 (8.0.25, 8.0.2526.11203), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 254.4 ns 2.32 ns 2.06 ns 0.0415 - 696 B
Bool_FluentAssertions 235.9 ns 1.30 ns 1.01 ns 0.0567 - 952 B
Equivalency_aweXpect 346,022.8 ns 2,498.12 ns 2,336.75 ns 20.0195 0.4883 335444 B
Equivalency_FluentAssertions 2,757,757.2 ns 24,544.80 ns 21,758.32 ns 285.1563 46.8750 4804906 B
Int_GreaterThan_aweXpect 254.1 ns 1.20 ns 1.06 ns 0.0482 - 808 B
Int_GreaterThan_FluentAssertions 332.3 ns 1.77 ns 1.66 ns 0.0730 - 1224 B
ItemsCount_AtLeast_aweXpect 502.9 ns 5.61 ns 5.25 ns 0.0811 - 1360 B
ItemsCount_AtLeast_FluentAssertions 544.0 ns 18.02 ns 16.86 ns 0.1192 - 2008 B
String_aweXpect 472.9 ns 1.76 ns 1.47 ns 0.0668 - 1128 B
String_FluentAssertions 1,250.0 ns 4.28 ns 3.79 ns 0.2346 - 3944 B
StringArray_aweXpect 1,886.6 ns 39.08 ns 36.56 ns 0.1564 - 2624 B
StringArray_FluentAssertions 1,385.6 ns 41.85 ns 39.15 ns 0.2480 - 4152 B
StringArrayInAnyOrder_aweXpect 2,508.2 ns 6.81 ns 6.37 ns 0.1678 - 2816 B
StringArrayInAnyOrder_FluentAssertions 88,222.4 ns 491.63 ns 435.82 ns 3.4180 - 58598 B

@vbreuss vbreuss enabled auto-merge (squash) April 1, 2026 05:21
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 1, 2026

@vbreuss vbreuss merged commit 944d5c8 into main Apr 1, 2026
14 checks passed
@vbreuss vbreuss deleted the topic/add-overloadresolutionpriority branch April 1, 2026 05:29
github-actions Bot added a commit that referenced this pull request Apr 1, 2026
…o collection expectations (#916) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Apr 1, 2026
…o collection expectations (#916) by Valentin Breuß
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.32.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants