Deprecate workflow debugging code (#10321)

This commit is contained in:
Kirk Munro
2019-08-15 08:29:18 +05:00
committed by Ilya
parent 1e6767296d
commit ca86d75754
2 changed files with 6 additions and 131 deletions
@@ -304,12 +304,12 @@ namespace System.Management.Automation
Default = 0x1,
/// <summary>
/// PowerShell script debugging including workflow script.
/// PowerShell script debugging.
/// </summary>
LocalScript = 0x2,
/// <summary>
/// PowerShell remote script and workflow debugging.
/// PowerShell remote script debugging.
/// </summary>
RemoteScript = 0x4
};
@@ -3333,18 +3333,6 @@ namespace System.Management.Automation
_lastActiveDebuggerAction = dbgCommand.ResumeAction.Value;
return new DebuggerCommandResults(dbgCommand.ResumeAction, true);
}
// If active debugger is Workflow debugger then process command here (for "list" and "help").
if (activeDebugger.GetType().FullName.Equals("Microsoft.PowerShell.Workflow.PSWorkflowDebugger", StringComparison.OrdinalIgnoreCase))
{
DebuggerCommand results = _commandProcessor.ProcessCommand(null, commandText, stopArgs.InvocationInfo, output);
if ((results != null) &&
results.ExecutedByDebugger)
{
return new DebuggerCommandResults(results.ResumeAction, true);
}
}
}
return activeDebugger.ProcessCommand(command, output);
@@ -3545,39 +3533,6 @@ namespace System.Management.Automation
PSMonitorRunspaceType runspaceType = nestedDebugger.RunspaceType;
// If this is a workflow debugger then ensure that there is a current active
// debugger that is the associated job debugger for this inline script WF runspace.
if (runspaceType == PSMonitorRunspaceType.WorkflowInlineScript)
{
bool needToPushAssociatedWFDebugger = true;
if (_activeDebuggers.TryPeek(out activeDebugger))
{
needToPushAssociatedWFDebugger = (activeDebugger.InstanceId != nestedDebugger.ParentDebuggerId);
if (needToPushAssociatedWFDebugger)
{
// Pop incorrect active debugger.
PopActiveDebugger();
}
}
if (needToPushAssociatedWFDebugger)
{
PSJobStartEventArgs wfJobArgs = null;
lock (_syncObject)
{
_runningJobs.TryGetValue(nestedDebugger.ParentDebuggerId, out wfJobArgs);
}
if (wfJobArgs == null)
{
Diagnostics.Assert(false, "We should never get a WF job InlineScript debugger without an associated WF parent job.");
return;
}
PushActiveDebugger(wfJobArgs.Debugger, _jobCallStackOffset);
}
}
// Fix up invocation info script extents for embedded nested debuggers where the script source is
// from the parent.
args.InvocationInfo = nestedDebugger.FixupInvocationInfo(args.InvocationInfo);
@@ -4245,7 +4200,7 @@ namespace System.Management.Automation
/// Attempts to fix up the debugger stop invocation information so that
/// the correct stack and source can be displayed in the debugger, for
/// cases where the debugged runspace is called inside a parent sccript,
/// such as with Workflow InlineScripts and script Invoke-Command cases.
/// such as with script Invoke-Command cases.
/// </summary>
/// <param name="debugStopInvocationInfo"></param>
/// <returns>InvocationInfo.</returns>
@@ -4411,8 +4366,7 @@ namespace System.Management.Automation
/// <summary>
/// Wrapper class for runspace debugger where the runspace is being used in an
/// embedded scenario such as Workflow InlineScript or Invoke-Command command
/// inside script.
/// embedded scenario such as Invoke-Command command inside script.
/// </summary>
internal sealed class EmbeddedRunspaceDebugger : NestedRunspaceDebugger
{
@@ -4521,7 +4475,7 @@ namespace System.Management.Automation
/// Attempts to fix up the debugger stop invocation information so that
/// the correct stack and source can be displayed in the debugger, for
/// cases where the debugged runspace is called inside a parent sccript,
/// such as with Workflow InlineScripts and script Invoke-Command cases.
/// such as with script Invoke-Command cases.
/// </summary>
/// <param name="debugStopInvocationInfo">Invocation information from debugger stop.</param>
/// <returns>InvocationInfo.</returns>
@@ -5366,65 +5320,6 @@ namespace System.Management.Automation.Internal
[SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes", Justification = "Needed Internal use only")]
public static class DebuggerUtils
{
/// <summary>
/// Set-DebuggerVariable function.
/// </summary>
public const string SetVariableFunction = @"function Set-DebuggerVariable
{
[CmdletBinding()]
param(
[Parameter(Position=0)]
[HashTable]
$Variables
)
foreach($key in $Variables.Keys)
{
microsoft.powershell.utility\set-variable -Name $key -Value $Variables[$key] -Scope global
}
Set-StrictMode -Off
}";
/// <summary>
/// Remove-DebuggerVariable function.
/// </summary>
public const string RemoveVariableFunction = @"function Remove-DebuggerVariable
{
[CmdletBinding()]
param(
[Parameter(Position=0)]
[string[]]
$Name
)
foreach ($item in $Name)
{
microsoft.powershell.utility\remove-variable -name $item -scope global
}
Set-StrictMode -Off
}";
/// <summary>
/// Get-PSCallStack override function.
/// </summary>
public const string GetPSCallStackOverrideFunction = @"function Get-PSCallStack
{
[CmdletBinding()]
param()
if ($null -ne $PSWorkflowDebugger)
{
foreach ($frame in $PSWorkflowDebugger.GetCallStack())
{
Write-Output $frame
}
}
Set-StrictMode -Off
}";
internal const string SetDebugModeFunctionName = "__Set-PSDebugMode";
internal const string SetDebuggerActionFunctionName = "__Set-PSDebuggerAction";
internal const string GetDebuggerStopArgsFunctionName = "__Get-PSDebuggerStopArgs";
@@ -5459,21 +5354,6 @@ namespace System.Management.Automation.Internal
}
}
/// <summary>
/// Helper method to return an enumeration of workflow debugger
/// functions.
/// </summary>
/// <returns></returns>
public static IEnumerable<string> GetWorkflowDebuggerFunctions()
{
return new Collection<string>()
{
SetVariableFunction,
RemoveVariableFunction,
GetPSCallStackOverrideFunction
};
}
/// <summary>
/// Start monitoring a runspace on the target debugger.
/// </summary>
@@ -5532,11 +5412,6 @@ namespace System.Management.Automation.Internal
/// Runspace from remote Invoke-Command script.
/// </summary>
InvokeCommand,
/// <summary>
/// Runspace from Workflow activity inline script.
/// </summary>
WorkflowInlineScript
}
/// <summary>
+1 -1
View File
@@ -187,7 +187,7 @@ Describe "Runspace Debugging API tests" -tag CI {
Context "PSStandaloneMonitorRunspaceInfo tests" {
BeforeAll {
$runspace = [runspacefactory]::CreateRunspace()
$runspaceType = [PSMonitorRunspaceType]::WorkflowInlineScript
$runspaceType = [PSMonitorRunspaceType]::InvokeCommand
$monitorInfo = [PSStandaloneMonitorRunspaceInfo]::new($runspace)
$instanceId = $runspace.InstanceId
$parentDebuggerId = [guid]::newguid()