Skip to content

Conversation

@thomhurst
Copy link
Owner

@thomhurst thomhurst commented Jan 28, 2026

Summary

The documentation showed an invalid OR operator syntax that causes errors with Microsoft.Testing.Platform's TreeNodeFilter.

Invalid syntax (old):

(/*/*/Class1/*)|(/*/*/Class2/*)

This throws: A filter '/.*/.*/Class1/.*' should not contain a '/' character

Valid syntax (new):

/*/*/(Class1)|(Class2)/*

Root Cause

Microsoft.Testing.Platform's TreeNodeFilter validates that expressions being combined with operators (|, &) cannot contain the / path separator character. OR operations must occur within a single path segment, not across full paths.

From the TreeNodeFilter source:

case ValueExpression vExpr when vExpr.Value.Contains(PathSeparator):
    throw new ArgumentException(...);

Test plan

  • Verify documentation renders correctly
  • Test that the new example syntax works: dotnet run -- --treenode-filter "/*/*/(Class1)|(Class2)/*"

The previous example `(/*/*/Class1/*)|(/*/*/Class2/*)` is invalid because
Microsoft.Testing.Platform's TreeNodeFilter does not allow OR operations
across full paths - the `/` character cannot appear within expressions
being combined with operators.

The correct syntax uses OR within a single path segment:
`/*/*/(Class1)|(Class2)/*`

Fixes #4580
@thomhurst
Copy link
Owner Author

Summary

Fixes incorrect OR operator syntax in test-filters.md documentation that causes TreeNodeFilter validation errors.

Critical Issues

Incomplete Fix: This PR fixes one instance but leaves other incorrect examples in the codebase:

  1. docs/docs/troubleshooting.md:1426 still shows:

    # Multiple filters (OR)
    dotnet run -- --treenode-filter "/*/*/ClassA/*|/*/*/ClassB/*"

    Should be: dotnet run -- --treenode-filter "/*/*/(ClassA)|(ClassB)/*"

  2. docs/docs/troubleshooting.md:1621 still shows:

    # Run tests that are Integration OR Unit
    dotnet run -- --treenode-filter "/*/*/*/*[Category=Integration]|/*/*/*/*[Category=Unit]"

    This has the same issue - OR-ing complete paths instead of within a segment. The correct syntax should apply here too.

  3. .github/copilot-instructions.md:139 shows vague example:

    # Multiple patterns (OR logic)
    --treenode-filter "Pattern1|Pattern2"

    Should clarify the OR must be within a single path segment.

Note: .claude/docs/workflows.md:50 already correctly identifies the old syntax as "Wrong" ✅

These inconsistencies will confuse users who find the incorrect examples in other documentation files.

Suggestions

Consider expanding this PR to fix all instances of incorrect OR syntax across the documentation to prevent confusion.

Verdict

⚠️ REQUEST CHANGES - Incomplete fix leaves incorrect examples in other documentation files

@thomhurst thomhurst merged commit bc50497 into main Jan 28, 2026
13 checks passed
@thomhurst thomhurst deleted the fix/treenode-filter-or-operator-docs branch January 28, 2026 01:03
This was referenced Jan 29, 2026
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.

2 participants