From ca86d7575486ff275d21c8d4e56a0cb2f24369d1 Mon Sep 17 00:00:00 2001 From: Kirk Munro Date: Thu, 15 Aug 2019 00:29:18 -0300 Subject: [PATCH] Deprecate workflow debugging code (#10321) --- .../engine/debugger/debugger.cs | 135 +----------------- test/powershell/SDK/PSDebugging.Tests.ps1 | 2 +- 2 files changed, 6 insertions(+), 131 deletions(-) diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index 8938ed7b97..83723d86d6 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -304,12 +304,12 @@ namespace System.Management.Automation Default = 0x1, /// - /// PowerShell script debugging including workflow script. + /// PowerShell script debugging. /// LocalScript = 0x2, /// - /// PowerShell remote script and workflow debugging. + /// PowerShell remote script debugging. /// 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. /// /// /// InvocationInfo. @@ -4411,8 +4366,7 @@ namespace System.Management.Automation /// /// 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. /// 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. /// /// Invocation information from debugger stop. /// InvocationInfo. @@ -5366,65 +5320,6 @@ namespace System.Management.Automation.Internal [SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes", Justification = "Needed Internal use only")] public static class DebuggerUtils { - /// - /// Set-DebuggerVariable function. - /// - 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 - }"; - - /// - /// Remove-DebuggerVariable function. - /// - 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 - }"; - - /// - /// Get-PSCallStack override function. - /// - 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 } } - /// - /// Helper method to return an enumeration of workflow debugger - /// functions. - /// - /// - public static IEnumerable GetWorkflowDebuggerFunctions() - { - return new Collection() - { - SetVariableFunction, - RemoveVariableFunction, - GetPSCallStackOverrideFunction - }; - } - /// /// Start monitoring a runspace on the target debugger. /// @@ -5532,11 +5412,6 @@ namespace System.Management.Automation.Internal /// Runspace from remote Invoke-Command script. /// InvokeCommand, - - /// - /// Runspace from Workflow activity inline script. - /// - WorkflowInlineScript } /// diff --git a/test/powershell/SDK/PSDebugging.Tests.ps1 b/test/powershell/SDK/PSDebugging.Tests.ps1 index f1d486a258..5189cb5c5e 100644 --- a/test/powershell/SDK/PSDebugging.Tests.ps1 +++ b/test/powershell/SDK/PSDebugging.Tests.ps1 @@ -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()