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

Backport docs for System.Diagnostics.Process #48137

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -37,6 +37,9 @@ internal SafeProcessHandle(int processId, SafeWaitHandle handle) :

internal int ProcessId { get; }

/// <summary>Closes the handle.</summary>
/// <returns>On Windows, returns <see langword="true" /> if the handle is closed successfully; <see langword="false" /> otherwise. On Unix, always returns <see langword="true" /></returns>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// <returns>On Windows, returns <see langword="true" /> if the handle is closed successfully; <see langword="false" /> otherwise. On Unix, always returns <see langword="true" /></returns>
/// <returns>On Windows, returns <see langword="true" /> if the handle is closed successfully; <see langword="false" /> otherwise. On Unix, always returns <see langword="true" />.</returns>

/// <remarks>On Windows, to get extended error information, call <see cref="System.Runtime.InteropServices.Marshal.GetLastWin32Error()" />.</remarks>
Comment on lines +40 to +42
Copy link
Member Author

Choose a reason for hiding this comment

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

protected override bool ReleaseHandle()
{
if (_releaseRef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

namespace Microsoft.Win32.SafeHandles
{
/// <summary>Provides a managed wrapper for a process handle.</summary>
public sealed partial class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid
{
/// <summary>Closes the handle.</summary>
/// <returns>On Windows, returns <see langword="true" /> if the handle is closed successfully; <see langword="false" /> otherwise. On Unix, always returns <see langword="true" /></returns>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// <returns>On Windows, returns <see langword="true" /> if the handle is closed successfully; <see langword="false" /> otherwise. On Unix, always returns <see langword="true" /></returns>
/// <returns>On Windows, returns <see langword="true" /> if the handle is closed successfully; <see langword="false" /> otherwise. On Unix, always returns <see langword="true" />.</returns>

/// <remarks>On Windows, to get extended error information, call <see cref="System.Runtime.InteropServices.Marshal.GetLastWin32Error()" />.</remarks>
protected override bool ReleaseHandle()
{
return Interop.Kernel32.CloseHandle(handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Microsoft.Win32.SafeHandles
{
/// <summary>Provides a managed wrapper for a process handle.</summary>
public sealed partial class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid
{
internal static readonly SafeProcessHandle InvalidHandle = new SafeProcessHandle();
carlossanlop marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -29,6 +30,13 @@ internal SafeProcessHandle(IntPtr handle)
{
}

/// <summary>Initializes a new instance of the <see cref="Microsoft.Win32.SafeHandles.SafeProcessHandle" /> class from the specified handle, indicating whether to release the handle during the finalization phase.</summary>
/// <param name="existingHandle">The handle to be wrapped.</param>
/// <param name="ownsHandle"><see langword="true" /> to reliably let <see cref="Microsoft.Win32.SafeHandles.SafeProcessHandle" /> release the handle during the finalization phase; otherwise, <see langword="false" />.</param>
/// <remarks><format type="text/markdown"><![CDATA[
/// > [!IMPORTANT]
/// > This type implements the <xref:System.IDisposable> interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its <xref:System.IDisposable.Dispose%2A> method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the <xref:System.IDisposable> interface topic.
/// ]]></format></remarks>
public SafeProcessHandle(IntPtr existingHandle, bool ownsHandle)
: base(ownsHandle)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent);$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS</TargetFrameworks>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- Suppress unused field warnings when using PlatformNotSupportedException stubs -->
<NoWarn Condition=" '$(TargetsFreeBSD)' == 'true' or '$(TargetsUnknownUnix)' == 'true' ">$(NoWarn);0649</NoWarn>
</PropertyGroup>
Expand Down Expand Up @@ -146,7 +147,7 @@
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetPriorityClass.cs"
Link="Common\Interop\Windows\Kernel32\Interop.SetPriorityClass.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.DuplicateHandle_SafeFileHandle.cs"
Link="Common\Interop\Windows\kernel32\Interop.DuplicateHandle_SafeFileHandle.cs" />
Link="Common\Interop\Windows\kernel32\Interop.DuplicateHandle_SafeFileHandle.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.DuplicateHandle_SafeWaitHandle.cs"
Link="Common\Interop\Windows\kernel32\Interop.DuplicateHandle_SafeWaitHandle.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.ProcessWaitHandle.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@

namespace System.Diagnostics
{
/// <summary>Represents the method that will handle the <see cref="System.Diagnostics.Process.OutputDataReceived" /> event or <see cref="System.Diagnostics.Process.ErrorDataReceived" /> event of a <see cref="System.Diagnostics.Process" />.</summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">A <see cref="System.Diagnostics.DataReceivedEventArgs" /> that contains the event data.</param>
/// <format type="text/markdown"><![CDATA[
/// [!INCLUDE[remarks] (~/includes/remarks/System.Diagnostics/DataReceivedEventHandler/DataReceivedEventHandler.md)]
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved
/// ]]></format>
/// <altmember cref="System.Diagnostics.DataReceivedEventArgs"/>
/// <altmember cref="System.Diagnostics.Process.OutputDataReceived"/>
/// <altmember cref="System.Diagnostics.Process.ErrorDataReceived"/>
/// <altmember cref="System.Diagnostics.Process"/>
public delegate void DataReceivedEventHandler(object sender, DataReceivedEventArgs e);

/// <summary>Provides data for the <see cref="System.Diagnostics.Process.OutputDataReceived" /> and <see cref="System.Diagnostics.Process.ErrorDataReceived" /> events.</summary>
/// <format type="text/markdown"><![CDATA[
/// [!INCLUDE[remarks] (~/includes/remarks/System.Diagnostics/DataReceivedEventArgs/DataReceivedEventArgs.md)]
/// ]]></format>
/// <altmember cref="System.Diagnostics.DataReceivedEventHandler"/>
/// <altmember cref="System.Diagnostics.Process.OutputDataReceived"/>
/// <altmember cref="System.Diagnostics.Process.ErrorDataReceived"/>
/// <altmember cref="System.Diagnostics.Process"/>
public class DataReceivedEventArgs : EventArgs
{
private readonly string? _data;
Expand All @@ -14,6 +32,11 @@ internal DataReceivedEventArgs(string? data)
_data = data;
}

/// <summary>Gets the line of characters that was written to a redirected <see cref="System.Diagnostics.Process" /> output stream.</summary>
/// <value>The line that was written by an associated <see cref="System.Diagnostics.Process" /> to its redirected <see cref="System.Diagnostics.Process.StandardOutput" /> or <see cref="System.Diagnostics.Process.StandardError" /> stream.</value>
/// <format type="text/markdown"><![CDATA[
/// [!INCLUDE[remarks] (~/includes/remarks/System.Diagnostics/DataReceivedEventArgs/Data.md)]
/// ]]></format>
public string? Data
{
get { return _data; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@

namespace System.Diagnostics
{
/// <summary>
/// DescriptionAttribute marks a property, event, or extender with a
/// description. Visual designers can display this description when referencing
/// the member.
/// </summary>
/// <summary>Specifies a description for a property or event.</summary>
/// <remarks>A visual designer can display the description when referencing the component member, such as in a Properties window. Access the <see cref="System.Diagnostics.MonitoringDescriptionAttribute.Description" /> property to get or set the text associated with this attribute.</remarks>
/// <altmember cref="System.ComponentModel.DescriptionAttribute"/>
/// <altmember cref="System.ComponentModel.PropertyDescriptor"/>
/// <altmember cref="System.ComponentModel.EventDescriptor"/>
[AttributeUsage(AttributeTargets.All)]
public class MonitoringDescriptionAttribute : DescriptionAttribute
{
private bool _replaced;

/// <summary>
/// Constructs a new sys description.
/// </summary>
/// <summary>Initializes a new instance of the <see cref="System.Diagnostics.MonitoringDescriptionAttribute" /> class, using the specified description.</summary>
/// <param name="description">The application-defined description text.</param>
/// <remarks>The description you specify in the <see cref="System.Diagnostics.MonitoringDescriptionAttribute.MonitoringDescriptionAttribute(string)" /> constructor is displayed by a visual designer when you access the property, event, or extender to which the attribute applies</remarks>
/// <altmember cref="System.Diagnostics.MonitoringDescriptionAttribute.Description"/>
public MonitoringDescriptionAttribute(string description) : base(description)
{
}

/// <summary>
/// Retrieves the description text.
/// </summary>
/// <summary>Gets description text associated with the item monitored.</summary>
/// <value>An application-defined description.</value>
/// <altmember cref="System.Diagnostics.MonitoringDescriptionAttribute.MonitoringDescriptionAttribute(string)"/>
public override string Description
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,34 @@

namespace System.Diagnostics
{
/// <summary>Provides access to local and remote processes and enables you to start and stop local system processes.</summary>
/// <remarks><format type="text/markdown"><![CDATA[
carlossanlop marked this conversation as resolved.
Show resolved Hide resolved
/// [!INCLUDE[remarks](~/includes/remarks/System.Diagnostics/Process/Process.md)]
/// ]]></format></remarks>
/// <altmember cref="O:System.Diagnostics.Process.Start"/>
/// <altmember cref="System.Diagnostics.ProcessStartInfo"/>
/// <altmember cref="System.Diagnostics.Process.CloseMainWindow"/>
/// <altmember cref="O:System.Diagnostics.Process.Kill"/>
/// <altmember cref="System.Diagnostics.ProcessThread"/>
/// <related type="ExternalDocumentation" href="https://code.msdn.microsoft.com/windowsdesktop/Using-the-NET-Process-Class-d70597ef">Using the .NET Process Class</related>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// <related type="ExternalDocumentation" href="https://code.msdn.microsoft.com/windowsdesktop/Using-the-NET-Process-Class-d70597ef">Using the .NET Process Class</related>

Copy link
Contributor

Choose a reason for hiding this comment

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

Bad link.

public partial class Process : IDisposable
{
/// <summary>Immediately stops the associated process, and optionally its child/descendent processes.</summary>
/// <param name="entireProcessTree"><see langword="true" /> to kill the associated process and its descendants; <see langword="false" /> to kill only the associated process.</param>
/// <remarks>When <paramref name="entireProcessTree" /> is set to <see langword="true" />, processes where the call lacks permissions to view details are silently skipped by the descendant termination process because the termination process is unable to determine whether those processes are descendants.</remarks>
/// <exception cref="System.ComponentModel.Win32Exception">The associated process could not be terminated.
/// -or-
/// The process is terminating.</exception>
/// <exception cref="System.NotSupportedException">You are attempting to call <see cref="O:System.Diagnostics.Process.Kill" /> for a process that is running on a remote computer. The method is available only for processes running on the local computer.</exception>
/// <exception cref="System.InvalidOperationException">The process has already exited.
/// -or-
/// There is no process associated with this <see cref="System.Diagnostics.Process" /> object.
/// -or-
/// The calling process is a member of the associated process' descendant tree.</exception>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// The calling process is a member of the associated process' descendant tree.</exception>
/// The calling process is a member of the associated process's descendant tree.</exception>

/// <exception cref="System.AggregateException">Not all processes in the associated process' descendant tree could be terminated.</exception>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// <exception cref="System.AggregateException">Not all processes in the associated process' descendant tree could be terminated.</exception>
/// <exception cref="System.AggregateException">Not all processes in the associated process's descendant tree could be terminated.</exception>

/// <altmember cref="System.Environment.Exit(int)"/>
/// <altmember cref="System.Diagnostics.Process.CloseMainWindow"/>
/// <altmember cref="O:System.Diagnostics.Process.Start"/>
public void Kill(bool entireProcessTree)
{
if (!entireProcessTree)
Expand Down
Loading