fix: update parameters to use IThatSubject in callbacks#946
Conversation
There was a problem hiding this comment.
Pull request overview
Updates aweXpect’s “drill-in” callback signatures to accept IThatSubject<T> (instead of IThat<T>) so callbacks can perform nested .Is<TType>() type assertions, and locks the behavior in with regression tests and updated public API baselines.
Changes:
- Switched multiple callback parameters (e.g.,
Whose/Which/For/CompliesWith, exception inner-exception callbacks, and per-item collection match callbacks) fromAction<IThat<...>>toAction<IThatSubject<...>>. - Updated internal plumbing (e.g., expectation item wrappers) to invoke callbacks with
ThatSubject<T>to enable nested type checks. - Added a dedicated regression test suite and updated PublicApiGenerator “Expected” baseline files.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/aweXpect.Tests/IThatSubjectCallbacks.Tests.cs | Adds regression tests ensuring callbacks allow nested .Is<TType>() usage. |
| Tests/aweXpect.Core.Api.Tests/Expected/aweXpect.Core_netstandard2.0.txt | Updates core public API baseline for callback signature changes. |
| Tests/aweXpect.Core.Api.Tests/Expected/aweXpect.Core_net8.0.txt | Updates core public API baseline for callback signature changes. |
| Tests/aweXpect.Core.Api.Tests/Expected/aweXpect.Core_net10.0.txt | Updates core public API baseline for callback signature changes. |
| Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt | Updates public API baseline for callback signature changes in aweXpect. |
| Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt | Updates public API baseline for callback signature changes in aweXpect. |
| Tests/aweXpect.Api.Tests/Expected/aweXpect_net10.0.txt | Updates public API baseline for callback signature changes in aweXpect. |
| Source/aweXpect/That/ThatGeneric.For.cs | Changes For(...) callback to Action<IThatSubject<TMember?>>. |
| Source/aweXpect/That/ThatGeneric.CompliesWith.cs | Changes CompliesWith/DoesNotComplyWith callbacks to IThatSubject<T>. |
| Source/aweXpect/That/Exceptions/ThatException.HasRecursiveInnerExceptions.cs | Changes recursive-inner-exception callback to IThatSubject<IEnumerable<Exception>>. |
| Source/aweXpect/That/Exceptions/ThatException.HasInnerException.cs | Changes inner-exception callback to IThatSubject<Exception?>. |
| Source/aweXpect/That/Exceptions/ThatException.HasInner.cs | Changes HasInner(...) callbacks to IThatSubject<...>. |
| Source/aweXpect/That/Delegates/ThatDelegateThrows.WithRecursiveInnerExceptions.cs | Changes delegate recursive-inner-exception callback to IThatSubject<IEnumerable<Exception>>. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsEqualTo.cs | Changes per-item expected callbacks to Action<IThatSubject<TItem?>>. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsContainedIn.cs | Changes per-item expected callbacks to Action<IThatSubject<TItem?>>. |
| Source/aweXpect/That/Collections/ThatEnumerable.HasItemThat.cs | Changes HasItemThat callback to Action<IThatSubject<TItem>>. |
| Source/aweXpect/That/Collections/ThatEnumerable.Elements.ComplyWith.cs | Changes Elements.*.ComplyWith callbacks to IThatSubject<...>. |
| Source/aweXpect/That/Collections/ThatEnumerable.cs | Updates internal constraint types for per-item expectation callbacks. |
| Source/aweXpect/That/Collections/ThatEnumerable.Contains.cs | Changes per-item expected/unexpected callbacks to Action<IThatSubject<TItem?>>. |
| Source/aweXpect/That/Collections/ThatAsyncEnumerable.IsEqualTo.cs | Changes per-item expected callbacks to Action<IThatSubject<TItem?>>. |
| Source/aweXpect/That/Collections/ThatAsyncEnumerable.IsContainedIn.cs | Changes per-item expected callbacks to Action<IThatSubject<TItem?>>. |
| Source/aweXpect/That/Collections/ThatAsyncEnumerable.HasItemThat.cs | Changes HasItemThat callback to Action<IThatSubject<TItem>>. |
| Source/aweXpect/That/Collections/ThatAsyncEnumerable.Elements.ComplyWith.cs | Changes Elements.*.ComplyWith callbacks to IThatSubject<...>. |
| Source/aweXpect/That/Collections/ThatAsyncEnumerable.cs | Updates internal constraint types for per-item expectation callbacks. |
| Source/aweXpect/That/Collections/ThatAsyncEnumerable.Contains.cs | Changes per-item expected/unexpected callbacks to Action<IThatSubject<TItem?>>. |
| Source/aweXpect.Core/Results/AndOrWhoseResult.cs | Changes Whose/AndWhose callback types to Action<IThatSubject<TMember?>>. |
| Source/aweXpect.Core/Results/AndOrWhichResult.cs | Changes Which/AndWhich callback types to Action<IThatSubject<TMember?>>. |
| Source/aweXpect.Core/Options/CollectionMatchOptions.cs | Updates ExpectationItem to accept/invoke Action<IThatSubject<TItem?>>. |
| Source/aweXpect.Core/Delegates/ThatDelegateThrows.WithInnerException.cs | Changes inner-exception callback type to Action<IThatSubject<Exception?>>. |
| Source/aweXpect.Core/Delegates/ThatDelegateThrows.WithInner.cs | Changes WithInner(...) callback types to Action<IThatSubject<...>>. |
| Source/aweXpect.Core/Delegates/ThatDelegateThrows.Whose.cs | Changes Whose(...) callback type to Action<IThatSubject<TMember?>>. |
Test Results 7 files - 43 7 suites - 43 45s ⏱️ - 7m 58s Results for commit 3104d2f. ± Comparison against base commit 3f417e7. This pull request removes 18639 and adds 101 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
|
This is addressed in release v2.33.0. |


This pull request primarily refactors the codebase to consistently use the
IThatSubject<T>interface instead ofIThat<T>for expectation actions across collection and exception assertion APIs. This change improves type safety and standardizes the way expectations are expressed throughout the library. Additionally, a build configuration change restricts the build scope to core components only.API Refactoring: Expectation Actions
Updated all collection assertion methods (e.g.,
ComplyWith,HasItemThat,Contains,IsEqualTo, etc.) to acceptAction<IThatSubject<T>>orAction<IThatSubject<T?>>instead ofAction<IThat<T>>orAction<IThat<T?>>. This affects both synchronous (IEnumerable<T>) and asynchronous (IAsyncEnumerable<T>) collection APIs.Changed exception assertion methods (e.g.,
WithInner,WithInnerException,Whose,Which, etc.) to require expectation actions usingIThatSubject<T>instead ofIThat<T>.Updated internal classes and constructors to use
IThatSubject<T>for expectation actions, ensuring consistency throughout the implementation.Build Configuration
Build.csfromBuildScope.DefaulttoBuildScope.CoreOnly, limiting the build process to core components.