Repository navigation
Fix IndexOutOfRangeException in VSTestBridge BuildFilter UID escaping by @azat-msft in #9771 (backport to rel/4.3) - #10112
Merged
Amaury Levé (Evangelink) merged 5 commits intoJul 21, 2026
Conversation
ContextAdapterBase.BuildFilter reconstructs a VSTest TestCaseFilter from a
TestNodeUidListFilter (the by-UID selection IDEs send over the server protocol).
Its hand-rolled escaper guarded the "is this char already escaped?" check with the
node index (i) instead of the character index (k): it read
currentTestNodeUid.Value[k - 1] while testing i - 1 < 0. For any node after the
first (i > 0) whose first character (k == 0) is a filter operator, this evaluated
Value[-1] and threw IndexOutOfRangeException, aborting the whole run. The same
index confusion could also under-escape an operator that follows a literal
backslash.
Replace the loop with VSTest's canonical FilterHelper.Escape, which escapes every
filter operator ('\ ( ) & | = ! ~') unconditionally -- exactly what a raw
test-node UID needs -- removing the index bug.
Add RunContextAdapterFilterTests covering BuildFilter output: FullyQualifiedName
vs Id=<guid> selection, multi-node OR joining, runsettings/command-line filters,
operator escaping, and the two regressions above (a later node starting with an
operator no longer throws; backslash-then-operator escapes both characters).
Co-authored-by: Copilot <[email protected]>
Assert the built filter not only produces the expected escaped string but also actually matches (via ITestCaseFilterExpression.MatchTestCase) a test case whose FullyQualifiedName is exactly the escaped name and rejects others, guarding the full escape -> parse -> match path against a future parser-side regression. Co-authored-by: Copilot App <[email protected]>
…ode and empty-list coverage Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
TestNodeUid lives in Microsoft.Testing.Platform.Extensions.Messages; that using was removed as 'unused' but CreateUidFilter constructs TestNodeUid, so all TFMs failed to compile with CS0246. Re-add the directive in alphabetical order. Co-authored-by: Copilot App <[email protected]>
Amaury Levé (Evangelink)
approved these changes
Jul 21, 2026
Amaury Levé (Evangelink)
enabled auto-merge (squash)
July 21, 2026 13:04
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.
Backport of #9771 to rel/4.3
/cc Amaury Levé (@Evangelink) Azat Mukhametshin (@azat-msft)