From 6ffd88e89707f9b3eb4f486627deae9ac2f1b0d7 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Thu, 18 Nov 2021 19:29:32 +0300 Subject: [PATCH] [iOS] Follow up changes for 61590 (#61670) This is a follow up PR for #61590. It includes: - additional UnsupportedOSPlatform annotations for some System.Diagnostics.Process APIs throwing PNSE on iOS/tvOS (they started doing so after excluding some managed logic around librpoc ) - fixing a bit ugly workaround for CS0649 (see https://github.com/dotnet/runtime/pull/61590/files#r749525127) - used a local pragma in the ThreadInfo class. - skipping the respective S.D.P. tests ( it will address [iOS/tvOS] System.Diagnostics.Tests.ProcessTests.TestGetProcesses fails on devices #60588 as well) --- .../ref/System.Diagnostics.Process.cs | 18 ++++++++++ .../src/System.Diagnostics.Process.csproj | 6 ++-- .../src/System/Diagnostics/Process.BSD.cs | 3 ++ .../src/System/Diagnostics/Process.Linux.cs | 3 ++ .../System/Diagnostics/Process.UnknownUnix.cs | 10 ++++++ .../src/System/Diagnostics/Process.Windows.cs | 2 ++ .../src/System/Diagnostics/Process.cs | 6 ++++ .../src/System/Diagnostics/Process.iOS.cs | 33 +++++++++++++++++++ .../System/Diagnostics/ProcessManager.Unix.cs | 3 ++ .../Diagnostics/ProcessManager.UnknownUnix.cs | 4 +++ .../Diagnostics/ProcessThread.UnknownUnix.cs | 8 +++++ .../src/System/Diagnostics/ThreadInfo.cs | 2 ++ .../tests/ProcessModuleTests.cs | 2 ++ .../tests/ProcessTests.cs | 15 +++++++++ .../tests/ProcessThreadTests.cs | 2 ++ 15 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs 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 4c98a461f323e..53a49f897c1a2 100644 --- a/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs +++ b/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs @@ -84,7 +84,11 @@ public Process() { } public System.DateTime StartTime { get { throw null; } } public System.ComponentModel.ISynchronizeInvoke? SynchronizingObject { get { throw null; } set { } } public System.Diagnostics.ProcessThreadCollection Threads { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.TimeSpan TotalProcessorTime { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.TimeSpan UserProcessorTime { get { throw null; } } [System.ObsoleteAttribute("Process.VirtualMemorySize has been deprecated because the type of the property can't represent all valid results. Use System.Diagnostics.Process.VirtualMemorySize64 instead.")] public int VirtualMemorySize { get { throw null; } } @@ -106,9 +110,17 @@ public static void EnterDebugMode() { } public static System.Diagnostics.Process GetCurrentProcess() { throw null; } public static System.Diagnostics.Process GetProcessById(int processId) { throw null; } public static System.Diagnostics.Process GetProcessById(int processId, string machineName) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Diagnostics.Process[] GetProcesses() { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Diagnostics.Process[] GetProcesses(string machineName) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Diagnostics.Process[] GetProcessesByName(string? processName) { throw null; } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public static System.Diagnostics.Process[] GetProcessesByName(string? processName, string machineName) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] @@ -233,6 +245,8 @@ internal ProcessThread() { } public int IdealProcessor { set { } } public bool PriorityBoostEnabled { get { throw null; } set { } } public System.Diagnostics.ThreadPriorityLevel PriorityLevel { [System.Runtime.Versioning.SupportedOSPlatform("windows")] [System.Runtime.Versioning.SupportedOSPlatform("linux")] [System.Runtime.Versioning.SupportedOSPlatform("freebsd")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.TimeSpan PrivilegedProcessorTime { get { throw null; } } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public System.IntPtr ProcessorAffinity { set { } } @@ -241,7 +255,11 @@ public System.IntPtr ProcessorAffinity { set { } } [System.Runtime.Versioning.SupportedOSPlatform("linux")] public System.DateTime StartTime { get { throw null; } } public System.Diagnostics.ThreadState ThreadState { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.TimeSpan TotalProcessorTime { get { throw null; } } + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] + [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] public System.TimeSpan UserProcessorTime { get { throw null; } } public System.Diagnostics.ThreadWaitReason WaitReason { get { throw null; } } public void ResetIdealProcessor() { } diff --git a/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj b/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj index a47851bff81cb..3573942a5d67c 100644 --- a/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj +++ b/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj @@ -5,7 +5,6 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent);$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS enable - $(NoWarn);0649 SR.Process_PlatformNotSupported @@ -329,7 +328,7 @@ - + @@ -350,6 +349,9 @@ + + + diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs index 02b7cce02263d..3380481ca5c8e 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; +using System.Runtime.Versioning; namespace System.Diagnostics { @@ -12,6 +13,8 @@ public partial class Process /// Creates an array of components that are associated with process resources on a /// remote computer. These process resources share the specified process name. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcessesByName(string? processName, string machineName) { if (processName == null) diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs index 6942d82d6d159..016327ad61ab5 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using System.Globalization; using System.IO; +using System.Runtime.Versioning; using System.Text; namespace System.Diagnostics @@ -17,6 +18,8 @@ public partial class Process : IDisposable /// Creates an array of components that are associated with process resources on a /// remote computer. These process resources share the specified process name. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcessesByName(string? processName, string machineName) { ProcessManager.ThrowIfRemoteMachine(machineName); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs index 897fde77e9a75..4b5f5116c14f4 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.Versioning; + namespace System.Diagnostics { public partial class Process : IDisposable @@ -9,12 +11,16 @@ public partial class Process : IDisposable /// Creates an array of components that are associated with process resources on a /// remote computer. These process resources share the specified process name. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcessesByName(string? processName, string machineName) { throw new PlatformNotSupportedException(); } /// Gets the amount of time the process has spent running code inside the operating system core. + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public TimeSpan PrivilegedProcessorTime { get { throw new PlatformNotSupportedException(); } @@ -31,6 +37,8 @@ internal DateTime StartTimeCore /// It is the sum of the and /// . /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public TimeSpan TotalProcessorTime { get { throw new PlatformNotSupportedException(); } @@ -40,6 +48,8 @@ public TimeSpan TotalProcessorTime /// Gets the amount of time the associated process has spent running code /// inside the application portion of the process (not the operating system core). /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public TimeSpan UserProcessorTime { get { throw new PlatformNotSupportedException(); } diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs index 9c59f54333bf6..ad7209a3f198d 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs @@ -21,6 +21,8 @@ public partial class Process : IDisposable /// Creates an array of components that are associated with process resources on a /// remote computer. These process resources share the specified process name. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcessesByName(string? processName, string machineName) { if (processName == null) 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 0c5bf3a96542a..a486b5d76cfee 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs @@ -1039,6 +1039,8 @@ public static Process GetProcessById(int processId) /// local computer. These process resources share the specified process name. /// /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcessesByName(string? processName) { return GetProcessesByName(processName, "."); @@ -1050,6 +1052,8 @@ public static Process[] GetProcessesByName(string? processName) /// component for each process resource on the local computer. /// /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcesses() { return GetProcesses("."); @@ -1062,6 +1066,8 @@ public static Process[] GetProcesses() /// process resource on the specified computer. /// /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static Process[] GetProcesses(string machineName) { bool isRemoteMachine = ProcessManager.IsRemoteMachine(machineName); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs new file mode 100644 index 0000000000000..fd1f50ccd4323 --- /dev/null +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.Versioning; + +namespace System.Diagnostics +{ + public partial class Process : IDisposable + { + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] + public void Kill(bool entireProcessTree) + { + throw new PlatformNotSupportedException(); + } + + /// + /// Returns all immediate child processes. + /// + private IReadOnlyList GetChildProcesses(Process[]? processes = null) + { + throw new PlatformNotSupportedException(); + } + + private static bool IsProcessInvalidException(Exception e) => + // InvalidOperationException signifies conditions such as the process already being dead. + // Win32Exception signifies issues such as insufficient permissions to get details on the process. + // In either case, the predicate couldn't be applied so return the fallback result. + e is InvalidOperationException || e is Win32Exception; + } +} diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs index 5df7ece329e1d..d9e27a8c54276 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs @@ -3,6 +3,7 @@ using Microsoft.Win32.SafeHandles; using System.Collections.Generic; +using System.Runtime.Versioning; using System.Text; namespace System.Diagnostics @@ -44,6 +45,8 @@ public static bool IsProcessRunning(int processId) /// Gets the IDs of all processes on the specified machine. /// The machine to examine. /// An array of process IDs from the specified machine. + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static int[] GetProcessIds(string machineName) { ThrowIfRemoteMachine(machineName); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.UnknownUnix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.UnknownUnix.cs index aa08c5b591f35..2fddb3b200e7e 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.UnknownUnix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.UnknownUnix.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.Versioning; + namespace System.Diagnostics { internal static partial class ProcessManager @@ -14,6 +16,8 @@ public static int[] GetProcessIds() /// Gets process infos for each process on the specified machine. /// The target machine. /// An array of process infos, one per found process. + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public static ProcessInfo[] GetProcessInfos(string machineName) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.UnknownUnix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.UnknownUnix.cs index 6d947625ddd6b..acb79218a5b27 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.UnknownUnix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.UnknownUnix.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.Versioning; + namespace System.Diagnostics { public partial class ProcessThread @@ -20,6 +22,8 @@ private ThreadPriorityLevel PriorityLevelCore /// Returns the amount of time the thread has spent running code inside the operating /// system core. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public TimeSpan PrivilegedProcessorTime { get { throw new PlatformNotSupportedException(); } // Not available on POSIX @@ -32,6 +36,8 @@ public TimeSpan PrivilegedProcessorTime /// It is the sum of the System.Diagnostics.ProcessThread.UserProcessorTime and /// System.Diagnostics.ProcessThread.PrivilegedProcessorTime. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public TimeSpan TotalProcessorTime { get { throw new PlatformNotSupportedException(); } // Not available on POSIX @@ -41,6 +47,8 @@ public TimeSpan TotalProcessorTime /// Returns the amount of time the associated thread has spent running code /// inside the application (not the operating system core). /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] public TimeSpan UserProcessorTime { get { throw new PlatformNotSupportedException(); } // Not available on POSIX diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ThreadInfo.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ThreadInfo.cs index c12c143e5a53a..1205e732e6732 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ThreadInfo.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ThreadInfo.cs @@ -12,6 +12,7 @@ namespace System.Diagnostics /// internal sealed class ThreadInfo { +#pragma warning disable CS0649 // The fields are unused on iOS/tvOS as the respective managed logic (mostly around libproc) is excluded. internal ulong _threadId; internal int _processId; internal int _basePriority; @@ -19,5 +20,6 @@ internal sealed class ThreadInfo internal IntPtr _startAddress; internal ThreadState _threadState; internal ThreadWaitReason _threadWaitReason; +#pragma warning restore CS0649 } } diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs index 33f84717da719..fd4e9d2751753 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs @@ -10,6 +10,7 @@ namespace System.Diagnostics.Tests public partial class ProcessModuleTests : ProcessTestBase { [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void TestModuleProperties() { ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; @@ -29,6 +30,7 @@ public void TestModuleProperties() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void Modules_Get_ContainsHostFileName() { ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index 880da43a64653..19a8898969620 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -414,6 +414,7 @@ public void TestExitTime() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void StartTime_GetNotStarted_ThrowsInvalidOperationException() { var process = new Process(); @@ -525,6 +526,7 @@ public void MachineName_GetNotStarted_ThrowsInvalidOperationException() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void TestMainModule() { Process p = Process.GetCurrentProcess(); @@ -854,6 +856,7 @@ public void TotalProcessorTime_PerformLoop_TotalProcessorTimeValid() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void UserProcessorTime_GetNotStarted_ThrowsInvalidOperationException() { var process = new Process(); @@ -861,6 +864,7 @@ public void UserProcessorTime_GetNotStarted_ThrowsInvalidOperationException() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void PriviledgedProcessorTime_GetNotStarted_ThrowsInvalidOperationException() { var process = new Process(); @@ -868,6 +872,7 @@ public void PriviledgedProcessorTime_GetNotStarted_ThrowsInvalidOperationExcepti } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void TotalProcessorTime_GetNotStarted_ThrowsInvalidOperationException() { var process = new Process(); @@ -1105,6 +1110,7 @@ public void TestGetProcessById() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void TestGetProcesses() { Process currentProcess = Process.GetCurrentProcess(); @@ -1170,6 +1176,7 @@ public void GetProcesses_RemoteMachinePath_ReturnsExpected() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void GetProcessesByName_ProcessName_ReturnsExpected() { // Get the current process using its name @@ -1229,6 +1236,7 @@ public static IEnumerable MachineName_Remote_TestData() [Theory] [MemberData(nameof(MachineName_TestData))] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void GetProcessesByName_ProcessNameMachineName_ReturnsExpected(string machineName) { Process currentProcess = Process.GetCurrentProcess(); @@ -1255,6 +1263,7 @@ public void GetProcessesByName_RemoteMachineNameWindows_ReturnsExpected(string m } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void GetProcessesByName_NoSuchProcess_ReturnsEmpty() { string processName = Guid.NewGuid().ToString("N"); @@ -1262,6 +1271,7 @@ public void GetProcessesByName_NoSuchProcess_ReturnsEmpty() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void GetProcessesByName_NullMachineName_ThrowsArgumentNullException() { Process currentProcess = Process.GetCurrentProcess(); @@ -1269,6 +1279,7 @@ public void GetProcessesByName_NullMachineName_ThrowsArgumentNullException() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void GetProcessesByName_EmptyMachineName_ThrowsArgumentException() { Process currentProcess = Process.GetCurrentProcess(); @@ -1331,6 +1342,7 @@ public void StartInfo_SetOnRunningProcess_ThrowsInvalidOperationException() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void StartInfo_SetGet_ReturnsExpected() { var process = new Process() { StartInfo = new ProcessStartInfo(RemoteExecutor.HostRunner) }; @@ -1715,6 +1727,7 @@ public void MainWindowTitle_GetWithGui_ShouldRefresh_Windows() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void RefreshResetsAllRefreshableFields() { // testing Process.Responding using a real unresponsive process would be very hard to do properly @@ -2271,6 +2284,7 @@ public void BothArgumentSetAndArgumentListSet() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void Kill_EntireProcessTree_True_ProcessNotStarted_ThrowsInvalidOperationException() { var process = new Process(); @@ -2300,6 +2314,7 @@ public void Kill_EntireProcessTree_True_CalledByNonLocalProcess_ThrowsInvalidOpe } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void Kill_EntireProcessTree_True_CalledOnCallingProcess_ThrowsInvalidOperationException() { var process = Process.GetCurrentProcess(); diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessThreadTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessThreadTests.cs index 2266582ac5190..6db4fd1a2cdee 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessThreadTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessThreadTests.cs @@ -46,6 +46,7 @@ public void TestCommonPriorityAndTimeProperties() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void TestThreadCount() { int numOfThreads = 10; @@ -161,6 +162,7 @@ await Task.Factory.StartNew(() => } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "libproc is not supported on iOS/tvOS")] public void TestStartAddressProperty() { using (Process p = Process.GetCurrentProcess())