Skip to content

Normalize array initialization in DotnetTest IPC serializers#9804

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/fix-ipc-serializer-array-init
Jul 9, 2026
Merged

Normalize array initialization in DotnetTest IPC serializers#9804
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/fix-ipc-serializer-array-init

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Fixes #9786.

Summary

Follow-up to #9774. PR #9774 introduced two different empty-array initialization styles across the DotnetTest IPC serializers. This normalizes the three inconsistent files to the = [] pattern used by DiscoveredTestMessagesSerializer and TestInProgressMessagesSerializer, removing the nullable = null initializer and the ?? [] null-coalescing at the return site.

Files changed

  • CommandLineOptionMessagesSerializer.cs
  • FileArtifactMessagesSerializer.cs
  • TestResultMessagesSerializer.cs

Notes

The missing InternalAPI.Unshipped.txt declarations (ReadFields/WriteListPayload and PlatformServicesConfigurationAdapter) referenced in the issue are already present on main, so no InternalAPI changes were needed.

No functional changes — behavior is identical.

Testing

  • Microsoft.Testing.Platform builds cleanly (0 warnings, 0 errors).

Follow-up to #9774. Normalize the empty-array initialization style in CommandLineOptionMessagesSerializer, FileArtifactMessagesSerializer, and TestResultMessagesSerializer to use the `= []` pattern (matching DiscoveredTestMessagesSerializer and TestInProgressMessagesSerializer), removing the nullable `= null` initializer and the `?? []` null-coalescing at the return site.

Fixes #9786

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Normalizes empty-array initialization across DotnetTest IPC serializers without changing behavior.

Changes:

  • Initializes message arrays with [].
  • Removes redundant ?? [] return fallbacks.
Show a summary per file
File Description
CommandLineOptionMessagesSerializer.cs Normalizes command-line message initialization.
FileArtifactMessagesSerializer.cs Normalizes artifact message initialization.
TestResultMessagesSerializer.cs Normalizes successful and failed result initialization.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Summary: Clean mechanical normalization. The three files now consistently use = [] initialization (matching DiscoveredTestMessagesSerializer and TestInProgressMessagesSerializer), removing the mixed = null + ?? [] pattern. Verified:

  • IPC Wire Compatibility — serialization is untouched; deserialization produces identical output (empty array fallback preserved via = [] initialization).
  • Algorithmic CorrectnessRead*Payload methods always return non-null arrays, so the variable is guaranteed non-null at the return site regardless of which ReadFields branches fire.
  • Performance[] for arrays compiles to Array.Empty<T>() (cached singleton), so no allocation concern even in the (unlikely) case the field isn't present in the stream.
  • Constructor compatibilityFileArtifactMessages, TestResultMessages, and CommandLineOptionMessages all accept the passed values correctly (verified against record signatures in IPC/Models/).

@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 9, 2026
@Evangelink
Evangelink enabled auto-merge (squash) July 9, 2026 22:00
@Evangelink
Evangelink merged commit 049d27e into main Jul 9, 2026
35 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/fix-ipc-serializer-array-init branch July 9, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants