Skip to content

Commit 8997e86

Browse files
authored
Use separate partials for iOS&tvOS instead of UnknowUnix in System.Diagnostics.Process (#61871)
1 parent bf1797a commit 8997e86

File tree

8 files changed

+192
-26
lines changed

8 files changed

+192
-26
lines changed

src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,16 @@
340340
<Compile Include="$(CommonPath)Interop\FreeBSD\Interop.Process.GetProcInfo.cs"
341341
Link="Common\Interop\FreeBSD\Interop.Process.GetProcInfo.cs" />
342342
</ItemGroup>
343-
<ItemGroup Condition="'$(TargetsUnknownUnix)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
343+
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
344+
<Compile Include="System\Diagnostics\Process.iOS.cs" />
345+
<Compile Include="System\Diagnostics\ProcessManager.iOS.cs" />
346+
<Compile Include="System\Diagnostics\ProcessThread.iOS.cs" />
347+
</ItemGroup>
348+
<ItemGroup Condition="'$(TargetsUnknownUnix)' == 'true'">
344349
<Compile Include="System\Diagnostics\Process.UnknownUnix.cs" />
345350
<Compile Include="System\Diagnostics\ProcessManager.UnknownUnix.cs" />
346351
<Compile Include="System\Diagnostics\ProcessThread.UnknownUnix.cs" />
347352
</ItemGroup>
348-
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
349-
<Compile Include="System\Diagnostics\Process.iOS.cs" />
350-
</ItemGroup>
351353
<ItemGroup>
352354
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj" />
353355
<Reference Include="Microsoft.Win32.Primitives" />

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Runtime.Versioning;
5-
64
namespace System.Diagnostics
75
{
86
public partial class Process : IDisposable
@@ -11,16 +9,12 @@ public partial class Process : IDisposable
119
/// Creates an array of <see cref="Process"/> components that are associated with process resources on a
1210
/// remote computer. These process resources share the specified process name.
1311
/// </summary>
14-
[UnsupportedOSPlatform("ios")]
15-
[UnsupportedOSPlatform("tvos")]
1612
public static Process[] GetProcessesByName(string? processName, string machineName)
1713
{
1814
throw new PlatformNotSupportedException();
1915
}
2016

2117
/// <summary>Gets the amount of time the process has spent running code inside the operating system core.</summary>
22-
[UnsupportedOSPlatform("ios")]
23-
[UnsupportedOSPlatform("tvos")]
2418
public TimeSpan PrivilegedProcessorTime
2519
{
2620
get { throw new PlatformNotSupportedException(); }
@@ -37,8 +31,6 @@ internal DateTime StartTimeCore
3731
/// It is the sum of the <see cref='System.Diagnostics.Process.UserProcessorTime'/> and
3832
/// <see cref='System.Diagnostics.Process.PrivilegedProcessorTime'/>.
3933
/// </summary>
40-
[UnsupportedOSPlatform("ios")]
41-
[UnsupportedOSPlatform("tvos")]
4234
public TimeSpan TotalProcessorTime
4335
{
4436
get { throw new PlatformNotSupportedException(); }
@@ -48,8 +40,6 @@ public TimeSpan TotalProcessorTime
4840
/// Gets the amount of time the associated process has spent running code
4941
/// inside the application portion of the process (not the operating system core).
5042
/// </summary>
51-
[UnsupportedOSPlatform("ios")]
52-
[UnsupportedOSPlatform("tvos")]
5343
public TimeSpan UserProcessorTime
5444
{
5545
get { throw new PlatformNotSupportedException(); }

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public bool HasExited
193193
}
194194

195195
/// <summary>Gets the time the associated process was started.</summary>
196+
[UnsupportedOSPlatform("ios")]
197+
[UnsupportedOSPlatform("tvos")]
196198
public DateTime StartTime
197199
{
198200
get

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,56 @@ public void Kill(bool entireProcessTree)
1616
throw new PlatformNotSupportedException();
1717
}
1818

19+
/// <summary>
20+
/// Creates an array of <see cref="Process"/> components that are associated with process resources on a
21+
/// remote computer. These process resources share the specified process name.
22+
/// </summary>
23+
[UnsupportedOSPlatform("ios")]
24+
[UnsupportedOSPlatform("tvos")]
25+
public static Process[] GetProcessesByName(string? processName, string machineName)
26+
{
27+
throw new PlatformNotSupportedException();
28+
}
29+
30+
/// <summary>Gets the amount of time the process has spent running code inside the operating system core.</summary>
31+
[UnsupportedOSPlatform("ios")]
32+
[UnsupportedOSPlatform("tvos")]
33+
public TimeSpan PrivilegedProcessorTime
34+
{
35+
get { throw new PlatformNotSupportedException(); }
36+
}
37+
38+
/// <summary>Gets the time the associated process was started.</summary>
39+
[UnsupportedOSPlatform("ios")]
40+
[UnsupportedOSPlatform("tvos")]
41+
internal DateTime StartTimeCore
42+
{
43+
get { throw new PlatformNotSupportedException(); }
44+
}
45+
46+
/// <summary>
47+
/// Gets the amount of time the associated process has spent utilizing the CPU.
48+
/// It is the sum of the <see cref='System.Diagnostics.Process.UserProcessorTime'/> and
49+
/// <see cref='System.Diagnostics.Process.PrivilegedProcessorTime'/>.
50+
/// </summary>
51+
[UnsupportedOSPlatform("ios")]
52+
[UnsupportedOSPlatform("tvos")]
53+
public TimeSpan TotalProcessorTime
54+
{
55+
get { throw new PlatformNotSupportedException(); }
56+
}
57+
58+
/// <summary>
59+
/// Gets the amount of time the associated process has spent running code
60+
/// inside the application portion of the process (not the operating system core).
61+
/// </summary>
62+
[UnsupportedOSPlatform("ios")]
63+
[UnsupportedOSPlatform("tvos")]
64+
public TimeSpan UserProcessorTime
65+
{
66+
get { throw new PlatformNotSupportedException(); }
67+
}
68+
1969
/// <summary>
2070
/// Returns all immediate child processes.
2171
/// </summary>
@@ -24,6 +74,45 @@ private IReadOnlyList<Process> GetChildProcesses(Process[]? processes = null)
2474
throw new PlatformNotSupportedException();
2575
}
2676

77+
/// <summary>Gets parent process ID</summary>
78+
private int GetParentProcessId =>
79+
throw new PlatformNotSupportedException();
80+
81+
/// <summary>
82+
/// Gets or sets which processors the threads in this process can be scheduled to run on.
83+
/// </summary>
84+
private IntPtr ProcessorAffinityCore
85+
{
86+
get { throw new PlatformNotSupportedException(); }
87+
set { throw new PlatformNotSupportedException(); }
88+
}
89+
90+
/// <summary>
91+
/// Make sure we have obtained the min and max working set limits.
92+
/// </summary>
93+
private void GetWorkingSetLimits(out IntPtr minWorkingSet, out IntPtr maxWorkingSet)
94+
{
95+
throw new PlatformNotSupportedException();
96+
}
97+
98+
/// <summary>Sets one or both of the minimum and maximum working set limits.</summary>
99+
/// <param name="newMin">The new minimum working set limit, or null not to change it.</param>
100+
/// <param name="newMax">The new maximum working set limit, or null not to change it.</param>
101+
/// <param name="resultingMin">The resulting minimum working set limit after any changes applied.</param>
102+
/// <param name="resultingMax">The resulting maximum working set limit after any changes applied.</param>
103+
private void SetWorkingSetLimitsCore(IntPtr? newMin, IntPtr? newMax, out IntPtr resultingMin, out IntPtr resultingMax)
104+
{
105+
throw new PlatformNotSupportedException();
106+
}
107+
108+
/// <summary>Gets execution path</summary>
109+
private string GetPathToOpenFile()
110+
{
111+
throw new PlatformNotSupportedException();
112+
}
113+
114+
private int ParentProcessId => throw new PlatformNotSupportedException();
115+
27116
private static bool IsProcessInvalidException(Exception e) =>
28117
// InvalidOperationException signifies conditions such as the process already being dead.
29118
// Win32Exception signifies issues such as insufficient permissions to get details on the process.

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.UnknownUnix.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Runtime.Versioning;
5-
64
namespace System.Diagnostics
75
{
86
internal static partial class ProcessManager
@@ -16,8 +14,6 @@ public static int[] GetProcessIds()
1614
/// <summary>Gets process infos for each process on the specified machine.</summary>
1715
/// <param name="machineName">The target machine.</param>
1816
/// <returns>An array of process infos, one per found process.</returns>
19-
[UnsupportedOSPlatform("ios")]
20-
[UnsupportedOSPlatform("tvos")]
2117
public static ProcessInfo[] GetProcessInfos(string machineName)
2218
{
2319
throw new PlatformNotSupportedException();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Runtime.Versioning;
5+
6+
namespace System.Diagnostics
7+
{
8+
internal static partial class ProcessManager
9+
{
10+
/// <summary>Gets the IDs of all processes on the current machine.</summary>
11+
public static int[] GetProcessIds()
12+
{
13+
throw new PlatformNotSupportedException();
14+
}
15+
16+
/// <summary>Gets process infos for each process on the specified machine.</summary>
17+
/// <param name="machineName">The target machine.</param>
18+
/// <returns>An array of process infos, one per found process.</returns>
19+
[UnsupportedOSPlatform("ios")]
20+
[UnsupportedOSPlatform("tvos")]
21+
public static ProcessInfo[] GetProcessInfos(string machineName)
22+
{
23+
throw new PlatformNotSupportedException();
24+
}
25+
26+
/// <summary>Gets an array of module infos for the specified process.</summary>
27+
/// <param name="processId">The ID of the process whose modules should be enumerated.</param>
28+
/// <returns>The array of modules.</returns>
29+
internal static ProcessModuleCollection GetModules(int processId)
30+
{
31+
return new ProcessModuleCollection(0);
32+
}
33+
34+
private static ProcessInfo CreateProcessInfo(int pid)
35+
{
36+
throw new PlatformNotSupportedException();
37+
}
38+
}
39+
}

src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.UnknownUnix.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Runtime.Versioning;
5-
64
namespace System.Diagnostics
75
{
86
public partial class ProcessThread
@@ -22,8 +20,6 @@ private ThreadPriorityLevel PriorityLevelCore
2220
/// Returns the amount of time the thread has spent running code inside the operating
2321
/// system core.
2422
/// </summary>
25-
[UnsupportedOSPlatform("ios")]
26-
[UnsupportedOSPlatform("tvos")]
2723
public TimeSpan PrivilegedProcessorTime
2824
{
2925
get { throw new PlatformNotSupportedException(); } // Not available on POSIX
@@ -36,8 +32,6 @@ public TimeSpan PrivilegedProcessorTime
3632
/// It is the sum of the System.Diagnostics.ProcessThread.UserProcessorTime and
3733
/// System.Diagnostics.ProcessThread.PrivilegedProcessorTime.
3834
/// </summary>
39-
[UnsupportedOSPlatform("ios")]
40-
[UnsupportedOSPlatform("tvos")]
4135
public TimeSpan TotalProcessorTime
4236
{
4337
get { throw new PlatformNotSupportedException(); } // Not available on POSIX
@@ -47,8 +41,6 @@ public TimeSpan TotalProcessorTime
4741
/// Returns the amount of time the associated thread has spent running code
4842
/// inside the application (not the operating system core).
4943
/// </summary>
50-
[UnsupportedOSPlatform("ios")]
51-
[UnsupportedOSPlatform("tvos")]
5244
public TimeSpan UserProcessorTime
5345
{
5446
get { throw new PlatformNotSupportedException(); } // Not available on POSIX
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Runtime.Versioning;
5+
6+
namespace System.Diagnostics
7+
{
8+
public partial class ProcessThread
9+
{
10+
/// <summary>
11+
/// Returns or sets the priority level of the associated thread. The priority level is
12+
/// not an absolute level, but instead contributes to the actual thread priority by
13+
/// considering the priority class of the process.
14+
/// </summary>
15+
private ThreadPriorityLevel PriorityLevelCore
16+
{
17+
get { throw new PlatformNotSupportedException(); }
18+
set { throw new PlatformNotSupportedException(); }
19+
}
20+
21+
/// <summary>
22+
/// Returns the amount of time the thread has spent running code inside the operating
23+
/// system core.
24+
/// </summary>
25+
[UnsupportedOSPlatform("ios")]
26+
[UnsupportedOSPlatform("tvos")]
27+
public TimeSpan PrivilegedProcessorTime
28+
{
29+
get { throw new PlatformNotSupportedException(); }
30+
}
31+
32+
private DateTime GetStartTime() => throw new PlatformNotSupportedException();
33+
/// <summary>
34+
/// Returns the amount of time the associated thread has spent utilizing the CPU.
35+
/// It is the sum of the System.Diagnostics.ProcessThread.UserProcessorTime and
36+
/// System.Diagnostics.ProcessThread.PrivilegedProcessorTime.
37+
/// </summary>
38+
[UnsupportedOSPlatform("ios")]
39+
[UnsupportedOSPlatform("tvos")]
40+
public TimeSpan TotalProcessorTime
41+
{
42+
get { throw new PlatformNotSupportedException(); }
43+
}
44+
45+
/// <summary>
46+
/// Returns the amount of time the associated thread has spent running code
47+
/// inside the application (not the operating system core).
48+
/// </summary>
49+
[UnsupportedOSPlatform("ios")]
50+
[UnsupportedOSPlatform("tvos")]
51+
public TimeSpan UserProcessorTime
52+
{
53+
get { throw new PlatformNotSupportedException(); }
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)