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 3904ae89bd0b15..02bb4632172ac7 100644 --- a/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs +++ b/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs @@ -160,7 +160,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 System.Diagnostics.Process Start(string fileName, string arguments) { throw null; } + public static System.Diagnostics.Process Start(string fileName, string? arguments) { 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 @@ -221,7 +221,7 @@ public sealed partial class ProcessStartInfo { public ProcessStartInfo() { } public ProcessStartInfo(string fileName) { } - public ProcessStartInfo(string fileName, string arguments) { } + public ProcessStartInfo(string fileName, string? arguments) { } public ProcessStartInfo(string fileName, System.Collections.Generic.IEnumerable arguments) { } public System.Collections.ObjectModel.Collection ArgumentList { get { throw null; } } [System.Diagnostics.CodeAnalysis.AllowNullAttribute] diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs index 4218596c129644..9eee2044b5589c 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs @@ -1313,7 +1313,7 @@ public static Process Start(string fileName) [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] [SupportedOSPlatform("maccatalyst")] - public static Process Start(string fileName, string arguments) + public static Process Start(string fileName, string? arguments) { // the underlying Start method can only return null on Windows platforms, // when the ProcessStartInfo.UseShellExecute property is set to true. diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.cs index 0f4fc0a0cb72c1..71fe5ffe89b79f 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.cs @@ -49,7 +49,7 @@ public ProcessStartInfo(string fileName) /// Specifies the name of the application that is to be started, as well as a set /// of command line arguments to pass to the application. /// - public ProcessStartInfo(string fileName, string arguments) + public ProcessStartInfo(string fileName, string? arguments) { _fileName = fileName; _arguments = arguments; diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs index d000f41c94c83a..7164cab40866c1 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.cs @@ -448,6 +448,17 @@ public void TestArgumentsProperty() Assert.Equal("-arg3 -arg4", psi.Arguments); } + [Fact] + public void TestArgumentsNullProperty() + { + string? args = null; + ProcessStartInfo psi = new ProcessStartInfo("filename", args); + Assert.Equal(string.Empty, psi.Arguments); + + psi.Arguments = null; + Assert.Equal(string.Empty, psi.Arguments); + } + [ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported)), InlineData(true), InlineData(false)] public void TestCreateNoWindowProperty(bool value) {