Repository navigation
Fix VSTestBridge BuildFilter misclassifying a GUID-shaped FullyQualifiedName as an Id filter - #9794
Conversation
…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]>
There was a problem hiding this comment.
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
useFullyQualifiedNameAsUidparameter throughContextAdapterBase→HandleFilter→BuildFilter, gating theGuid.TryParsebranch on!useFullyQualifiedNameAsUid. - Added backward-compatible constructor overloads on
ContextAdapterBase,RunContextAdapter, andDiscoveryContextAdapter(defaulting the flag tofalse), and wired the two request factories to passUseFullyQualifiedNameAsTestNodeUid. - Added unit tests and the corresponding
InternalAPI.Unshipped.txtentries.
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
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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.
…testbridge-guid-filter # Conflicts: # src/Platform/Microsoft.Testing.Extensions.VSTestBridge/InternalAPI.Unshipped.txt
🧪 Test quality grade — PR #9794
This advisory comment was generated automatically. Grades are heuristic
|
|
/backport to rel/4.3 |
|
Started backporting to rel/4.3: https://github.com/microsoft/testfx/actions/runs/29831574643 |
…iedName as an Id filter by @Evangelink in #9794 (backport to rel/4.3) (#10113) Co-authored-by: Amaury Levé <[email protected]> Co-authored-by: Copilot App <[email protected]>
Fixes #9784.
Problem
ContextAdapterBase.BuildFilterused aGuid.TryParseheuristic to decide whether aTestNodeUidshould become anId=<guid>clause or aFullyQualifiedName=<name>clause. But the UID value is produced byObjectModelConverters.ToTestNode, which sets it to eithertestCase.FullyQualifiedNameortestCase.Id.ToString()depending onuseFullyQualifiedNameAsUid.When
useFullyQualifiedNameAsUidistrue, the UID is always aFullyQualifiedName. If that FQN happens to be a GUID-shaped string (e.g. a data-driven test whose display name is exactly12345678-1234-1234-1234-1234567890ab), the heuristic incorrectly emittedId=<guid>, so the reconstructedTestCaseFilterselected by the wrong property — potentially selecting the wrong test or none at all.Fix
Thread the same
useFullyQualifiedNameAsUiddiscriminator (fromVSTestBridgedTestFrameworkBase.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 emitFullyQualifiedName=...(even for GUID-shaped names).useFullyQualifiedNameAsUid == false→ keep the existingId=/Guid.TryParsebehavior for Id-based UIDs.Backwards-compatible constructor overloads (defaulting the flag to
false) are retained so existing callers/tests are unaffected.Tests
Added
RunContextAdapterTestscases covering:useFullyQualifiedNameAsUid: true→FullyQualifiedName=...useFullyQualifiedNameAsUid: false→Id=...useFullyQualifiedNameAsUid: true→FullyQualifiedName=...All VSTestBridge unit tests pass on net8.0, net9.0, and net462.