Skip to content

Extract MSTest's explicit-token tuple predicate - #12045

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/cancellation-predicate-helpers
Oct 20, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
dev/amauryleve/cancellation-predicate-helpers

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Pull request

Summary

Make MSTest's single-argument data check easier to read by extracting IsSingleTupleArgumentWithExplicitCancellationToken. The private helper replaces only the inline negated condition; tuple expansion, supported token values, and short-circuit evaluation are unchanged.

Fixes: #12017

Replaces closed #12020. The display-name predicate proposed there is already covered by #12021, so its shared implementation is preserved rather than duplicated.

Design and decision record

No separate record is needed for this private, behavior-preserving extraction. Preserve the existing parameter-count and row-length guards before tuple expansion and explicit-token detection. No public/internal API declarations, package layout, or scheduling configuration change.

Demonstration

Media is not applicable: no user-visible output changes. The focused green-before/green-after comparison below checks unchanged argument binding and display names.

Validation and regression proof

Baseline: 780c775d357d6ca25eee67b9469133dae3ee1730. Tested head: e8d8290561542b8dea1dd782ac128f521ece8f91. Debug configuration, using the repo-local SDK bootstrapped by eng\build.ps1.

Focused selection TFM Before After
TestDataSourceHelpersTests, TestMethodInfoTests, MethodInfoExtensionsTests net8.0 196 passed 196 passed
Same adapter selection net462 194 passed 194 passed
DataRowAttributeTests, CombinatorialDataAttributeTests net8.0 48 passed 48 passed

All runs exited 0 with zero failed or skipped tests. The sorted test identities and outcomes match between the baseline and refactor reports. The following exact head commands were also rerun before publication; each exited 0:

& .\.dotnet\dotnet.exe build .\src\Adapter\MSTestAdapter.PlatformServices\MSTestAdapter.PlatformServices.csproj --no-restore -c Debug -p:SkipUapTargetFramework=true --verbosity quiet
& .\.dotnet\dotnet.exe run --project .\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj --framework net8.0 --no-build -c Debug -- --treenode-filter '/*/*/(TestDataSourceHelpersTests)|(TestMethodInfoTests)|(MethodInfoExtensionsTests)/*' --report-trx --report-trx-filename adapter-net8.trx --results-directory .\artifacts\TestResults\predicate-pr
& .\.dotnet\dotnet.exe run --project .\test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj --framework net462 --no-build -c Debug -- --treenode-filter '/*/*/(TestDataSourceHelpersTests)|(TestMethodInfoTests)|(MethodInfoExtensionsTests)/*' --report-trx --report-trx-filename adapter-net462.trx --results-directory .\artifacts\TestResults\predicate-pr
& .\.dotnet\dotnet.exe run --project .\test\UnitTests\TestFramework.UnitTests\TestFramework.UnitTests.csproj --framework net8.0 --no-build -c Debug -- --treenode-filter '/*/*/(DataRowAttributeTests)|(CombinatorialDataAttributeTests)/*' --report-trx --report-trx-filename framework-net8.trx --results-directory .\artifacts\TestResults\predicate-pr

Build result: 0 warnings and 0 errors across net462, net8.0, net9.0, net10.0, net11.0, net8.0-windows10.0.18362.0, and net9.0-windows10.0.17763.0. Legacy UAP was excluded; runtime tests on the other TFMs and package-consuming acceptance tests were not run.

TRX reports are retained locally under artifacts\TestResults\predicate-pr\ as adapter-net8.trx, adapter-net462.trx, and framework-net8.trx; baseline/comparison reports are retained in the session artifacts. These local artifacts have not been uploaded.

Test-value evidence

Executed green-before/green-after evidence: the same 438 tests pass on both revisions above. Existing cases distinguish full-arity Tuple/ValueTuple rows from ordinary single-array data, including explicit tokens, null, Type.Missing, invalid token values, extra tuple elements, argument packing, and display-name shapes. Both modern ITuple and legacy reflection tuple paths are exercised. No new behavior or regression test is introduced; a failing baseline is not expected for this extraction.

