Repository navigation
Add experimental MSTest JSON-RPC discovery reuse - #11853
Conversation
Keep repeated GUID selections opt-in and reuse only inert reflection metadata, rediscovering live types and creating fresh execution descriptors. Preserve baseline routes, lifecycle, cancellation and filtering with packed parity coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e085e21a-57c7-4c4e-a32e-03cce215a62c
Preserve both discovery-cache and FSharp-module internal API declarations. Repack and verify all three packed metadata modes plus adapter and PlatformServices unit suites. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e085e21a-57c7-4c4e-a32e-03cce215a62c
There was a problem hiding this comment.
🔵 Needs a closer look
The reflection-cache lifecycle spans discovery, execution, telemetry, concurrency, and multiple runtimes, while cross-platform and fallback CI validation remains pending.
0 open findings
What changed in this PR
Adds opt-in discovery metadata reuse for repeated GUID-selected MSTest JSON-RPC server requests.
Changes:
- Introduces application-scoped metadata caching with conservative eligibility and invalidation.
- Preserves live discovery, filtering, ordering, telemetry, cancellation, and fallback behavior.
- Adds extensive unit, packed acceptance, API-baseline, and package-documentation coverage.
| File | Description |
|---|---|
test/UnitTests/MSTestAdapter.UnitTests/MSTestDiscoveryCacheTests.cs |
Tests cache correctness, invalidation, isolation, and concurrency. |
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/MtpDiscoveryCacheTests.cs |
Validates packed server-mode parity and fallback routes. |
src/Adapter/MSTestAdapter.PlatformServices/Telemetry/MSTestTelemetryDataCollector.cs |
Supports telemetry snapshot and replay. |
src/Adapter/MSTestAdapter.PlatformServices/InternalAPI/InternalAPI.Unshipped.txt |
Tracks new PlatformServices internals. |
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.cs |
Allows injecting the cached discoverer. |
src/Adapter/MSTestAdapter.PlatformServices/Discovery/UnitTestDiscoverer.cs |
Separates returned candidates from full discovery counts. |
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumeratorWrapper.cs |
Supports targeted type enumeration and observation. |
src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs |
Adds per-type discovery observation. |
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/TestApplicationBuilderExtensions.cs |
Registers the application-scoped cache. |
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestFramework.cs |
Gates reuse to eligible JSON-RPC requests. |
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestDiscoveryCache.cs |
Implements catalog construction, reuse, and invalidation. |
src/Adapter/MSTest.TestAdapter/PACKAGE.md |
Documents experimental activation and limitations. |
src/Adapter/MSTest.TestAdapter/InternalAPI/uwp/InternalAPI.Unshipped.txt |
Updates the UWP internal API baseline. |
src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt |
Updates the adapter internal API baseline. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🧪 Test quality review — PR #11853
🧵 Parallel safety
Status: CLEAN (Critical=0, High=0, Warning=0, Info=2)
| Test assembly | Scope | Workers | Notes |
|---|---|---|---|
MSTestAdapter.UnitTests (MSTestDiscoveryCacheTests) |
off — runs under the internal TestContainer engine (TestFramework.ForTestingMSTest), which has no concurrent scheduler |
n/a | Sequential by construction |
MSTest.Acceptance.IntegrationTests (outer) |
MethodLevel |
CPU count | Pre-existing acceptance assembly setting |
DiscoveryCacheHost (generated child asset embedded in the new test) |
MethodLevel, Workers = 2 |
2 | Single-use generated fixture, not shipped test code |
i️ Info — MSTestDiscoveryCacheTests.cs:604-651,701-706: DiscoveryFixture mutates process-global PlatformServiceProvider.Instance, MSTestTelemetryDataCollector.Current, and LiveData statics, restoring them in Dispose(). This is readiness-only: the owning engine has no parallel scheduler today, and the pattern matches existing sibling files in the same project (MSTestDiscovererTests.cs, TestResultRecorderExtensionsTests.cs). No action needed now; if this engine ever gains concurrency, these globals would need explicit mutual exclusion.
i️ Info — MSTestDiscoveryCacheTests.cs:439-454: ConcurrentHitsReturnIndependentMetadataWithoutChangingTheCatalog runs 16 concurrent Task.Run discoveries against one shared MSTestDiscoveryCache, but this exercises production-code internal locking (lock (_gate)), not cross-test parallelism — the suite itself runs sequentially. Not a hazard.
The new integration test's shared probe directory/events file usage was also checked: every [DataRow]/route variant allocates its own sub-directory, and in-process Probe.Record writes are serialized with a lock. No races found.
Per-test grades
All 23 new unit tests in MSTestDiscoveryCacheTests.cs and the single new acceptance test method (RepeatedSelectedRequestsMatchUncachedExecution, exercised via 3 [DataRow] metadata modes) were graded. Every test earned A: each uses exact-value AwesomeAssertions (Should().Equal(...), Should().Be(...)) against concrete production state rather than bare non-null checks, follows clear Arrange-Act-Assert structure under ~25 lines, and a pseudo-mutation walk of MSTestDiscoveryCache.GetTests/IsTypeSafe/AreAttributesSafe/CloneMetadata found no meaningful mutation (cache-key invalidation fields, unsafe-type detection, GUID multimap ordering, cloned-vs-original metadata independence, cancellation gating, telemetry replay) that these tests would fail to kill. No inline findings were needed.
| Grade | Test | Mutation | Notes | How to improve |
|---|---|---|---|---|
| A (90–100) | new MtpDiscoveryCacheTests. | N/A (process-level parity test) | Verifies byte-identical TRX/event parity across default/enabled/disabled/invalid modes and all host routes. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Confirms a pre-cancelled token still performs baseline discovery and later requests succeed. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 3/3 killed | Exact telemetry-count equivalence between cold scan and cache hit, including unselected tests. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 3/3 killed | Verifies a catalog is not published on cancellation and a later scan still succeeds. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 3/3 killed | Settings-XML change forces rescan; identical settings still hit the cache. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 4/4 killed | Mutating a returned element never leaks into subsequent cache hits across all mutable fields. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | 16 concurrent hits each get independently mutable metadata without corrupting the shared catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | A live custom-category getter re-evaluates on every hit even with no data source. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Unsafe deployment-item types are rediscovered live even when unselected. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Disposal forces a full baseline rescan rather than reusing a stale catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | A discovery warning on one type prevents the whole catalog from being published. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Duplicate/unknown UIDs in selection don't break baseline source-ordering. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Live dynamic-data providers still run for empty/unknown selections, observing side effects. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Empty selection yields zero candidates while preserving the full discovered count. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 3/3 killed | A narrow first selection still allows a later, different selection to hit the same catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Two catalog entries sharing a GUID are both returned as distinct instances, in order. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | An inherited live category getter re-evaluates on an unselected hit. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | A warning on a live (unsafe) type doesn't corrupt or replace the existing safe-type catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Metadata-inspection failure disables caching and recovers once the failure clears. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | An inert BCL assembly attribute does not block catalog eligibility. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Catalogs are isolated per cache-owner instance; a new owner always rescans. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | SetSources correctly evicts a source's catalog when it's no longer present. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Unknown UID selection yields zero candidates while retaining the full count. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 3/3 killed | A dynamic-data type produces fresh rows with unique indices even when unselected, in order. | — |
This advisory review is heuristic and non-blocking.
Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
github.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "github.com"See Network Configuration for more information.
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 315.3 AIC · ⌖ 7.41 AIC · ⊞ 19.6K · ◷
Distinguish initial warning rejection from live warnings on later cache hits. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e085e21a-57c7-4c4e-a32e-03cce215a62c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e085e21a-57c7-4c4e-a32e-03cce215a62c
This comment has been minimized.
This comment has been minimized.
|
Final test-triage resolution — Azure Pipelines build 1629558 This supersedes any preliminary comment for this build. Affected leg: Actionable failure — product/test defect in this PR's own new feature:
Platform-specific signal: the identically-named test (same 3 variants, multiple attempts) passed on Evidence completeness: Not actionable: the other 6 failures in Conclusion: no issue created. This failure is scoped entirely to this PR's own new, experimental, Windows-only-validated discovery-cache feature and has no history on unrelated commits or main/scheduled builds, so the durable-issue thresholds are not met — the fix belongs in this PR. Next step: investigate why
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e085e21a-57c7-4c4e-a32e-03cce215a62c
There was a problem hiding this comment.
🧪 Test quality review — PR #11853
🧵 Parallel safety
STATUS: FINDINGS (Warning/Info only — no Critical or High risk, no fix required)
| Test assembly | Scope | Workers | Analyzer coverage |
|---|---|---|---|
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests |
off (TestContainer engine has no parallel scheduler) |
n/a | n/a |
MSTest.Acceptance.IntegrationTests |
MethodLevel (pre-existing [assembly: Parallelize], unchanged by this PR) |
CPU count | pending parallel-safety analyzers |
- [Warning · A · High confidence]
test/UnitTests/MSTestAdapter.UnitTests/MSTestDiscoveryCacheTests.cs—DiscoveryFixturemutates process-global statics (PlatformServiceProvider.Instance,MSTestTelemetryDataCollector.Current,LiveData.*), also touched by sibling files in the same assembly. No live race today becauseMSTestAdapter.UnitTestsruns on the sequentialTestContainerengine. Readiness-only: if this project ever adopts[Parallelize], these classes would need[DoNotParallelize]or a shared[ResourceLock]. No action needed now. - [Info · D · High confidence]
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/MtpDiscoveryCacheTests.cs— the fixedAssetName = "DiscoveryCacheHost"cannot collide becauseTestAsset.GenerateAssetAsyncallocates a fresh randomly-suffixed temp directory per call, and no other file reuses that id. Context only, not a defect.
No inline parallel-safety comment is warranted: both findings are readiness-only/context, with no concrete present-day race or fix.
Per-test grades
| Grade | Test | Mutation | Notes | How to improve |
|---|---|---|---|---|
| A (90–100) | new MtpDiscoveryCacheTests. | 4/4 killed | Byte-for-byte parity across console/UID/dotnet-test/vstest routes, UID stability, and kill-switch override, across 3 metadata modes; this test already caught a real Linux-only host crash in CI. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Verifies a pre-cancelled token still falls back to full discovery, not a stuck/empty result. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Asserts cache hits replay identical discovery-attribute telemetry counts as a cold scan. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Confirms a cancelled cold scan never publishes a half-built catalog for later hits. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Exact pre/post full-scan counts prove settings-XML changes invalidate the catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Mutates returned elements across three fetches and asserts no shared-reference leakage between hits. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | 16 concurrent cache hits each get independently-mutable metadata without corrupting the shared catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Exact category-value change on a second request proves custom attributes stay live even when unselected. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Deployment-item path change between runs is reflected in the second result, proving no stale-cache leak. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Disposing mid-flight still returns the full baseline set rather than a stale/partial cached result. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | A discovery warning on first scan is shown to block catalog publication (second scan re-warns identically). | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Duplicate + unknown UIDs in one request still yield baseline type ordering, not scrambled or duplicated output. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Live data-provider values change between empty/unknown-selection requests, proving providers are never cached. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Empty selection yields zero candidates while total discovered count is still correct. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | First narrow selection is shown not to corrupt the catalog for a later, different selection. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Two catalog entries sharing one UID are both returned and are distinct instances — the multimap isn't collapsed. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Inherited custom-category attribute stays live (re-evaluated) across requests even when unselected. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | A later live-type warning is surfaced but proven not to replace/corrupt the existing cached catalog. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Metadata-inspection exceptions fall back to full discovery, and recovery once the exception clears is verified. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | A real inert BCL assembly attribute is shown not to block cache eligibility. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | A second cache instance never reuses the first owner's catalog, even after the first is disposed. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | Dropping a source from SetSources is shown to evict and force a fresh full scan. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 1/1 killed | An unknown UID yields zero candidates while total discovered count remains correct. | — |
| A (90–100) | new MSTestDiscoveryCacheTests. | 2/2 killed | Changed dynamic-data row count/values between requests prove the data provider is re-invoked, not cached. | — |
Summary
- 24 gradable test methods (23 unit tests in
MSTestDiscoveryCacheTests+ 1 parameterized acceptance test inMtpDiscoveryCacheTests), all A. Assertions are precise (exact equality/sequence/value checks, not just non-null), scope is narrow per test, and the suite systematically covers cache eligibility, invalidation, concurrency, telemetry replay, warnings, and cross-owner isolation. - Parallel safety: no live race. The only two findings are readiness-only (sequential
TestContainerengine today) and contextual (unique per-call temp directories); no fix is required and no inline comment is warranted. - For context (not part of this review's scope): CI's automated pipeline-test-triage already flagged that
RepeatedSelectedRequestsMatchUncachedExecutionis currently failing deterministically on the Linux Release leg (native host SIGABRT), which the test itself caught as a genuine product defect in this PR's new feature — a strong signal of this test's effectiveness, but a merge blocker the author still needs to fix. - Existing automated review threads (
github-code-qualitysuggestions aroundWhere/Selectrefactors, and the PACKAGE.md warning-semantics clarification) are already resolved with author replies; no new duplicate findings raised here. - No inline comments were posted: no verified, actionable defect met the publication bar independent of the already-resolved threads and the pre-existing CI triage.
This advisory review is heuristic and non-blocking.
Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 412.1 AIC · ⌖ 8.59 AIC · ⊞ 19.6K · ◷

Repeated selected-test requests in native MTP server mode currently rediscover the entire assembly. This adds application-scoped reuse of eligible reflection metadata to reduce that cost while preserving live discovery behavior.
Approach and scope
MSTEST_EXPERIMENTAL_DISCOVERY_CACHE=1ortrueto opt in;MSTEST_DISABLE_DISCOVERY_CACHE=1ortrueoverrides it. Both are read per run request. The default path performs no cache eligibility inspection.Validation
All local results below use the final restored payload at
724795be78efc22f0596b6433b159579c27af503(MSTest 4.6.0-dev, MTP/client 2.6.0-dev), on Windows:$/cancelRequest, not merely caller cancellation or a settle delay.Independent Claude Opus 5.5 review found no blocking discrepancy for this narrow experimental recommendation. That is not CI, merge or shipping approval.
Performance and trade-offs
108 fresh hosts and 3924 timed requests, with six balanced blocks, covered 100/1000/5000-test fixtures and 0/10/50% live-type mixes. For one selected test in a 90/10 mix, paired median RPC speedups were 2.64x [2.14, 2.99] at 1000 tests and 3.64x [3.33, 4.25] at 5000 (paired-block bootstrap 95% intervals). At 50% live types, the corresponding gains were 1.88x and 2.26x with outcome parity.
These are synthetic fast tests on one shared Windows machine, not broad application compatibility or universal small-suite benefit. The first eligible run pays catalog construction: observed paired cold overhead was about +4 to +22 ms at 1000 tests and +22 to +88 ms at 5000. Catalog eviction reclaimed approximately 0.53/2.78 MiB of managed heap for 900/4500 reusable tests. Turning opt-in off stops reuse but retains an existing catalog until invalidation/shutdown. Discovery-only requests do not warm it. Overlapping RPC telemetry isolation is not claimed.
No full-Stryker or end-to-end runtime improvement is claimed. Package documentation records eligibility, fallbacks and costs. Raw measurements, TRX, reports and payload provenance are preserved in session artifacts.
Release boundary
Target the upcoming MSTest 4.6/MTP 2.6 line only. No servicing backport or downstream default enablement. Supported-OS PR CI, full acceptance and UWP/.NET Framework fallback validation remain merge prerequisites; release-branch and cross-platform execution have not been verified locally. The implementation owner retains responsibility for evidence-backed promotion or removal of the experimental flag.
Related issue: N/A.