Skip to content

Change IList<string> to IEnumerable<string> in Process Run/StartAndForget methods#130630

Merged
adamsitnik merged 3 commits into
mainfrom
copilot/implement-changes-from-issue-130364
Jul 21, 2026
Merged

Change IList<string> to IEnumerable<string> in Process Run/StartAndForget methods#130630
adamsitnik merged 3 commits into
mainfrom
copilot/implement-changes-from-issue-130364

Conversation

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

The arguments parameter in Process.Run, RunAsync, RunAndCaptureText, RunAndCaptureTextAsync, and StartAndForget was typed as IList<string> despite the implementation only iterating (never indexing or mutating) the collection. This is inconsistent with the existing Process.Start(string, IEnumerable<string>) overload.

  • ref/System.Diagnostics.Process.cs — updated all five affected method signatures from IList<string>? to IEnumerable<string>?
  • src/System/Diagnostics/Process.Scenarios.cs — updated matching public signatures and the private CreateStartInfo/CreateStartInfoForCapture helpers; implementation body unchanged (already used foreach)

API approved in #130364 (comment)

…rget methods

Fixes #130364 by updating the parameter type of the arguments parameter
in Process.Run, Process.RunAsync, Process.RunAndCaptureText,
Process.RunAndCaptureTextAsync, and Process.StartAndForget to use
IEnumerable<string> instead of IList<string>, consistent with the
existing Process.Start(string, IEnumerable<string>) overload.

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot AI self-assigned this Jul 13, 2026
Copilot AI review requested due to automatic review settings July 13, 2026 15:09
Copilot AI removed the request for review from Copilot July 13, 2026 15:09
Copilot AI requested a review from adamsitnik July 13, 2026 15:10

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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 requested review from Copilot and removed request for Copilot July 13, 2026 16:00
Copilot AI requested a review from adamsitnik July 13, 2026 16:01
Copilot AI temporarily deployed to copilot-pat-pool July 13, 2026 16:03 Inactive
Copilot AI temporarily deployed to copilot-pat-pool July 13, 2026 16:04 Inactive
@adamsitnik adamsitnik added this to the 11.0.0 milestone Jul 21, 2026
@adamsitnik
adamsitnik marked this pull request as ready for review July 21, 2026 17:24
Copilot AI review requested due to automatic review settings July 21, 2026 17:24
@adamsitnik
adamsitnik enabled auto-merge (squash) July 21, 2026 17:24
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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

This PR updates the public System.Diagnostics.Process “scenario” APIs to accept IEnumerable<string>? for command arguments instead of IList<string>?, aligning with the existing Process.Start(string, IEnumerable<string>) pattern and removing an unnecessary list requirement.

Changes:

  • Updated Process.Run, RunAsync, RunAndCaptureText, RunAndCaptureTextAsync, and StartAndForget overloads to take IEnumerable<string>? arguments = null.
  • Simplified internal CreateStartInfo* helpers to pass the enumerable directly to new ProcessStartInfo(fileName, arguments) when non-null.
  • Updated the ref/ contract accordingly (public API surface change).

Reviewed changes

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

File Description
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Scenarios.cs Updates public overload signatures and internal helper signatures; uses ProcessStartInfo(string, IEnumerable<string>) when arguments are provided.
src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs Updates the public reference surface for the five affected APIs to IEnumerable<string>?.

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot address the feedback

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 17:49
auto-merge was automatically disabled July 21, 2026 17:49

Head branch was pushed to by a user without write access

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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Scenarios.cs:68

  • This overload can throw ArgumentException when fileName is empty (via ArgumentException.ThrowIfNullOrEmpty(fileName) in CreateStartInfo), but the XML docs only mention the null case. Please document the empty-string exception for consistency with the other fileName overloads in this file.
        /// The command-line arguments to pass to the process. Pass <see langword="null"/> or an empty sequence
        /// to start the process without additional arguments.
        /// </param>
        /// <returns>The process ID of the started process.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="fileName"/> is <see langword="null"/>.</exception>

@adamsitnik
adamsitnik enabled auto-merge (squash) July 21, 2026 18:15
@adamsitnik
adamsitnik merged commit 640b31b into main Jul 21, 2026
82 of 84 checks passed
@adamsitnik
adamsitnik deleted the copilot/implement-changes-from-issue-130364 branch July 21, 2026 20:48
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.

[API Proposal]: Change Process.Run() and related methods to accept IEnumerable<string> instead of IList<string>

4 participants