Normalize array initialization in DotnetTest IPC serializers#9804
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
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 Correctness —
Read*Payloadmethods always return non-null arrays, so the variable is guaranteed non-null at the return site regardless of whichReadFieldsbranches fire. - Performance —
[]for arrays compiles toArray.Empty<T>()(cached singleton), so no allocation concern even in the (unlikely) case the field isn't present in the stream. - Constructor compatibility —
FileArtifactMessages,TestResultMessages, andCommandLineOptionMessagesall accept the passed values correctly (verified against record signatures inIPC/Models/).
Evangelink
enabled auto-merge (squash)
July 9, 2026 22:00
0101
approved these changes
Jul 9, 2026
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.
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 byDiscoveredTestMessagesSerializerandTestInProgressMessagesSerializer, removing the nullable= nullinitializer and the?? []null-coalescing at the return site.Files changed
CommandLineOptionMessagesSerializer.csFileArtifactMessagesSerializer.csTestResultMessagesSerializer.csNotes
The missing
InternalAPI.Unshipped.txtdeclarations (ReadFields/WriteListPayloadandPlatformServicesConfigurationAdapter) referenced in the issue are already present onmain, so no InternalAPI changes were needed.No functional changes — behavior is identical.
Testing
Microsoft.Testing.Platformbuilds cleanly (0 warnings, 0 errors).