Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate unsupported APIs in System.Diagnostics.Process #57120

Merged
merged 7 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Process() { }
public long PrivateMemorySize64 { get { throw null; } }
public System.TimeSpan PrivilegedProcessorTime { get { throw null; } }
public string ProcessName { get { throw null; } }
public System.IntPtr ProcessorAffinity { get { throw null; } set { } }
public System.IntPtr ProcessorAffinity { [System.Runtime.Versioning.SupportedOSPlatform("windows")] [System.Runtime.Versioning.SupportedOSPlatform("linux")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatform("windows")] [System.Runtime.Versioning.SupportedOSPlatform("linux")] set { } }
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved
public bool Responding { get { throw null; } }
public Microsoft.Win32.SafeHandles.SafeProcessHandle SafeHandle { get { throw null; } }
public int SessionId { get { throw null; } }
Expand Down Expand Up @@ -237,7 +237,7 @@ internal ProcessThread() { }
public int Id { get { throw null; } }
public int IdealProcessor { set { } }
public bool PriorityBoostEnabled { get { throw null; } set { } }
public System.Diagnostics.ThreadPriorityLevel PriorityLevel { get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] 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 { } }
public System.TimeSpan PrivilegedProcessorTime { get { throw null; } }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public System.IntPtr ProcessorAffinity { set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public TimeSpan PrivilegedProcessorTime
get { throw new PlatformNotSupportedException(); }
}

/// <summary>Gets the time the associated process was started.</summary>
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ public string ProcessName
/// </devdoc>
public IntPtr ProcessorAffinity
{
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows and Linux support it, everything else does not.

get
{
if (!_haveProcessorAffinity)
Expand All @@ -537,6 +539,8 @@ public IntPtr ProcessorAffinity
}
return _processorAffinity;
}
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
set
{
ProcessorAffinityCore = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,5 @@ internal static void ThrowIfRemoteMachine(string machineName)
throw new PlatformNotSupportedException(SR.RemoteMachinesNotSupported);
}
}
public static IntPtr GetMainWindowHandle(int processId)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as pointed by @buyaa-n in #57090 (comment) it turned out to be dead code

{
throw new PlatformNotSupportedException(); // Window handle is a Windows concept
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public bool PriorityBoostEnabled
/// </devdoc>
public ThreadPriorityLevel PriorityLevel
{
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("freebsd")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows, Linux and FreeBSD support it, everything else does not.

get
{
if (!_priorityLevel.HasValue)
Expand Down