From 2b194c193dec312725e8e6dbc53b501712e2e348 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Mon, 23 Jun 2008 19:09:22 +0000 Subject: [PATCH] In System.Diagnostics: 2008-06-21 Robert Jordan * Process.cs (Start_common): UserName may be null or empty. Fixes bug #350543. In Test/System.Diagnostics: 2008-06-21 Robert Jordan * ProcessTest.cs (Start_UseShellExecuteWithEmptyUserName): add test for bug #350543. svn path=/trunk/mcs/; revision=106452 --- mcs/class/System/System.Diagnostics/ChangeLog | 5 +++ .../System/System.Diagnostics/Process.cs | 2 +- .../System/Test/System.Diagnostics/ChangeLog | 5 +++ .../Test/System.Diagnostics/ProcessTest.cs | 38 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/System.Diagnostics/ChangeLog b/mcs/class/System/System.Diagnostics/ChangeLog index 396955cebad..da061432ef2 100644 --- a/mcs/class/System/System.Diagnostics/ChangeLog +++ b/mcs/class/System/System.Diagnostics/ChangeLog @@ -1,3 +1,8 @@ +2008-06-21 Robert Jordan + + * Process.cs (Start_common): UserName may be null or empty. + Fixes bug #350543. + 2008-06-19 Dick Porter * Process.cs: Match the buffer sizes of StreamReader and diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index fa28855f542..01bf8169048 100644 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -1132,7 +1132,7 @@ namespace System.Diagnostics { if (startInfo.UseShellExecute) { #if NET_2_0 - if (startInfo.UserName != null) + if (!String.IsNullOrEmpty (startInfo.UserName)) throw new InvalidOperationException ("UserShellExecute must be false if an explicit UserName is specified when starting a process"); #endif return (Start_shell (startInfo, process)); diff --git a/mcs/class/System/Test/System.Diagnostics/ChangeLog b/mcs/class/System/Test/System.Diagnostics/ChangeLog index 34723b09cd9..a9839147b18 100644 --- a/mcs/class/System/Test/System.Diagnostics/ChangeLog +++ b/mcs/class/System/Test/System.Diagnostics/ChangeLog @@ -1,3 +1,8 @@ +2008-06-21 Robert Jordan + + * ProcessTest.cs (Start_UseShellExecuteWithEmptyUserName): + add test for bug #350543. + 2008-06-11 Atsushi Enomoto * FileVersionInfoTest.cs : disabled all English-Windows-dependent diff --git a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs index 3cbb80e2fd5..16f38019f13 100644 --- a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs +++ b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs @@ -592,6 +592,44 @@ namespace MonoTests.System.Diagnostics } } +#if NET_2_0 + [Test] + public void Start_UseShellExecuteWithEmptyUserName () + { + if (RunningOnUnix) + Assert.Ignore ("On Unix and Mac OS X, we try " + + "to open any file (using xdg-open, ...)" + + " and we do not report an exception " + + "if this fails."); + + string exe = @"c:\shouldnoteverexist.exe"; + + try { + Process p = new Process (); + p.StartInfo.FileName = exe; + p.StartInfo.UseShellExecute = true; + p.StartInfo.UserName = ""; + p.Start (); + Assert.Fail ("#1"); + } catch (InvalidOperationException) { + Assert.Fail ("#2"); + } catch (Win32Exception) { + } + + try { + Process p = new Process (); + p.StartInfo.FileName = exe; + p.StartInfo.UseShellExecute = true; + p.StartInfo.UserName = null; + p.Start (); + Assert.Fail ("#3"); + } catch (InvalidOperationException) { + Assert.Fail ("#4"); + } catch (Win32Exception) { + } + } +#endif + [Test] // Start (string, string) public void Start4_FileName_Null () { -- 2.25.1