Skip to content

Fix VSTestBridge BuildFilter misclassifying a GUID-shaped FullyQualifiedName as an Id filter - #9794

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/fix-vstestbridge-guid-filter
Jul 9, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/fix-vstestbridge-guid-filter

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Fixes #9784.

Problem

ContextAdapterBase.BuildFilter used a Guid.TryParse heuristic to decide whether a TestNodeUid should become an Id=<guid> clause or a FullyQualifiedName=<name> clause. But the UID value is produced by ObjectModelConverters.ToTestNode, which sets it to either testCase.FullyQualifiedName or testCase.Id.ToString() depending on useFullyQualifiedNameAsUid.

When useFullyQualifiedNameAsUid is true, the UID is always a FullyQualifiedName. If that FQN happens to be a GUID-shaped string (e.g. a data-driven test whose display name is exactly 12345678-1234-1234-1234-1234567890ab), the heuristic incorrectly emitted Id=<guid>, so the reconstructed TestCaseFilter selected by the wrong property — potentially selecting the wrong test or none at all.

Fix

Thread the same useFullyQualifiedNameAsUid discriminator (from VSTestBridgedTestFrameworkBase.UseFullyQualifiedNameAsTestNodeUid) used when the UID was created down through the two context factories → RunContextAdapter / DiscoveryContextAdapter → ContextAdapterBase → BuildFilter, and use it to pick the clause type:

  • useFullyQualifiedNameAsUid == true → always emit FullyQualifiedName=... (even for GUID-shaped names).
  • useFullyQualifiedNameAsUid == false → keep the existing Id=/Guid.TryParse behavior for Id-based UIDs.

Backwards-compatible constructor overloads (defaulting the flag to false) are retained so existing callers/tests are unaffected.

Tests

Added RunContextAdapterTests cases covering:

  • GUID-shaped FQN with useFullyQualifiedNameAsUid: true → FullyQualifiedName=...
  • GUID value with useFullyQualifiedNameAsUid: false → Id=...
  • Regular FQN with useFullyQualifiedNameAsUid: true → FullyQualifiedName=...

All VSTestBridge unit tests pass on net8.0, net9.0, and net462.

…dName as Id filter

Thread the useFullyQualifiedNameAsUid discriminator through the context
adapters so BuildFilter emits FullyQualifiedName= (not Id=) when the UID was
produced from TestCase.FullyQualifiedName, even when that name coincidentally
parses as a Guid.

Fixes #9784

Co-authored-by: Copilot App <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 17:50

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.

Pull request overview

This PR fixes a latent bug (#9784) in the VSTestBridge where ContextAdapterBase.BuildFilter used a Guid.TryParse heuristic to decide whether a TestNodeUid should become an Id=<guid> or FullyQualifiedName=<name> filter clause. When useFullyQualifiedNameAsUid is true, a FullyQualifiedName that is coincidentally GUID-shaped (e.g. a data-driven test named exactly like a GUID) was misclassified as an Id= clause, selecting the wrong test or none. The fix threads the same useFullyQualifiedNameAsUid discriminator used when the UID was created, rather than re-guessing from the value.

Changes:

  • Added a useFullyQualifiedNameAsUid parameter through ContextAdapterBase → HandleFilter → BuildFilter, gating the Guid.TryParse branch on !useFullyQualifiedNameAsUid.
  • Added backward-compatible constructor overloads on ContextAdapterBase, RunContextAdapter, and DiscoveryContextAdapter (defaulting the flag to false), and wired the two request factories to pass UseFullyQualifiedNameAsTestNodeUid.
  • Added unit tests and the corresponding InternalAPI.Unshipped.txt entries.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/ContextAdapterBase.cs Core fix: threads useFullyQualifiedNameAsUid into BuildFilter and gates the Id=/Guid.TryParse path; adds explanatory comment and new constructor overload.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/RunContextAdapter.cs Adds 4-arg constructor forwarding the flag to the base; keeps 3-arg overload defaulting to false.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/DiscoveryContextAdapter.cs Same overload pattern as RunContextAdapter.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Requests/VSTestRunTestExecutionRequestFactory.cs Passes adapterExtension.UseFullyQualifiedNameAsTestNodeUid when creating the run context.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Requests/VSTestDiscoverTestExecutionRequestFactory.cs Passes the flag when creating the discovery context.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt Declares the three new internal constructor overloads (RS0016).
test/UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests/ObjectModel/RunContextAdapterTests.cs Adds tests for GUID-shaped FQN, GUID Id, and regular FQN filter clause selection.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions

This comment has been minimized.

@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.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Review summary: Clean, well-scoped bug fix. The root cause — Guid.TryParse heuristic misclassifying GUID-shaped FullyQualifiedName values as Id filters — is correctly addressed by threading the same useFullyQualifiedNameAsUid discriminator used during UID creation (in ObjectModelConverters.ToTestNode) through the filter-building path. Backward-compatible constructor overloads (defaulting to false) preserve existing behavior for callers that don't pass the flag. Tests cover the three key scenarios (GUID-shaped FQN with flag on, GUID with flag off, non-GUID FQN with flag on) and assertions use the correct library per BannedSymbols.txt. Internal API surface is properly tracked in InternalAPI.Unshipped.txt.

@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) July 9, 2026 18:06
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jul 9, 2026
…testbridge-guid-filter

# Conflicts:
#	src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt
Copilot AI review requested due to automatic review settings July 9, 2026 19:30

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.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9794

GradeTestNotes
A (90–100) new RunContextAdapterFilterTests.
GetTestCaseFilter_
WithGuidShapedFullyQualifiedName_
AndUseFullyQualifiedNameAsUid_
BuildsFullyQualifiedNameFilter
Clear AAA structure, named constant for GUID-shaped name, and a precise equality assertion directly pinning the regression scenario. No issues found.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 44.9 AIC · ⌖ 7.37 AIC · ⊞ 9.5K · [◷]( · ◷)

@Evangelink
Amaury Levé (Evangelink) merged commit e9fec47 into main Jul 9, 2026
39 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/fix-vstestbridge-guid-filter branch July 9, 2026 20:59
@Evangelink

Copy link
Copy Markdown
Member Author

/backport to rel/4.3

@github-actions

Copy link
Copy Markdown
Contributor

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

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VSTestBridge BuildFilter misclassifies a FullyQualifiedName that is a valid GUID as an Id= filter

3 participants