Skip to content

[code-simplifier] Fix array initialization consistency in IPC serializers and missing InternalAPI declarations #9786

Closed

Description

@github-actions

Code Simplification + Build Fixes — Follow-up to #9774 and #9773

Two recently merged PRs left the build in a broken state (missing InternalAPI.Unshipped.txt declarations) and introduced a minor style inconsistency in the IPC serializers. This PR addresses both.

Files Changed

  • CommandLineOptionMessagesSerializer.cs — consistent empty-array initialization
  • FileArtifactMessagesSerializer.cs — consistent empty-array initialization
  • TestResultMessagesSerializer.cs — consistent empty-array initialization
  • Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt — declare ReadFields/WriteListPayload
  • Microsoft.Testing.Extensions.HangDump/InternalAPI/InternalAPI.Unshipped.txt — same
  • Microsoft.Testing.Extensions.TrxReport/InternalAPI/InternalAPI.Unshipped.txt — same
  • Microsoft.Testing.Extensions.Retry/InternalAPI/InternalAPI.Unshipped.txt — same
  • Microsoft.Testing.Extensions.MSBuild/InternalAPI.Unshipped.txt — same
  • MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt — declare PlatformServicesConfigurationAdapter

Improvements Made

1. Consistent Array Initialization (follow-up to #9774)

PR #9774 introduced two styles within the same set of serializers:

Serializers (before #9774 refactor, kept same style) Pattern
DiscoveredTestMessagesSerializer T[] var = []
TestInProgressMessagesSerializer T[] var = []
CommandLineOptionMessagesSerializer T[]? var = null + return new(..., var ?? [])
FileArtifactMessagesSerializer T[]? var = null + return new(..., var ?? [])
TestResultMessagesSerializer T[]? var = null + return new(..., var ?? [])

This PR normalizes the three inconsistent files to the = [] pattern, removing the nullable type and the ?? [] null-coalescing at the return site.

2. Missing InternalAPI Declarations (pre-existing build failure from #9774)

BaseSerializer.ReadFields and BaseSerializer.WriteListPayload<T> were added as protected static methods. Because BaseSerializer is internal but exposed via InternalsVisibleTo, the API analyzer tracks it. The declarations were missing from Microsoft.Testing.Platform and from all 4 extension projects that include BaseSerializer.cs as a linked source file.

3. Missing InternalAPI Declaration for PlatformServicesConfigurationAdapter (pre-existing build failure from #9773)

PlatformServicesConfigurationAdapter was added to MSTest.TestAdapter in PR #9773 but its constructor and indexer were not declared in InternalAPI.Unshipped.txt.

Testing

  • ✅ Build succeeds (full ./build.sh --build -c Debug)
  • ✅ All 21 Microsoft.Testing.Platform.DotnetTestProtocolContract.UnitTests tests pass
  • ✅ No functional changes — behavior is identical

Changes Based On

🤖 Automated content by GitHub Copilot. Generated by the Code Simplifier workflow. · 440.2 AIC · ⌖ 24.8 AIC · ⊞ 9.3K · [◷]( · ◷)

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@main
  • expires on Jul 10, 2026, 2:25 PM UTC

Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/ipc-serializer-consistency-73fd620fa571e063.

Click here to create the pull request

To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (157 of 157 lines)
From 066286d6f080afd821a41cbfaab8aefb64dbb7b3 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 9 Jul 2026 14:22:50 +0000
Subject: [PATCH] Fix array initialization consistency in IPC serializers and
 missing InternalAPI declarations

- Normalize array initialization in 3 DotnetTest IPC serializers to use
  empty array `= []` pattern instead of nullable `= null` with `?? []`
  fallback, matching the style used by DiscoveredTestMessagesSerializer
  and TestInProgressMessagesSerializer (introduced in PR #9774)

- Add missing InternalAPI.Unshipped.txt declarations for ReadFields and
  WriteListPayload methods added to BaseSerializer in PR #9774, across
  Microsoft.Testing.Platform and its 4 extension projects that link
  BaseSerializer.cs as a shared source file (HangDump, TrxReport, Retry,
  MSBuild)

- Add missing InternalAPI.Unshipped.txt declaration for
  PlatformServicesConfigurationAdapter class added in PR #9773 to
  MSTest.TestAdapter

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../InternalAPI/InternalAPI.Unshipped.txt                 | 3 +++
 .../InternalAPI/InternalAPI.Unshipped.txt                 | 2 ++
 .../InternalAPI.Unshipped.txt                             | 2 ++
 .../InternalAPI/InternalAPI.Unshipped.txt                 | 2 ++
 .../InternalAPI/InternalAPI.Unshipped.txt                 | 2 ++
 .../InternalAPI/InternalAPI.Unshipped.txt                 | 2 ++
 .../Serializers/CommandLineOptionMessagesSerializer.cs    | 4 ++--
 .../IPC/Serializers/FileArtifactMessagesSerializer.cs     | 4 ++--
 .../IPC/Serializers/TestResultMessagesSerializer.cs       | 8 ++++----
 9 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt b/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt
index 7dc5c58..af599cf 100644
--- a/src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.t
... (truncated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentic-workflowsGitHub agentic workflow definitions under .github/workflows/*.md.type/automationCreated or maintained by an agentic workflow.type/tech-debtCode health, refactoring, simplification.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions