Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Implementation Plan for ProcessExitStatus

  • Add ProcessExitStatus to reference file (ref/System.Diagnostics.Process.cs)
  • Add ProcessExitStatus implementation in src/System/Diagnostics/ProcessExitStatus.cs
  • Add XML documentation based on the approved API shape
  • Add basic unit tests for ProcessExitStatus
  • Build and test the changes
  • Address API review feedback - remove IEquatable and equality members
  • Change from struct to sealed class per approved API shape
  • Rename constructor parameter cancelled to canceled to match Canceled property
  • Clarify Signal property remarks for publicly constructible type

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@copilot address my feedback

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ProcessExitStatus class to System.Diagnostics namespace Add ProcessExitStatus struct to System.Diagnostics.Process Feb 11, 2026
Copilot AI requested a review from adamsitnik February 11, 2026 12:40
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot address my feedback

Addressed in commit b291ae1. Removed IEquatable interface and all equality-related members to match the approved API shape.

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot AI changed the title Add ProcessExitStatus struct to System.Diagnostics.Process Add ProcessExitStatus class to System.Diagnostics.Process Feb 11, 2026
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM

@adamsitnik adamsitnik marked this pull request as ready for review February 11, 2026 13:01
Copilot AI review requested due to automatic review settings February 11, 2026 13:01
@adamsitnik adamsitnik enabled auto-merge (squash) February 11, 2026 13:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new System.Diagnostics.ProcessExitStatus public type to represent process termination state (exit code, optional POSIX signal, and cancellation/timeout termination), along with unit tests and project file wiring to compile/ship the new API.

Changes:

  • Added new public API ProcessExitStatus (ref + implementation) in System.Diagnostics.Process.
  • Wired the new source file into the product csproj and added a new unit test file.
  • Added unit tests validating constructor/property behavior for multiple parameter combinations.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj Includes the new ProcessExitStatusTests.cs test file in compilation.
src/libraries/System.Diagnostics.Process/tests/ProcessExitStatusTests.cs Adds unit tests for ProcessExitStatus constructor/property combinations.
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessExitStatus.cs Implements the new public ProcessExitStatus class with XML docs.
src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj Adds ProcessExitStatus.cs to the product compilation list.
src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs Adds the ProcessExitStatus public ref-surface declaration.

@stephentoub
Copy link
Member

@copilot please invoke the code-review skill and post your analysis/results as a comment on this PR

Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot please invoke the code-review skill and post your analysis/results as a comment on this PR

🤖 Copilot Code Review — PR #124393

Holistic Assessment

Motivation: This PR implements the ProcessExitStatus type from the approved API proposal in #123380 (API review comment). The type is foundational infrastructure for future process execution APIs. The motivation is clear and backed by an approved API review.

Approach: The implementation is a straightforward sealed class matching the approved API shape exactly. No alternative approach is warranted for a simple DTO type.

Summary: ⚠️ Needs Human Review. The code is correct and matches the approved API shape. There are two documentation items and a minor test style observation worth human judgment, but none are blocking.


Detailed Findings

✅ API Shape — Matches approved API exactly

The implementation matches the approved API shape exactly:

  • public sealed class ProcessExitStatus
  • Constructor: (int exitCode, bool cancelled, PosixSignal? signal = null)
  • Properties: ExitCode, Signal, Canceled — all get-only ✓

The cancelled (double-l) parameter name and Canceled (single-l) property name both match the approved API verbatim. The copilot-pull-request-reviewer bot's suggestion to rename the parameter would deviate from the approved shape.

✅ Ref Assembly — Follows conventions

  • No using directives (types are fully qualified) ✓
  • throw null method bodies ✓
  • partial class
  • Members in alphabetical order ✓
  • Placed alphabetically between ProcessModuleCollection and ProcessPriorityClass

✅ Project File Wiring — Correct

  • ProcessExitStatus.cs added to the Compile ItemGroup in the correct alphabetical position within the TargetPlatformIdentifier != '' condition ✓
  • ProcessExitStatusTests.cs added to test csproj in alphabetical order ✓

✅ Implementation — Clean and correct

  • License header present ✓
  • Sealed class with readonly auto-properties ✓
  • File-scoped namespace not used — consistent with sibling files (e.g., ProcessPriorityClass.cs, ProcessInfo.cs) which all use block-scoped namespaces ✓
  • XML doc comments on all public members ✓

⚠️ Documentation — Signal property remarks are slightly misleading (advisory, non-blocking)

The Signal property doc says:

"This property is always null on Windows."

Since ProcessExitStatus is publicly constructible, a caller can set Signal to any value on any platform. The remark is only accurate when the instance is produced by the runtime's process APIs. This is a minor precision issue — the approved API review established this as a public constructor, so the runtime clearly intends users to construct instances. A more precise remark might be: "When produced by process management APIs on Windows, this property is always null." However, this is advisory — the current wording is understandable in context and the API owner has already approved.

💡 Tests — Could use [Theory] but [Fact] is fine

The five test methods each construct a ProcessExitStatus with different parameter combinations. These could be consolidated into a [Theory] with [InlineData] to reduce duplication:

[Theory]
[InlineData(0, false, null)]
[InlineData(42, false, null)]
[InlineData(1, true, null)]
[InlineData(137, false, PosixSignal.SIGTERM)]
[InlineData(130, true, PosixSignal.SIGINT)]
public void Constructor_SetsPropertiesCorrectly(int exitCode, bool cancelled, PosixSignal? signal)

However, the existing test files in this project (ProcessTests.cs, ProcessStartInfoTests.cs) predominantly use [Fact] rather than [Theory], so the current approach is consistent with the codebase. This is purely a style suggestion.

✅ No Missing Callers or Sibling Impact

ProcessExitStatus is a new standalone type with no existing callers. It will be consumed by future APIs (SafeProcessHandle.WaitForExit(), etc.) from #123380. No sibling types need modification.

…rty name

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
auto-merge was automatically disabled February 11, 2026 13:46

Head branch was pushed to by a user without write access

Copilot AI requested a review from adamsitnik February 11, 2026 13:47
@stephentoub
Copy link
Member

@copilot please address the feedback

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot please address the feedback

Addressed the remaining reviewer feedback — clarified the Signal property remarks from "This property is always null on Windows" to "When produced by Process APIs on Windows, this property is always null" since the type is publicly constructible (commit 9932cba). The cancelledcanceled rename was already done in 2f9f9f6.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM

@adamsitnik adamsitnik requested a review from jozkee February 11, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants