Refactor ServerTestHost into focused partial-class files#8865
Merged
Conversation
6 tasks
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor ServerTestHost.cs into focused partial-class files
Refactor Jun 5, 2026
ServerTestHost into focused partial-class files
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors ServerTestHost (Microsoft.Testing.Platform server-mode host) by splitting the existing partial type into multiple concern-focused files, keeping the lifecycle/core state in ServerTestHost.cs while moving message-loop/RPC handling, request execution, and outbound messaging into dedicated partial-class files. It also fixes the cancellation-warning logic so warnings are emitted only when request-cancellation itself throws.
Changes:
- Split inbound JSON-RPC reading/dispatch and request tracking into
ServerTestHost.MessageLoop.cs. - Split request execution + telemetry metric shaping into
ServerTestHost.RequestExecution.cs. - Split outbound JSON-RPC response/notification helpers into
ServerTestHost.Messaging.cs, keepingServerTestHost.csfocused on lifecycle and core state.
Show a summary per file
| File | Description |
|---|---|
| src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.cs | Removes message-loop, request execution, and messaging helpers to keep the main file focused on lifecycle/core state. |
| src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.MessageLoop.cs | New partial file containing the main message loop, inbound notification/request handling, and per-request cancellation state. |
| src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.RequestExecution.cs | New partial file containing request execution pipeline and telemetry metric builders for discovery/run. |
| src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.Messaging.cs | New partial file containing outbound responses/errors and pushed notifications (test updates, telemetry, logs). |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 1
Evangelink
approved these changes
Jun 7, 2026
Co-authored-by: Copilot <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.
ServerTestHost.cshad grown into a large mixed-responsibility file, making the server host flow harder to navigate. This change splits the existing partial type by concern so lifecycle, inbound RPC handling, request execution, and outbound messaging each live in a dedicated file.What changed
ServerTestHost.csfocused on host lifecycle and core state:InternalRunAsyncDisposeServerTestHost.MessageLoop.cs:HandleMessagesAsyncHandleNotificationAsyncHandleRequestAsyncCompleteRequestRpcInvocationStateServerTestHost.RequestExecution.cs:HandleRequestCoreAsyncServerTestHost.Messaging.cs:Behavioral note
ServerTestHostsurface area and call paths while reducing file size and isolating responsibilities.Example split