Add property and event for debug attach (#25788)

Adds the `IsRemoteDebuggerAttached` property to `Runspace` that
indicates whether a debugger is attached to the Runspace through the
`Debug-Runspace` cmdlet. Also adds a new engine event
`PowerShell.OnDebugAttach` that is emitted when the debugger is
attached.
This commit is contained in:
Jordan Borean authored and GitHub committed 2025-10-07 18:34:15 -04:00
1 parent 60d4bc39bc
commit 0ef738b36f
4 files changed
+49 -1

No files matched your search

@@ -1830,6 +1830,11 @@ namespace System.Management.Automation
/// </summary>
public const string OnIdle = "PowerShell.OnIdle";
/// <summary>
/// Called when <c>Debug-Runspace</c> has attached a debugger to the current runspace.
/// </summary>
public const string OnDebugAttach = "PowerShell.OnDebugAttach";
/// <summary>
/// Called during scriptblock invocation.
/// </summary>
@@ -1843,7 +1848,7 @@ namespace System.Management.Automation
/// <summary>
/// A HashSet that contains all engine event names.
/// </summary>
internal static readonly HashSet<string> EngineEvents = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { Exiting, OnIdle, OnScriptBlockInvoke };
internal static readonly HashSet<string> EngineEvents = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { Exiting, OnIdle, OnDebugAttach, OnScriptBlockInvoke };
}
/// <summary>
@@ -761,6 +761,12 @@ namespace System.Management.Automation.Runspaces
/// Gets the Runspace Id.
/// </summary>
public int Id { get; }
/// <summary>
/// Gets and sets a boolean indicating whether the runspace has a
/// debugger attached with <c>Debug-Runspace</c>.
/// </summary>
public bool IsRemoteDebuggerAttached { get; internal set; }
/// <summary>
/// Returns protocol version that the remote server uses for PS remoting.