From 828d7d782b603f3eccf986637ec1fd9e83513482 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 6 Oct 2015 14:56:38 +0200 Subject: [PATCH] [System] Remove Process.Start and related API from TvOS/WatchOS. --- mcs/build/profiles/monotouch_tv.make | 1 + mcs/build/profiles/monotouch_tv_runtime.make | 3 + mcs/build/profiles/monotouch_watch.make | 1 + .../profiles/monotouch_watch_runtime.make | 3 + mcs/class/System/Makefile | 5 + .../System/System.Diagnostics/Process.cs | 91 +++++++++++++++++++ .../System.Net.NetworkInformation/Ping.cs | 6 +- .../ProcessStartInfoTest.cs | 4 + .../Test/System.Diagnostics/ProcessTest.cs | 7 +- mcs/mcs/Makefile | 4 + mcs/mcs/driver.cs | 4 + 11 files changed, 127 insertions(+), 2 deletions(-) diff --git a/mcs/build/profiles/monotouch_tv.make b/mcs/build/profiles/monotouch_tv.make index 084af615caa..2a36da9c203 100644 --- a/mcs/build/profiles/monotouch_tv.make +++ b/mcs/build/profiles/monotouch_tv.make @@ -5,3 +5,4 @@ PROFILE_MCS_FLAGS += \ NO_THREAD_ABORT=1 NO_THREAD_SUSPEND_RESUME=1 +NO_PROCESS_START=1 diff --git a/mcs/build/profiles/monotouch_tv_runtime.make b/mcs/build/profiles/monotouch_tv_runtime.make index 6ea1b4ab2d6..552442ac129 100644 --- a/mcs/build/profiles/monotouch_tv_runtime.make +++ b/mcs/build/profiles/monotouch_tv_runtime.make @@ -5,3 +5,6 @@ PROFILE_MCS_FLAGS += \ NO_THREAD_ABORT=1 NO_THREAD_SUSPEND_RESUME=1 +# The binding generator (btv) still needs to execute processes, +# so we need a System.dll that can do that. +#NO_PROCESS_START=1 diff --git a/mcs/build/profiles/monotouch_watch.make b/mcs/build/profiles/monotouch_watch.make index 9a68dcf9eb5..8534aaf1f77 100644 --- a/mcs/build/profiles/monotouch_watch.make +++ b/mcs/build/profiles/monotouch_watch.make @@ -5,3 +5,4 @@ PROFILE_MCS_FLAGS += \ NO_THREAD_ABORT=1 NO_THREAD_SUSPEND_RESUME=1 +NO_PROCESS_START=1 diff --git a/mcs/build/profiles/monotouch_watch_runtime.make b/mcs/build/profiles/monotouch_watch_runtime.make index 920042750dd..7b3eb80a551 100644 --- a/mcs/build/profiles/monotouch_watch_runtime.make +++ b/mcs/build/profiles/monotouch_watch_runtime.make @@ -5,3 +5,6 @@ PROFILE_MCS_FLAGS += \ NO_THREAD_ABORT=1 NO_THREAD_SUSPEND_RESUME=1 +# The binding generator (bwatch) still needs to execute processes, +# so we need a System.dll that can do that. +#NO_PROCESS_START=1 diff --git a/mcs/class/System/Makefile b/mcs/class/System/Makefile index aef9e5f2b46..b734c75c850 100644 --- a/mcs/class/System/Makefile +++ b/mcs/class/System/Makefile @@ -23,6 +23,11 @@ TEST_MCS_FLAGS = -r:System.Drawing.dll -r:Mono.Security.dll -r:System.Data -r:Sy $(foreach f, $(TEST_RESOURCES), -resource:$(f),$(notdir $(f))) REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,SYSTEM_NAMESPACE,MONO,PLATFORM_UNIX +ifndef NO_PROCESS_START +REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_PROCESS_START +TEST_MCS_FLAGS += -d:MONO_FEATURE_PROCESS_START +endif + LIB_MCS_FLAGS = -nowarn:618 -d:CONFIGURATION_2_0 $(REFERENCE_SOURCES_FLAGS) -unsafe $(RESOURCE_FILES:%=-resource:%) TEST_MCS_FLAGS += -r:System.Configuration diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index 76f2a7fc1a6..75228caad85 100644 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -577,6 +577,7 @@ namespace System.Diagnostics { } } +#if MONO_FEATURE_PROCESS_START private StreamReader error_stream=null; bool error_stream_exposed; @@ -648,6 +649,28 @@ namespace System.Diagnostics { start_info = value; } } +#else + [Obsolete ("Process.StandardError is not supported on the current platform.", true)] + public StreamReader StandardError { + get { throw new NotSupportedException ("Process.StandardError is not supported on the current platform."); } + } + + [Obsolete ("Process.StandardInput is not supported on the current platform.", true)] + public StreamWriter StandardInput { + get { throw new NotSupportedException ("Process.StandardInput is not supported on the current platform."); } + } + + [Obsolete ("Process.StandardOutput is not supported on the current platform.", true)] + public StreamReader StandardOutput { + get { throw new NotSupportedException ("Process.StandardOutput is not supported on the current platform."); } + } + + [Obsolete ("Process.StartInfo is not supported on the current platform.", true)] + public ProcessStartInfo StartInfo { + get { throw new NotSupportedException ("Process.StartInfo is not supported on the current platform."); } + set { throw new NotSupportedException ("Process.StartInfo is not supported on the current platform."); } + } +#endif // MONO_FEATURE_PROCESS_START /* Returns the process start time in Windows file * times (ticks from DateTime(1/1/1601 00:00 GMT)) @@ -895,6 +918,7 @@ namespace System.Diagnostics { // the process (currently we have none). } +#if MONO_FEATURE_PROCESS_START [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern static bool ShellExecuteEx_internal(ProcessStartInfo startInfo, ref ProcInfo proc_info); @@ -1191,6 +1215,43 @@ namespace System.Diagnostics { psi.UseShellExecute = false; return Start(psi); } +#else + [Obsolete ("Process.Start is not supported on the current platform.", true)] + public bool Start () + { + throw new NotSupportedException ("Process.Start is not supported on the current platform."); + } + + [Obsolete ("Process.Start is not supported on the current platform.", true)] + public static Process Start (ProcessStartInfo startInfo) + { + throw new NotSupportedException ("Process.Start is not supported on the current platform."); + } + + [Obsolete ("Process.Start is not supported on the current platform.", true)] + public static Process Start (string fileName) + { + throw new NotSupportedException ("Process.Start is not supported on the current platform."); + } + + [Obsolete ("Process.Start is not supported on the current platform.", true)] + public static Process Start(string fileName, string arguments) + { + throw new NotSupportedException ("Process.Start is not supported on the current platform."); + } + + [Obsolete ("Process.Start is not supported on the current platform.", true)] + public static Process Start(string fileName, string username, SecureString password, string domain) + { + throw new NotSupportedException ("Process.Start is not supported on the current platform."); + } + + [Obsolete ("Process.Start is not supported on the current platform.", true)] + public static Process Start(string fileName, string arguments, string username, SecureString password, string domain) + { + throw new NotSupportedException ("Process.Start is not supported on the current platform."); + } +#endif // MONO_FEATURE_PROCESS_START public override string ToString() { @@ -1219,11 +1280,13 @@ namespace System.Diagnostics { if (!WaitForExit_internal (process_handle, ms)) return false; +#if MONO_FEATURE_PROCESS_START if (async_output != null && !async_output.IsCompleted) async_output.AsyncWaitHandle.WaitOne (); if (async_error != null && !async_error.IsCompleted) async_error.AsyncWaitHandle.WaitOne (); +#endif // MONO_FEATURE_PROCESS_START OnExited (); @@ -1277,6 +1340,7 @@ namespace System.Diagnostics { cb (this, new DataReceivedEventArgs (str)); } +#if MONO_FEATURE_PROCESS_START [Flags] enum AsyncModes { NoneYet = 0, @@ -1465,6 +1529,31 @@ namespace System.Diagnostics { error_canceled = true; } +#else + [Obsolete ("Process.BeginOutputReadLine is not supported on the current platform.", true)] + public void BeginOutputReadLine () + { + throw new NotSupportedException ("Process.BeginOutputReadLine is not supported on the current platform."); + } + + [Obsolete ("Process.BeginOutputReadLine is not supported on the current platform.", true)] + public void CancelOutputRead () + { + throw new NotSupportedException ("Process.BeginOutputReadLine is not supported on the current platform."); + } + + [Obsolete ("Process.BeginOutputReadLine is not supported on the current platform.", true)] + public void BeginErrorReadLine () + { + throw new NotSupportedException ("Process.BeginOutputReadLine is not supported on the current platform."); + } + + [Obsolete ("Process.BeginOutputReadLine is not supported on the current platform.", true)] + public void CancelErrorRead () + { + throw new NotSupportedException ("Process.BeginOutputReadLine is not supported on the current platform."); + } +#endif // MONO_FEATURE_PROCESS_START [Category ("Behavior")] [MonitoringDescription ("Raised when this process exits.")] @@ -1497,6 +1586,7 @@ namespace System.Diagnostics { // If this is a call to Dispose, // dispose all managed resources. if (disposing) { +#if MONO_FEATURE_PROCESS_START /* These have open FileStreams on the pipes we are about to close */ if (async_output != null) async_output.Close (); @@ -1518,6 +1608,7 @@ namespace System.Diagnostics { error_stream.Close (); error_stream = null; } +#endif // MONO_FEATURE_PROCESS_START } // Release unmanaged resources diff --git a/mcs/class/System/System.Net.NetworkInformation/Ping.cs b/mcs/class/System/System.Net.NetworkInformation/Ping.cs index 157b888871d..abb6d5d6bce 100644 --- a/mcs/class/System/System.Net.NetworkInformation/Ping.cs +++ b/mcs/class/System/System.Net.NetworkInformation/Ping.cs @@ -26,6 +26,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // + using System; using System.IO; using System.Text; @@ -286,6 +287,7 @@ namespace System.Net.NetworkInformation { private PingReply SendUnprivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options) { +#if MONO_FEATURE_PROCESS_START DateTime sentTime = DateTime.UtcNow; Process ping = new Process (); @@ -325,6 +327,9 @@ namespace System.Net.NetworkInformation { } return new PingReply (address, buffer, options, trip_time, status); +#else + throw new NotSupportedException ("Ping is not supported on this platform."); +#endif // MONO_FEATURE_PROCESS_START } // Async @@ -592,4 +597,3 @@ namespace System.Net.NetworkInformation { } } } - diff --git a/mcs/class/System/Test/System.Diagnostics/ProcessStartInfoTest.cs b/mcs/class/System/Test/System.Diagnostics/ProcessStartInfoTest.cs index 53de1f66db4..7612efae6cc 100644 --- a/mcs/class/System/Test/System.Diagnostics/ProcessStartInfoTest.cs +++ b/mcs/class/System/Test/System.Diagnostics/ProcessStartInfoTest.cs @@ -8,6 +8,8 @@ // (c) 2007 Novell, Inc. (http://www.novell.com) // +#if MONO_FEATURE_PROCESS_START + using System; using System.Diagnostics; using System.Text; @@ -62,3 +64,5 @@ namespace MonoTests.System.Diagnostics } } } + +#endif // MONO_FEATURE_PROCESS_START diff --git a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs index d4372a1dddd..615b0aed3e6 100644 --- a/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs +++ b/mcs/class/System/Test/System.Diagnostics/ProcessTest.cs @@ -104,6 +104,7 @@ namespace MonoTests.System.Diagnostics } } +#if MONO_FEATURE_PROCESS_START [Test] // Start () public void Start1_FileName_Empty () { @@ -841,7 +842,6 @@ namespace MonoTests.System.Diagnostics Assert.AreEqual (1, exitedCalledCounter); } - ProcessStartInfo GetCrossPlatformStartInfo () { if (RunningOnUnix) { @@ -855,6 +855,7 @@ namespace MonoTests.System.Diagnostics } else return new ProcessStartInfo ("help", ""); } +#endif // MONO_FEATURE_PROCESS_START [Test] public void ProcessName_NotStarted () @@ -876,6 +877,7 @@ namespace MonoTests.System.Diagnostics Assert.IsNull (e.InnerException, "IOE inner exception should be null"); } +#if MONO_FEATURE_PROCESS_START [Test] [NUnit.Framework.Category ("MobileNotWorking")] public void ProcessName_AfterExit () @@ -906,6 +908,7 @@ namespace MonoTests.System.Diagnostics Assert.IsNull (e.InnerException, "IOE inner exception should be null"); } +#endif // MONO_FEATURE_PROCESS_START [Test] public void Handle_ThrowsOnNotStarted () @@ -923,6 +926,7 @@ namespace MonoTests.System.Diagnostics Assert.IsFalse (Process.GetCurrentProcess ().HasExited); } +#if MONO_FEATURE_PROCESS_START [Test] [NUnit.Framework.Category ("MobileNotWorking")] public void DisposeWithDisposedStreams () @@ -952,6 +956,7 @@ namespace MonoTests.System.Diagnostics p.StandardInput.Write ('x'); } } +#endif // MONO_FEATURE_PROCESS_START [Test] public void Modules () { diff --git a/mcs/mcs/Makefile b/mcs/mcs/Makefile index ef4f3e3c917..8b93d720fa1 100644 --- a/mcs/mcs/Makefile +++ b/mcs/mcs/Makefile @@ -30,6 +30,10 @@ ifndef NO_THREAD_ABORT REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_THREAD_ABORT endif +ifndef NO_PROCESS_START +REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_PROCESS_START +endif + LOCAL_MCS_FLAGS += $(REFERENCE_SOURCES_FLAGS) PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/4.5 diff --git a/mcs/mcs/driver.cs b/mcs/mcs/driver.cs index 994fdb8afd5..0a11914328a 100644 --- a/mcs/mcs/driver.cs +++ b/mcs/mcs/driver.cs @@ -201,6 +201,7 @@ namespace Mono.CSharp public static string GetPackageFlags (string packages, Report report) { +#if MONO_FEATURE_PROCESS_START ProcessStartInfo pi = new ProcessStartInfo (); pi.FileName = "pkg-config"; pi.RedirectStandardOutput = true; @@ -239,6 +240,9 @@ namespace Mono.CSharp p.Close (); return pkgout; +#else + throw new NotSupportedException ("Process.Start is not supported on this platform."); +#endif // MONO_FEATURE_PROCESS_START } // -- 2.25.1