Relocate VSTest logger/sink bridges to the adapter (Phase 6e-2)#9623
Draft
Evangelink wants to merge 1 commit into
Draft
Relocate VSTest logger/sink bridges to the adapter (Phase 6e-2)#9623Evangelink wants to merge 1 commit into
Evangelink wants to merge 1 commit into
Conversation
Move the three remaining VSTest-object-model bridge helpers out of MSTestAdapter.PlatformServices and into MSTest.TestAdapter: AdapterMessageLoggerExtensions, MessageLevel (ToTestMessageLevel), and UnitTestElementSinkExtensions. These are the last code references to Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging / ITestCaseDiscoverySink in PlatformServices; only doc comments now mention the VSTest types. The logical namespace is unchanged so callers at the adapter boundary and the integration harness are unaffected. PlatformServices.UnitTests calls the ToAdapterMessageLogger bridge, which now lives in MSTest.TestAdapter; touching that module runs its [ModuleInitializer] (MSTestExecutor.SetPlatformLogger), which assigns PlatformServiceProvider.Instance.AdapterTraceLogger. Make the test double's setter tolerate the assignment (as the real PlatformServiceProvider does) instead of throwing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Phase 6e-2 — Relocate the VSTest logger/sink bridges to the adapter
Part of the initiative to make
MSTestAdapter.PlatformServicesplatform-agnostic by removing its dependency on the VSTest object model (Microsoft.TestPlatform.ObjectModel). VSTest coupling moves up intoMSTest.TestAdapter; the platform-services engine becomes neutral.What this does
Moves the three remaining VSTest-object-model bridge helpers out of
MSTestAdapter.PlatformServices/Services/and intoMSTest.TestAdapter/Services/:AdapterMessageLoggerExtensions.cs—IMessageLogger→IAdapterMessageLoggerMessageLevel.cs— theMessageLevel↔TestMessageLevelmapping (ToTestMessageLevel)UnitTestElementSinkExtensions.cs—ITestCaseDiscoverySink→IUnitTestElementSinkThese were the last code references to
Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging/ITestCaseDiscoverySinkin PlatformServices. After this change, the only mentions of the VSTest logger/sink types in PlatformServices are<c>…</c>doc-comment references on the neutral interfaces (IAdapterMessageLogger,IUnitTestElementSink).The files keep their logical namespace (
…MSTestAdapter.PlatformServices), so the adapter-boundary callers (MSTestExecutor/MSTestDiscoverer/MSTestBridgedTestFramework) and the integration-test harness are source-unaffected — they already reach these via[InternalsVisibleTo].Test-double adjustment
MSTestAdapter.PlatformServices.UnitTestscalls theToAdapterMessageLoggerbridge in ~150 places (to wrap a MoqIMessageLoggerwhen exercising the neutralMSTestSettings.GetSettings(…, IAdapterMessageLogger)surface). Now that the bridge lives inMSTest.TestAdapter, the first such call loads that module, which runs its[ModuleInitializer](MSTestExecutor.SetPlatformLogger) and assignsPlatformServiceProvider.Instance.AdapterTraceLogger. TheTestablePlatformServiceProviderdouble previously threw from that setter as a guard, which turned the initializer into a hard fault cascading across the suite.Since the real
PlatformServiceProvider.AdapterTraceLoggeris a normal settable property, the double's setter is now a no-op (the getter still returns the mock so trace-logging verifications are unchanged). No test assignsAdapterTraceLoggerdirectly, so this only affects tolerance of the production module initializer.Verification
build.cmd -c Debuggreen across all TFMs (net462/net8.0/net9.0/UWP/WinUI).MSTestAdapter.PlatformServices.UnitTests: 897 (net8.0) / 935 (net462), 0 failed.MSTestAdapter.UnitTests: 21, 0 failed.MSTest.IntegrationTests: 48 total, 0 failed, 1 skipped (OutputIsNotMixedWhenTestsRunInParallel, pre-existing known flaky).ObjectModel.Logging/IMessageLogger/TestMessageLevel/ITestCaseDiscoverySinkcode references remain in PlatformServices (doc comments only).Stacking
Stacked chain onto
dev/amauryleve/vstest-decoupling-base:6c2 #9590→6d-1 #9591→6d-2 #9621→6e-1 #9622→ 6e-2 (this).Base for this PR is the 6e-1 branch (
dev/amauryleve/vstest-decoupling-bridges). Review/merge after the predecessors reach the base. Do not rebase/reset the base.