Name the tuple-row check without changing its guards or short-circuit order. Keep the shared display-name token predicate introduced by #12021.

Fixes #12017

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8589acf0-ae23-4d9e-9d8b-6d5bb09e85cd
Copilot AI balanced review requested due to automatic review settings October 20, 2026 11:52
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 20, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧪 Test quality review — PR #12045

Compared merge base 780c775d357d6ca25eee67b9469133dae3ee1730 with head
e8d8290561542b8dea1dd782ac128f521ece8f91. Evidence applies to this head, not
every intermediate commit.

Test-value evidence

This PR touches exactly one contract: TestDataSourceHelpers.IsDataConsideredSingleArgumentValue. The change is a pure extract-method refactor — the inline negated condition !(parameters.Length == 2 && data.Length == 1 && TryHandleTupleDataSource(...) && IsDataWithExplicitCancellationToken(...)) is moved verbatim into a new private helper IsSingleTupleArgumentWithExplicitCancellationToken, with no change to operand order, short-circuit evaluation, or the boolean expression itself. Diffing the extracted body against the removed inline code confirms a textual/semantic match (same operators, same operand order, same helper calls).

  • Scenario: single-argument-value detection for a 2-parameter test method (data, CancellationToken) where the sole supplied data item is a tuple.
  • Counterfactual: not applicable — there is no behavioral ablation to construct since no branch, operand, or guard changed; this is a structural refactor only.
  • Expected result: unchanged outcome before and after for all existing cases (explicit-token tuples, preserved tuple-as-object-array data, explicit/implicit object-array shapes), matching the refactor-test expectation that behavior is identical pre/post.
  • Evidence available: test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Helpers/TestDataSourceHelpersTests.cs already exercises IsDataConsideredSingleArgumentValue across the relevant shapes (IsDataConsideredSingleArgumentValue_RejectsExplicitTokenTuplesForObjectArrayArgument, _PreservesTupleAsObjectArrayData, _PreservesExplicitAndImplicitObjectArrayShapes) and was not modified by this PR, so it continues to protect the now-extracted branch indirectly through the public entry point. This is a static prediction, not executed evidence collected by this workflow — this review does not run tests. The PR description reports an executed green-before/green-after comparison (438 tests passing on both revisions) as author-supplied evidence; that claim was not independently reproduced here.
  • No new test method was added or needed for a behavior-preserving extraction of this kind; the unchanged existing suite is the correct instrument.

🧵 Parallel safety

PARALLEL-SAFETY RESULT
STATUS: NOT_APPLICABLE
ASSEMBLIES:
none
COUNTS: A=0; B=0; C=0; D=0; Critical=0; High=0; Warning=0; Info=0
TOP_ACTIONS:
none
FINDINGS:
none
NOTES: No changed tests or parallelization configuration were in scope (has_parallel_scope=false, test_count=0, config_count=0).
END PARALLEL-SAFETY RESULT

Per-test assessment

No test methods were added or modified by this PR (test_count = 0). There is nothing to grade.

This advisory review is heuristic and non-blocking.

Re-run the combined review with /review-tests, or only the parallel-safety
specialist with /parallel-audit.

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 39.4 AIC · ⌖ 8.43 AIC · ⊞ 22.3K · ◷

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 20, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow private extraction preserves existing logic and introduces no identified blocking issues.

No open issues 🎉

What changed in this PR

Improves readability of MSTest’s argument classification without changing behavior.

Changes:

  • Extracts the tuple-and-explicit-token condition into a private helper.
  • Preserves guards, short-circuit order, and shared token detection.
  • Adds a comment explaining why these tuples represent full rows.

Test-value evidence: The PR reports 438 tests passing on both 780c775 and e8d8290. Execution artifacts were not independently verified.

🟢 Confidence at a glance: adapter refactor

The supplied diff preserves the original predicate and evaluation order. No actionable issues remain.

File Description
src/​Adapter/​MSTestAdapter.PlatformServices/​Helpers/​TestDataSourceHelpers.cs Extracts and documents the explicit-token tuple predicate.

