Skip to content

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

Description

@TheTomatoKing

Background and motivation

The new Process.Run() and related methods take an IList<string> for command arguments.
It should use IEnumerable<string> instead for correctness, and to be in line with the Process.Start() counterpart.

API Proposal

// Existing API
public class Process
{
    public static ProcessExitStatus Run(string fileName, IList<string>? arguments = null, TimeSpan? timeout = default);
}
// Proposed API
public class Process
{
    public static ProcessExitStatus Run(string fileName, IEnumerable<string>? arguments = null, TimeSpan? timeout = default);
}
// And similar for related APIs (eg. RunAndCaptureText, RunAsync, etc).

API Usage

No change for existing callers.

Alternative Designs

IReadOnlyList<string> is also a valid option.
But IEnumerable<string> will allow it to be dropped in as a replacement for more existing code, and I can see neither Count nor the indexer are used in the current implementation.

Risks

This is a breaking change. But I don't think it's beyond what's expected in Preview/RC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.ProcessuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions