fix: support nested Member after IsTypeOf - #6540
Merged
thomhurst merged 1 commit intoAug 7, 2026
Merged
Conversation
Closed
1 task
Greptile SummaryThe PR fixes nested
Confidence Score: 5/5The PR appears safe to merge; the nested result preserves the complete assertion chain and the tests cover both successful and failing execution paths. The new branch extracts the assertion that
|
| Filename | Overview |
|---|---|
| src/TUnit.Assertions/Conditions/MemberAssertion.cs | Adds an internal interface that exposes the fully composed erased assertion already held by a member result. |
| src/TUnit.Assertions/Extensions/AssertionExtensions.cs | Recognizes nested member results in the object-returning fallback while preserving reflection handling and diagnostics for other values. |
| tests/TUnit.Assertions.Tests/Bugs/Issue6528Tests.cs | Covers the successful chain and independently verifies failures from both the nested value assertion and preceding type assertion. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Outer Member lambda] --> B[IsTypeOf InnerEx]
B --> C[And nested Member]
C --> D[MemberAssertionResult InnerEx]
D --> E[ITypeErasedMemberAssertion]
E --> F[Already-composed Assertion object]
F --> G[Outer BuildMemberResult]
G --> H[Execute type and nested member checks]
Reviews (1): Last reviewed commit: "fix: support nested Member after IsTypeO..." | Re-trigger Greptile
Owner
|
Thanks! |
This was referenced Aug 7, 2026
Closed
This was referenced Aug 10, 2026
Open
github-actions Bot
pushed a commit
to BenjaminMichaelis/TrxLib
that referenced
this pull request
Aug 10, 2026
Updated [TUnit](https://github.com/thomhurst/TUnit) from 1.63.0 to 1.64.6. <details> <summary>Release notes</summary> _Sourced from [TUnit's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.64.6 <!-- Release notes generated using configuration in .github/release.yml at v1.64.6 --> ## What's Changed ### Other Changes * Switch NuGet publishing to trusted publishing by @thomhurst in thomhurst/TUnit#6573 * Expose results directory through TestContext by @thomhurst in thomhurst/TUnit#6575 * Fix outcome timeline overflow in HTML reports by @thomhurst in thomhurst/TUnit#6574 ### Dependencies * chore(deps): update tunit to 1.64.0 by @thomhurst in thomhurst/TUnit#6570 **Full Changelog**: thomhurst/TUnit@v1.64.0...v1.64.6 ## 1.64.0 <!-- Release notes generated using configuration in .github/release.yml at v1.64.0 --> ## What's Changed ### Other Changes * Honor cancellation tokens linked by custom test executors by @thomhurst in thomhurst/TUnit#6565 * Fix linked cancellation from before-test hooks by @thomhurst in thomhurst/TUnit#6568 * Add per-test execution cancellation by @thomhurst in thomhurst/TUnit#6569 ### Dependencies * chore(deps): update tunit to 1.63.25 by @thomhurst in thomhurst/TUnit#6559 * chore(deps): update dependency serialize-javascript to v7.1.0 by @thomhurst in thomhurst/TUnit#6561 * chore(deps): update dependency nsubstitute to 6.1.0 by @thomhurst in thomhurst/TUnit#6564 * chore(deps): bump mermaid from 11.15.0 to 11.16.1 in /docs by @dependabot[bot] in thomhurst/TUnit#6563 * chore(deps): bump nanoid from 3.3.16 to 3.3.18 in /docs by @dependabot[bot] in thomhurst/TUnit#6562 **Full Changelog**: thomhurst/TUnit@v1.63.25...v1.64.0 ## 1.63.25 <!-- Release notes generated using configuration in .github/release.yml at v1.63.25 --> ## What's Changed ### Other Changes * Fix Mermaid label contrast in dark mode by @thomhurst in thomhurst/TUnit#6531 * Enhance matrix tests documentation by @koryphaee in thomhurst/TUnit#6537 * fix: support nested Member after IsTypeOf by @mvanhorn in thomhurst/TUnit#6540 * docs: Add documentation for TestContext.Parameters by @thomhurst with @Copilot in thomhurst/TUnit#6558 * fix: run event receivers on injected properties by @thomhurst in thomhurst/TUnit#6556 ### Dependencies * chore(deps): update tunit to 1.63.0 by @thomhurst in thomhurst/TUnit#6526 * chore(deps): update dependency stackexchange.redis to 3.1.0 by @thomhurst in thomhurst/TUnit#6529 * chore(deps): update verify to 31.28.0 by @thomhurst in thomhurst/TUnit#6532 * chore(deps): update dependency stackexchange.redis to 3.1.3 by @thomhurst in thomhurst/TUnit#6541 * chore(deps): update dependency dompurify to v3.4.13 by @thomhurst in thomhurst/TUnit#6542 * chore(deps): update dependency rabbitmq.client to 7.2.2 by @thomhurst in thomhurst/TUnit#6546 * chore(deps): update dependency polyfill to 11.0.2 by @thomhurst in thomhurst/TUnit#6549 * chore(deps): update dependency polyfill to 11.0.2 by @thomhurst in thomhurst/TUnit#6548 * chore(deps): bump fast-uri from 3.1.4 to 3.1.5 in /docs by @dependabot[bot] in thomhurst/TUnit#6545 * chore(deps): bump postcss from 8.5.22 to 8.5.25 in /docs by @dependabot[bot] in thomhurst/TUnit#6547 * chore(deps): update dependency stackexchange.redis to 3.1.11 by @thomhurst in thomhurst/TUnit#6550 * chore(deps): update dependency stackexchange.redis to 3.1.13 by @thomhurst in thomhurst/TUnit#6552 ## New Contributors * @koryphaee made their first contribution in thomhurst/TUnit#6537 **Full Changelog**: thomhurst/TUnit@v1.63.0...v1.63.25 Commits viewable in [compare view](thomhurst/TUnit@v1.63.0...v1.64.6). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Aug 10, 2026
Open
Merged
github-actions Bot
pushed a commit
to IntelliTect/CodingGuidelines
that referenced
this pull request
Aug 10, 2026
Updated [TUnit.Core](https://github.com/thomhurst/TUnit) from 1.63.0 to 1.64.6. <details> <summary>Release notes</summary> _Sourced from [TUnit.Core's releases](https://github.com/thomhurst/TUnit/releases)._ ## 1.64.6 <!-- Release notes generated using configuration in .github/release.yml at v1.64.6 --> ## What's Changed ### Other Changes * Switch NuGet publishing to trusted publishing by @thomhurst in thomhurst/TUnit#6573 * Expose results directory through TestContext by @thomhurst in thomhurst/TUnit#6575 * Fix outcome timeline overflow in HTML reports by @thomhurst in thomhurst/TUnit#6574 ### Dependencies * chore(deps): update tunit to 1.64.0 by @thomhurst in thomhurst/TUnit#6570 **Full Changelog**: thomhurst/TUnit@v1.64.0...v1.64.6 ## 1.64.0 <!-- Release notes generated using configuration in .github/release.yml at v1.64.0 --> ## What's Changed ### Other Changes * Honor cancellation tokens linked by custom test executors by @thomhurst in thomhurst/TUnit#6565 * Fix linked cancellation from before-test hooks by @thomhurst in thomhurst/TUnit#6568 * Add per-test execution cancellation by @thomhurst in thomhurst/TUnit#6569 ### Dependencies * chore(deps): update tunit to 1.63.25 by @thomhurst in thomhurst/TUnit#6559 * chore(deps): update dependency serialize-javascript to v7.1.0 by @thomhurst in thomhurst/TUnit#6561 * chore(deps): update dependency nsubstitute to 6.1.0 by @thomhurst in thomhurst/TUnit#6564 * chore(deps): bump mermaid from 11.15.0 to 11.16.1 in /docs by @dependabot[bot] in thomhurst/TUnit#6563 * chore(deps): bump nanoid from 3.3.16 to 3.3.18 in /docs by @dependabot[bot] in thomhurst/TUnit#6562 **Full Changelog**: thomhurst/TUnit@v1.63.25...v1.64.0 ## 1.63.25 <!-- Release notes generated using configuration in .github/release.yml at v1.63.25 --> ## What's Changed ### Other Changes * Fix Mermaid label contrast in dark mode by @thomhurst in thomhurst/TUnit#6531 * Enhance matrix tests documentation by @koryphaee in thomhurst/TUnit#6537 * fix: support nested Member after IsTypeOf by @mvanhorn in thomhurst/TUnit#6540 * docs: Add documentation for TestContext.Parameters by @thomhurst with @Copilot in thomhurst/TUnit#6558 * fix: run event receivers on injected properties by @thomhurst in thomhurst/TUnit#6556 ### Dependencies * chore(deps): update tunit to 1.63.0 by @thomhurst in thomhurst/TUnit#6526 * chore(deps): update dependency stackexchange.redis to 3.1.0 by @thomhurst in thomhurst/TUnit#6529 * chore(deps): update verify to 31.28.0 by @thomhurst in thomhurst/TUnit#6532 * chore(deps): update dependency stackexchange.redis to 3.1.3 by @thomhurst in thomhurst/TUnit#6541 * chore(deps): update dependency dompurify to v3.4.13 by @thomhurst in thomhurst/TUnit#6542 * chore(deps): update dependency rabbitmq.client to 7.2.2 by @thomhurst in thomhurst/TUnit#6546 * chore(deps): update dependency polyfill to 11.0.2 by @thomhurst in thomhurst/TUnit#6549 * chore(deps): update dependency polyfill to 11.0.2 by @thomhurst in thomhurst/TUnit#6548 * chore(deps): bump fast-uri from 3.1.4 to 3.1.5 in /docs by @dependabot[bot] in thomhurst/TUnit#6545 * chore(deps): bump postcss from 8.5.22 to 8.5.25 in /docs by @dependabot[bot] in thomhurst/TUnit#6547 * chore(deps): update dependency stackexchange.redis to 3.1.11 by @thomhurst in thomhurst/TUnit#6550 * chore(deps): update dependency stackexchange.redis to 3.1.13 by @thomhurst in thomhurst/TUnit#6552 ## New Contributors * @koryphaee made their first contribution in thomhurst/TUnit#6537 **Full Changelog**: thomhurst/TUnit@v1.63.0...v1.63.25 Commits viewable in [compare view](thomhurst/TUnit@v1.63.0...v1.64.6). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
7 tasks
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.
Description
Add a small internal production-facing type-erasure contract in
MemberAssertion.csthat letsMemberAssertionResult<TObject>expose its already-composedAssertion<object?>without changing the public fluent API or re-running only part of the chain. UpdateWrapMemberAssertionto recognize that contract before its reflection-basedAssertion<T>fallback, preserving existing handling for ordinary transformed assertions and existing diagnostics for unsupported return values. This keeps the nested result on the same execution path used by normal member chaining and avoids making the public result type inherit a different base class.An outer
Memberassertion currently selects its object-returning fallback when the assertion lambda ends in anotherMemberAssertionResult<T>. In the reported chain,IsTypeOf<InnerEx>().And.Member(...)produces that result, butWrapMemberAssertiononly recognizes classes derived fromAssertion<T>and throwsInvalidOperationExceptionbefore evaluating the assertions. The member result already implements the non-generic assertion contract and contains the combined type and nested-member checks, so rejecting it is inconsistent with the supported chaining model. There are no claims, competing PRs, or closed-unmerged attempts associated with the issue.Closes #6528
Related Issue
Fixes #
Type of Change
Checklist
Not applicable to this change.
Required
TUnit-Specific Requirements
TUnit.Core.SourceGenerator)Not run: no test command resolved in this workspace, so nothing was executed to pass.
TUnit.Engine)Not run: no test command resolved in this workspace, so nothing was executed to pass.
TUnit.Core.SourceGenerator.Testsand/orTUnit.PublicAPItestsNot run: no test command resolved in this workspace, so nothing was executed to pass.
.received.txtfiles and accepted them as.verified.txtNot run: no test command resolved in this workspace, so nothing was executed to pass.
.verified.txtfilesNot run: no test command resolved in this workspace, so nothing was executed to pass.
[DynamicallyAccessedMembers]annotationsNot run: no test command resolved in this workspace, so nothing was executed to pass.
dotnet publish -p:PublishAot=trueNot run: no test command resolved in this workspace, so nothing was executed to pass.
Testing
dotnet test)Not run: no test command resolved in this workspace, so nothing was executed to pass.
ThrowsExactly<OuterEx>().And.Member(... IsTypeOf<InnerEx>().And.Member(Code, IsEqualTo(5)))chain completes successfully for anInnerExwhose code is5. - The same chain with a differentCodevalue throws the normal assertion exception, proving the nested member assertion is executed instead of being silently skipped or rejected as an unexpected type.Additional Notes
Nothing beyond what is described above.