-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/6.0-maui] Exclude the managed code around libproc on iOS/tvOS (
#62235) * Exclude the managed code around libproc on iOS/tvOS (#61590) Since libproc is a private Apple API, it is not available on iOS/tvOS and should be excluded (see #61265 (comment) and above for more details). This PR excludes $(CommonPath)Interop\OSX\Interop.libproc.cs on the iOS/tvOS as well as makes some methods in Process, ProcessManager, and ProcessThread classes calling that API throw PNSE so that for iOS/tvOS it's possible to re-use the respective *.UnknownUnix.cs parts. * [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) * Skip System.Diagnostics.TextWriterTraceListenerTests.XmlWriterTraceListenerTests on iOS/tvOS (#61807) This marks System.Diagnostics.TextWriterTraceListenerTests.XmlWriterTraceListenerTests withSkipOnPlatform attribute for iOS/tvOS as those tests try to create a process info, which throws PNSE after S.D.Process API's around libproc have been excluded in #61590. * Disable several failing tests on iOSSimulator arm64 #61826 A few tests popped up as failures on the rolling build due to parts of System.Diagnostics.Process throwing PNSE. Disabled the functional tests from running on arm64 as mlaunch can't detect the return code. * Use separate partials for iOS&tvOS instead of UnknowUnix in System.Diagnostics.Process (#61871) * Remove NoWarn removal
- Loading branch information
1 parent
5e7fb16
commit 6c8d2b0
Showing
19 changed files
with
292 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// 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(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates an array of <see cref="Process"/> components that are associated with process resources on a | ||
/// remote computer. These process resources share the specified process name. | ||
/// </summary> | ||
[UnsupportedOSPlatform("ios")] | ||
[UnsupportedOSPlatform("tvos")] | ||
public static Process[] GetProcessesByName(string? processName, string machineName) | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
/// <summary>Gets the amount of time the process has spent running code inside the operating system core.</summary> | ||
[UnsupportedOSPlatform("ios")] | ||
[UnsupportedOSPlatform("tvos")] | ||
public TimeSpan PrivilegedProcessorTime | ||
{ | ||
get { throw new PlatformNotSupportedException(); } | ||
} | ||
|
||
/// <summary>Gets the time the associated process was started.</summary> | ||
[UnsupportedOSPlatform("ios")] | ||
[UnsupportedOSPlatform("tvos")] | ||
internal DateTime StartTimeCore | ||
{ | ||
get { throw new PlatformNotSupportedException(); } | ||
} | ||
|
||
/// <summary> | ||
/// Gets the amount of time the associated process has spent utilizing the CPU. | ||
/// It is the sum of the <see cref='System.Diagnostics.Process.UserProcessorTime'/> and | ||
/// <see cref='System.Diagnostics.Process.PrivilegedProcessorTime'/>. | ||
/// </summary> | ||
[UnsupportedOSPlatform("ios")] | ||
[UnsupportedOSPlatform("tvos")] | ||
public TimeSpan TotalProcessorTime | ||
{ | ||
get { throw new PlatformNotSupportedException(); } | ||
} | ||
|
||
/// <summary> | ||
/// Gets the amount of time the associated process has spent running code | ||
/// inside the application portion of the process (not the operating system core). | ||
/// </summary> | ||
[UnsupportedOSPlatform("ios")] | ||
[UnsupportedOSPlatform("tvos")] | ||
public TimeSpan UserProcessorTime | ||
{ | ||
get { throw new PlatformNotSupportedException(); } | ||
} | ||
|
||
/// <summary> | ||
/// Returns all immediate child processes. | ||
/// </summary> | ||
private IReadOnlyList<Process> GetChildProcesses(Process[]? processes = null) | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
/// <summary>Gets parent process ID</summary> | ||
private int GetParentProcessId => | ||
throw new PlatformNotSupportedException(); | ||
|
||
/// <summary> | ||
/// Gets or sets which processors the threads in this process can be scheduled to run on. | ||
/// </summary> | ||
private IntPtr ProcessorAffinityCore | ||
{ | ||
get { throw new PlatformNotSupportedException(); } | ||
set { throw new PlatformNotSupportedException(); } | ||
} | ||
|
||
/// <summary> | ||
/// Make sure we have obtained the min and max working set limits. | ||
/// </summary> | ||
private void GetWorkingSetLimits(out IntPtr minWorkingSet, out IntPtr maxWorkingSet) | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
/// <summary>Sets one or both of the minimum and maximum working set limits.</summary> | ||
/// <param name="newMin">The new minimum working set limit, or null not to change it.</param> | ||
/// <param name="newMax">The new maximum working set limit, or null not to change it.</param> | ||
/// <param name="resultingMin">The resulting minimum working set limit after any changes applied.</param> | ||
/// <param name="resultingMax">The resulting maximum working set limit after any changes applied.</param> | ||
private void SetWorkingSetLimitsCore(IntPtr? newMin, IntPtr? newMax, out IntPtr resultingMin, out IntPtr resultingMax) | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
/// <summary>Gets execution path</summary> | ||
private string GetPathToOpenFile() | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
private int ParentProcessId => 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.iOS.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// 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 | ||
{ | ||
/// <summary>Gets the IDs of all processes on the current machine.</summary> | ||
public static int[] GetProcessIds() | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
/// <summary>Gets process infos for each process on the specified machine.</summary> | ||
/// <param name="machineName">The target machine.</param> | ||
/// <returns>An array of process infos, one per found process.</returns> | ||
[UnsupportedOSPlatform("ios")] | ||
[UnsupportedOSPlatform("tvos")] | ||
public static ProcessInfo[] GetProcessInfos(string machineName) | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
/// <summary>Gets an array of module infos for the specified process.</summary> | ||
/// <param name="processId">The ID of the process whose modules should be enumerated.</param> | ||
/// <returns>The array of modules.</returns> | ||
internal static ProcessModuleCollection GetModules(int processId) | ||
{ | ||
return new ProcessModuleCollection(0); | ||
} | ||
|
||
private static ProcessInfo CreateProcessInfo(int pid) | ||
{ | ||
throw new PlatformNotSupportedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.