Review effort: Balanced

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 20, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Oct 20, 2026
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Build Failure Analysis

Analysis incomplete — all 13 application-model acceptance binlogs completed successfully with zero MSBuild errors, but binlog-mcp timed out while loading each of the three full-build logs (Windows Debug, Linux Release, and Windows Release). Because those logs could contain the actual failure, there is not enough evidence to classify this as a clean compile/non-build failure or to propose a code fix safely.

Please inspect the originating [Azure DevOps build]((dev.azure.com/redacted) for the authoritative errors. No inline suggestions or automated changes were emitted because no compiler or MSBuild error could be recovered from the affected logs.


🤖 Generated by the Build Failure Analysis workflow using (a href="(dev.azure.com/redacted) · commit e8d8290561542b8dea1dd782ac128f521ece8f91

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · copilot · gpt56 · 65.2 AIC · ⌖ 18.6 AIC · ⊞ 43.3K · [◷]( · ◷)

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Final test-triage resolution — Azure Pipelines build 1642025

Analysis is final (completed build, mode full), but historical correlation data is incomplete (artifact-download-failed, download-budget-exhausted), so absence-of-recurrence claims below are bounded by that gap.

Affected build legs: Windows Debug (failed). Windows Release and Linux Release unaffected.

Failure signatures (7 failed/retried records):

  1. Microsoft.Testing.Extensions.UnitTests.HangDumpTests.QueryOnceAndDumpTree_StartsEveryDumpBeforeAwaitingCompletion — net472, Windows Debug only. Assert.AreSame(allDumpsStarted.Task, completed) failed; the message indicates a dump was awaited before the remaining process dumps were started (timing/ordering race). Passed on net8.0/9.0/10.0/11.0/net462 in the same job and on Linux Release across all TFMs. Checked up to 5 prior main builds for this exact signature (net472, same leg): all passed (durations 13–10,696 ms vs. this run's 35,963 ms). Single occurrence, no retry attempt recorded, and the current PR only touches MSTest's explicit-token tuple predicate helpers — no plausible connection to hang-dump orchestration. Confidence: low-to-moderate this is a pre-existing net472/Debug timing flake rather than a PR regression; it does not meet the two-build recurrence or deterministic-regression bar for an issue.
  2. WinUIMtpPackagedApp.UnitTest1.RetryFailsFirstAttempt, NativeTests.Outcome (×4), PackagedWinUI.PackagedWinUITestCases.RetryTestMethod_PassesOnSecondAppContainerHost — all from Windows_App_Model_Diagnostics. These are self-validating extension-probe tests designed to fail their first attempt and pass on retry; fail→pass is confirmed in the retry attempt records for each. Working as intended, not product defects.

Conclusion: No actionable regression or durable flaky pattern identified. The one real product-test failure (QueryOnceAndDumpTree_StartsEveryDumpBeforeAwaitingCompletion) is an isolated net472/Windows-Debug timing assertion unrelated to this PR's diff, with no recurrence in the (incomplete) available history. No issue created per escalation policy; worth monitoring subsequent main builds for recurrence of this specific signature before escalating.

🤖 Automated content by GitHub Copilot. Generated by the Pipeline Test Triage workflow. · copilot · auto · 59.2 AIC · ⌖ 5.21 AIC · ⊞ 9.8K

@Evangelink
Amaury Levé (Evangelink) merged commit 1a6a5f7 into main Oct 20, 2026
35 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/cancellation-predicate-helpers branch October 20, 2026 15:17
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Oct 20, 2026
Amaury Levé (Evangelink) added a commit that referenced this pull request Oct 20, 2026
Resolve the overlap between #12043 and #12045 by retaining one unchanged IsSingleTupleArgumentWithExplicitCancellationToken definition. Removing the duplicate restores compilation, which otherwise fails with CS0111.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ba332d0f-f512-4fa7-80b6-9731c87a2c96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[code-simplifier] Extract named helpers for cancellation-token data predicates

3 participants