Optimize VSTestBridge property lookup - #10586
Conversation
Scan only the custom TestCase property store when preserving the original executor URI, avoiding the built-in property concatenation and key snapshot allocations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Optimizes the per-test-case VSTest bridge executor URI lookup while preserving existing behavior.
Changes:
- Scans only stored custom properties.
- Adds regression coverage for repeated fixups, null values, and URI replacement.
Show a summary per file
| File | Description |
|---|---|
ObjectModelConverters.cs |
Optimizes original executor URI detection. |
ObjectModelConvertersTests.cs |
Covers fixup behavior and edge cases. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
🧵 Parallel-safety audit — PR #10586Parallelization — assemblies audited:
Findings: A (global-state) This PR only touches
No changes to Top actions: None — no changes needed for parallel-safety. Advisory only — heuristic, non-blocking. Re-run with
|
| // Because this project is the actually registered test adapter, we need to replace test framework executor | ||
| // URI by ours. | ||
| if (!testCase.Properties.Any(x => x.Id == OriginalExecutorUriProperty.Id)) | ||
| if (!testCase.GetProperties().Any(static property => property.Key.Id == OriginalExecutorUriProperty.Id)) |
There was a problem hiding this comment.
Is this whole condition even needed? Looks like it's always true to me and the property can be set unconditionally?
Summary
TestCaseproperties when preserving the original executor URITestCase.Propertiesconcatenation and key-snapshot allocations on the per-test-case hot pathnullvalues, and executor URI replacementPerformance
Independent .NET 9 measurements used
Microsoft.TestPlatform.ObjectModel18.8.0, four custom properties, five 5,000,000-call repetitions, and hit-first/hit-last/no-hit scenarios. The original non-capturing predicate was confirmed to be cached; the savings come from avoidingTestCase.Propertiesenumeration.A manual loop retained the same allocations as each corresponding LINQ path, so this keeps the simpler
Anyexpression.Testing
net462,net8.0, andnet9.0Microsoft.Testing.Extensions.VSTestBridge.UnitTestssuites: 69/69 (net462), 74/74 (net8.0), 74/74 (net9.0)Closes #10585