diff --git a/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs b/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs index 52dfab59a18f05..71e903dc30c3ec 100644 --- a/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs +++ b/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs @@ -193,7 +193,7 @@ public void Refresh() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] - public static System.Diagnostics.ProcessExitStatus Run(string fileName, System.Collections.Generic.IList? arguments = null, bool silent = false, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static System.Diagnostics.ProcessExitStatus Run(string fileName, System.Collections.Generic.IEnumerable? arguments = null, bool silent = false, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] @@ -201,7 +201,7 @@ public void Refresh() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] - public static System.Diagnostics.ProcessTextOutput RunAndCaptureText(string fileName, System.Collections.Generic.IList? arguments = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } + public static System.Diagnostics.ProcessTextOutput RunAndCaptureText(string fileName, System.Collections.Generic.IEnumerable? arguments = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] @@ -209,7 +209,7 @@ public void Refresh() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] - public static System.Threading.Tasks.Task RunAndCaptureTextAsync(string fileName, System.Collections.Generic.IList? arguments = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task RunAndCaptureTextAsync(string fileName, System.Collections.Generic.IEnumerable? arguments = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] @@ -217,7 +217,7 @@ public void Refresh() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] - public static System.Threading.Tasks.Task RunAsync(string fileName, System.Collections.Generic.IList? arguments = null, bool silent = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task RunAsync(string fileName, System.Collections.Generic.IEnumerable? arguments = null, bool silent = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] // this needs to come after the ios attribute due to limitations in the platform analyzer @@ -251,7 +251,7 @@ public void Refresh() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] // this needs to come after the ios attribute due to limitations in the platform analyzer - public static int StartAndForget(string fileName, System.Collections.Generic.IList? arguments = null) { throw null; } + public static int StartAndForget(string fileName, System.Collections.Generic.IEnumerable? arguments = null) { throw null; } public override string ToString() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Scenarios.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Scenarios.cs index 25bec66a903087..3952c4a540400a 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Scenarios.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Scenarios.cs @@ -61,7 +61,7 @@ public static int StartAndForget(ProcessStartInfo startInfo) /// /// The name of the application or document to start. /// - /// The command-line arguments to pass to the process. Pass or an empty list + /// The command-line arguments to pass to the process. Pass or an empty sequence /// to start the process without additional arguments. /// /// The process ID of the started process. @@ -80,7 +80,7 @@ public static int StartAndForget(ProcessStartInfo startInfo) [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] - public static int StartAndForget(string fileName, IList? arguments = null) + public static int StartAndForget(string fileName, IEnumerable? arguments = null) => StartAndForget(CreateStartInfo(fileName, arguments)); /// @@ -118,7 +118,7 @@ public static ProcessExitStatus Run(ProcessStartInfo startInfo, TimeSpan? timeou /// /// The name of the application or document to start. /// - /// The command-line arguments to pass to the process. Pass or an empty list + /// The command-line arguments to pass to the process. Pass or an empty sequence /// to start the process without additional arguments. /// /// @@ -137,7 +137,7 @@ public static ProcessExitStatus Run(ProcessStartInfo startInfo, TimeSpan? timeou [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] - public static ProcessExitStatus Run(string fileName, IList? arguments = null, bool silent = false, TimeSpan? timeout = default) + public static ProcessExitStatus Run(string fileName, IEnumerable? arguments = null, bool silent = false, TimeSpan? timeout = default) { ProcessStartInfo startInfo = CreateStartInfo(fileName, arguments); @@ -181,7 +181,7 @@ public static async Task RunAsync(ProcessStartInfo startInfo, /// /// The name of the application or document to start. /// - /// The command-line arguments to pass to the process. Pass or an empty list + /// The command-line arguments to pass to the process. Pass or an empty sequence /// to start the process without additional arguments. /// /// @@ -199,7 +199,7 @@ public static async Task RunAsync(ProcessStartInfo startInfo, [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] - public static async Task RunAsync(string fileName, IList? arguments = null, bool silent = false, CancellationToken cancellationToken = default) + public static async Task RunAsync(string fileName, IEnumerable? arguments = null, bool silent = false, CancellationToken cancellationToken = default) { ProcessStartInfo startInfo = CreateStartInfo(fileName, arguments); @@ -275,7 +275,7 @@ public static ProcessTextOutput RunAndCaptureText(ProcessStartInfo startInfo, Ti /// /// The name of the application or document to start. /// - /// The command-line arguments to pass to the process. Pass or an empty list + /// The command-line arguments to pass to the process. Pass or an empty sequence /// to start the process without additional arguments. /// /// @@ -289,7 +289,7 @@ public static ProcessTextOutput RunAndCaptureText(ProcessStartInfo startInfo, Ti [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] - public static ProcessTextOutput RunAndCaptureText(string fileName, IList? arguments = null, TimeSpan? timeout = default) + public static ProcessTextOutput RunAndCaptureText(string fileName, IEnumerable? arguments = null, TimeSpan? timeout = default) => RunAndCaptureText(CreateStartInfoForCapture(fileName, arguments), timeout); /// @@ -342,7 +342,7 @@ public static async Task RunAndCaptureTextAsync(ProcessStartI /// /// The name of the application or document to start. /// - /// The command-line arguments to pass to the process. Pass or an empty list + /// The command-line arguments to pass to the process. Pass or an empty sequence /// to start the process without additional arguments. /// /// @@ -355,26 +355,17 @@ public static async Task RunAndCaptureTextAsync(ProcessStartI [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] - public static Task RunAndCaptureTextAsync(string fileName, IList? arguments = null, CancellationToken cancellationToken = default) + public static Task RunAndCaptureTextAsync(string fileName, IEnumerable? arguments = null, CancellationToken cancellationToken = default) => RunAndCaptureTextAsync(CreateStartInfoForCapture(fileName, arguments), cancellationToken); - private static ProcessStartInfo CreateStartInfo(string fileName, IList? arguments) + private static ProcessStartInfo CreateStartInfo(string fileName, IEnumerable? arguments) { ArgumentException.ThrowIfNullOrEmpty(fileName); - ProcessStartInfo startInfo = new(fileName); - if (arguments is not null) - { - foreach (string argument in arguments) - { - startInfo.ArgumentList.Add(argument); - } - } - - return startInfo; + return arguments is not null ? new ProcessStartInfo(fileName, arguments) : new ProcessStartInfo(fileName); } - private static ProcessStartInfo CreateStartInfoForCapture(string fileName, IList? arguments) + private static ProcessStartInfo CreateStartInfoForCapture(string fileName, IEnumerable? arguments) { ProcessStartInfo startInfo = CreateStartInfo(fileName, arguments); startInfo.RedirectStandardOutput = true;