Skip to content

Commit

Permalink
Use separate partials for iOS&tvOS instead of UnknowUnix in System.Di…
Browse files Browse the repository at this point in the history
…agnostics.Process (#61871)
  • Loading branch information
MaximLipnin authored Nov 24, 2021
1 parent bf1797a commit 8997e86
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,16 @@
<Compile Include="$(CommonPath)Interop\FreeBSD\Interop.Process.GetProcInfo.cs"
Link="Common\Interop\FreeBSD\Interop.Process.GetProcInfo.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnknownUnix)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
<Compile Include="System\Diagnostics\Process.iOS.cs" />
<Compile Include="System\Diagnostics\ProcessManager.iOS.cs" />
<Compile Include="System\Diagnostics\ProcessThread.iOS.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnknownUnix)' == 'true'">
<Compile Include="System\Diagnostics\Process.UnknownUnix.cs" />
<Compile Include="System\Diagnostics\ProcessManager.UnknownUnix.cs" />
<Compile Include="System\Diagnostics\ProcessThread.UnknownUnix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
<Compile Include="System\Diagnostics\Process.iOS.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Win32.Registry\src\Microsoft.Win32.Registry.csproj" />
<Reference Include="Microsoft.Win32.Primitives" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// 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
Expand All @@ -11,16 +9,12 @@ public partial class Process : IDisposable
/// 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(); }
Expand All @@ -37,8 +31,6 @@ internal DateTime StartTimeCore
/// 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(); }
Expand All @@ -48,8 +40,6 @@ 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).
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan UserProcessorTime
{
get { throw new PlatformNotSupportedException(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public bool HasExited
}

/// <summary>Gets the time the associated process was started.</summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public DateTime StartTime
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,56 @@ 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>
Expand All @@ -24,6 +74,45 @@ 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// 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
Expand All @@ -16,8 +14,6 @@ public static int[] GetProcessIds()
/// <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();
Expand Down
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();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// 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
Expand All @@ -22,8 +20,6 @@ private ThreadPriorityLevel PriorityLevelCore
/// Returns the amount of time the thread has spent running code inside the operating
/// system core.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan PrivilegedProcessorTime
{
get { throw new PlatformNotSupportedException(); } // Not available on POSIX
Expand All @@ -36,8 +32,6 @@ public TimeSpan PrivilegedProcessorTime
/// It is the sum of the System.Diagnostics.ProcessThread.UserProcessorTime and
/// System.Diagnostics.ProcessThread.PrivilegedProcessorTime.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan TotalProcessorTime
{
get { throw new PlatformNotSupportedException(); } // Not available on POSIX
Expand All @@ -47,8 +41,6 @@ public TimeSpan TotalProcessorTime
/// Returns the amount of time the associated thread has spent running code
/// inside the application (not the operating system core).
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan UserProcessorTime
{
get { throw new PlatformNotSupportedException(); } // Not available on POSIX
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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
{
/// <summary>
/// Returns or sets the priority level of the associated thread. The priority level is
/// not an absolute level, but instead contributes to the actual thread priority by
/// considering the priority class of the process.
/// </summary>
private ThreadPriorityLevel PriorityLevelCore
{
get { throw new PlatformNotSupportedException(); }
set { throw new PlatformNotSupportedException(); }
}

/// <summary>
/// Returns the amount of time the thread has spent running code inside the operating
/// system core.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan PrivilegedProcessorTime
{
get { throw new PlatformNotSupportedException(); }
}

private DateTime GetStartTime() => throw new PlatformNotSupportedException();
/// <summary>
/// Returns the amount of time the associated thread has spent utilizing the CPU.
/// It is the sum of the System.Diagnostics.ProcessThread.UserProcessorTime and
/// System.Diagnostics.ProcessThread.PrivilegedProcessorTime.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan TotalProcessorTime
{
get { throw new PlatformNotSupportedException(); }
}

/// <summary>
/// Returns the amount of time the associated thread has spent running code
/// inside the application (not the operating system core).
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public TimeSpan UserProcessorTime
{
get { throw new PlatformNotSupportedException(); }
}
}
}

0 comments on commit 8997e86

Please sign in to comment.