diff --git a/src/System.Management.Automation/engine/debugger/debugger.cs b/src/System.Management.Automation/engine/debugger/debugger.cs index a14b2b59f4..8468edb0c0 100644 --- a/src/System.Management.Automation/engine/debugger/debugger.cs +++ b/src/System.Management.Automation/engine/debugger/debugger.cs @@ -3013,7 +3013,6 @@ namespace System.Management.Automation _runningJobs.Add(jobArgs.Job.InstanceId, jobArgs); jobArgs.Debugger.DebuggerStop += HandleMonitorRunningJobsDebuggerStop; - jobArgs.Debugger.BreakpointUpdated += HandleBreakpointUpdated; newJob = true; } @@ -3090,7 +3089,6 @@ namespace System.Management.Automation if (_runningJobs.TryGetValue(job.InstanceId, out jobArgs)) { jobArgs.Debugger.DebuggerStop -= HandleMonitorRunningJobsDebuggerStop; - jobArgs.Debugger.BreakpointUpdated -= HandleBreakpointUpdated; _runningJobs.Remove(job.InstanceId); } } @@ -3308,28 +3306,6 @@ namespace System.Management.Automation (((DebugMode & DebugModes.RemoteScript) == DebugModes.RemoteScript) && !IsLocalSession)); } - private void HandleBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) - { - switch (e.UpdateType) - { - case BreakpointUpdateType.Set: - AddNewBreakpoint(e.Breakpoint); - break; - - case BreakpointUpdateType.Removed: - RemoveBreakpoint(e.Breakpoint); - break; - - case BreakpointUpdateType.Enabled: - EnableBreakpoint(e.Breakpoint); - break; - - case BreakpointUpdateType.Disabled: - DisableBreakpoint(e.Breakpoint); - break; - } - } - private bool IsRunningWFJobsDebugger(Debugger debugger) { lock (_syncObject) @@ -3528,7 +3504,6 @@ namespace System.Management.Automation if (nestedDebugger != null) { nestedDebugger.DebuggerStop -= HandleMonitorRunningRSDebuggerStop; - nestedDebugger.BreakpointUpdated -= HandleBreakpointUpdated; nestedDebugger.Dispose(); // If current active debugger, then pop. @@ -3698,7 +3673,6 @@ namespace System.Management.Automation runspaceInfo.NestedDebugger = nestedDebugger; nestedDebugger.DebuggerStop += HandleMonitorRunningRSDebuggerStop; - nestedDebugger.BreakpointUpdated += HandleBreakpointUpdated; if (((_lastActiveDebuggerAction == DebuggerResumeAction.StepInto) || (_currentDebuggerAction == DebuggerResumeAction.StepInto)) && !nestedDebugger.IsActive) diff --git a/test/powershell/SDK/Breakpoint.Tests.ps1 b/test/powershell/SDK/Breakpoint.Tests.ps1 index 599b8b4561..b81148d8fa 100644 --- a/test/powershell/SDK/Breakpoint.Tests.ps1 +++ b/test/powershell/SDK/Breakpoint.Tests.ps1 @@ -77,13 +77,6 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' { Context 'Managing breakpoints in a remote runspace via the SDK' { - AfterAll { - # Get rid of any breakpoints that were created in the default runspace. - # This is necessary due to a known bug that causes breakpoints with the - # same id to be created or updated in the default runspace. - Get-PSBreakpoint | Remove-PSBreakpoint - } - It 'Can set command breakpoints' { $jobRunspace.Debugger.SetCommandBreakpoint('Write-Verbose', { break }) | Should -BeOfType [System.Management.Automation.CommandBreakpoint] } @@ -115,6 +108,14 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' { } } + It 'Doesn''t manipulate any breakpoints in the default runspace' { + # Issue https://github.com/PowerShell/PowerShell/issues/10167 fix: + # Ensure that breakpoints were not created in the default runspace. + # Prior to this issue being fixed, breakpoints with the same id + # would be created or updated in the default runspace. + $host.Runspace.Debugger.GetBreakpoints() | Should -BeNullOrEmpty + } + It 'Can remove breakpoints' { foreach ($bp in $jobRunspace.Debugger.GetBreakpoints()) { $jobRunspace.Debugger.RemoveBreakpoint($bp) | Should -BeTrue