Skip to content

Refactor named-pipe serializers behind a shared typed base#8535

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-duplicate-code-inamedpipeserializer
Draft

Refactor named-pipe serializers behind a shared typed base#8535
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-duplicate-code-inamedpipeserializer

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 24, 2026

The IPC layer had the same BaseSerializer + INamedPipeSerializer boilerplate repeated across the platform and several extensions, with each serializer re-implementing the same Id / cast / Serialize / Deserialize shape. This change centralizes that pattern without changing the wire format or serializer registration model.

  • Shared serializer abstraction

    • Added NamedPipeSerializer<T> in Microsoft.Testing.Platform as the common implementation of the INamedPipeSerializer plumbing.
    • Keeps the typed serialization contract in one place and leaves each concrete serializer responsible only for Id, DeserializeCore, and SerializeCore.
  • Serializer migration

    • Moved the duplicated named-pipe serializers in Platform, MSBuild, HangDump, Retry, and TrxReport onto the new base.
    • Preserved existing message IDs and binary payload ordering; the change is structural, not protocol-level.
  • Linked-source updates

    • Updated projects that embed the shared IPC serializer sources to include the new base file alongside BaseSerializer and VoidResponseSerializer.
  • Focused test updates

    • Adjusted the IPC/protocol unit tests to exercise the refactored serializers while keeping the assertions on serialized behavior unchanged.

Example of the new shape:

internal sealed class ModuleInfoRequestSerializer
    : NamedPipeSerializer<ModuleInfoRequest>, INamedPipeSerializer
{
    public override int Id => 1;

    protected override ModuleInfoRequest DeserializeCore(Stream stream)
        => new(ReadString(stream), ReadString(stream), ReadString(stream));

    protected override void SerializeCore(ModuleInfoRequest value, Stream stream)
    {
        WriteString(stream, value.FrameworkDescription);
        WriteString(stream, value.ProcessArchitecture);
        WriteString(stream, value.TestResultFolder);
    }
}

Copilot AI requested review from Copilot and removed request for Copilot May 24, 2026 05:37
Copilot AI linked an issue May 24, 2026 that may be closed by this pull request
10 tasks
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 24, 2026 05:57
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 24, 2026 05:59
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 24, 2026 06:01
Copilot AI changed the title [WIP] Fix duplicate code in INamedPipeSerializer implementations Refactor named-pipe serializers behind a shared typed base May 24, 2026
Copilot AI requested a review from Evangelink May 24, 2026 06:02
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.

[duplicate-code] Duplicate Code: INamedPipeSerializer Boilerplate Pattern

2 participants