Skip to content

Commit f0fe356

Browse files
authored
Restore SetBreakpoints API (PowerShell#11622)
* Restore SetBreakpoints API * Remove default values in API methods * Fix inheriting APIs * Correct further comments * Fix breakpoint API use issues * Fix breakpoint API tests
1 parent 66912b7 commit f0fe356

7 files changed

Lines changed: 262 additions & 186 deletions

File tree

src/Microsoft.PowerShell.Commands.Utility/commands/utility/Set-PSBreakpoint.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected override void ProcessRecord()
8181
else
8282
{
8383
WriteObject(
84-
Context.Debugger.SetCommandBreakpoint(Command[i], Action));
84+
Context.Debugger.SetCommandBreakpoint(Command[i], Action, path: null));
8585
}
8686
}
8787
}
@@ -103,7 +103,7 @@ protected override void ProcessRecord()
103103
else
104104
{
105105
WriteObject(
106-
Context.Debugger.SetVariableBreakpoint(Variable[i], Mode, Action));
106+
Context.Debugger.SetVariableBreakpoint(Variable[i], Mode, Action, path: null));
107107
}
108108
}
109109
}

src/System.Management.Automation/engine/debugger/debugger.cs

Lines changed: 151 additions & 75 deletions
Large diffs are not rendered by default.

src/System.Management.Automation/engine/hostifaces/PSTask.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,8 @@ public override DebuggerCommandResults ProcessCommand(
10911091
/// Adds the provided set of breakpoints to the debugger.
10921092
/// </summary>
10931093
/// <param name="breakpoints">List of breakpoints.</param>
1094-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1095-
public override void SetBreakpoints(IEnumerable<Breakpoint> breakpoints, int? runspaceId = null) =>
1094+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
1095+
public override void SetBreakpoints(IEnumerable<Breakpoint> breakpoints, int? runspaceId) =>
10961096
_wrappedDebugger.SetBreakpoints(breakpoints, runspaceId);
10971097

10981098
/// <summary>
@@ -1108,79 +1108,79 @@ public override void SetDebuggerAction(DebuggerResumeAction resumeAction)
11081108
/// Get a breakpoint by id, primarily for Enable/Disable/Remove-PSBreakpoint cmdlets.
11091109
/// </summary>
11101110
/// <param name="id">Id of the breakpoint you want.</param>
1111-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1111+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11121112
/// <returns>The breakpoint with the specified id.</returns>
1113-
public override Breakpoint GetBreakpoint(int id, int? runspaceId = null) =>
1113+
public override Breakpoint GetBreakpoint(int id, int? runspaceId) =>
11141114
_wrappedDebugger.GetBreakpoint(id, runspaceId);
11151115

11161116
/// <summary>
11171117
/// Returns breakpoints on a runspace.
11181118
/// </summary>
1119-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1119+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11201120
/// <returns>A list of breakpoints in a runspace.</returns>
1121-
public override List<Breakpoint> GetBreakpoints(int? runspaceId = null) =>
1121+
public override List<Breakpoint> GetBreakpoints(int? runspaceId) =>
11221122
_wrappedDebugger.GetBreakpoints(runspaceId);
11231123

11241124
/// <summary>
11251125
/// Sets a command breakpoint in the debugger.
11261126
/// </summary>
1127-
/// <param name="command">The name of the command that will trigger the breakpoint. This value is required and may not be null.</param>
1127+
/// <param name="command">The name of the command that will trigger the breakpoint. This value may not be null.</param>
11281128
/// <param name="action">The action to take when the breakpoint is hit. If null, PowerShell will break into the debugger when the breakpoint is hit.</param>
11291129
/// <param name="path">The path to the script file where the breakpoint may be hit. If null, the breakpoint may be hit anywhere the command is invoked.</param>
1130-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1130+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11311131
/// <returns>The command breakpoint that was set.</returns>
1132-
public override CommandBreakpoint SetCommandBreakpoint(string command, ScriptBlock action = null, string path = null, int? runspaceId = null) =>
1132+
public override CommandBreakpoint SetCommandBreakpoint(string command, ScriptBlock action, string path, int? runspaceId) =>
11331133
_wrappedDebugger.SetCommandBreakpoint(command, action, path, runspaceId);
11341134

11351135
/// <summary>
11361136
/// Sets a variable breakpoint in the debugger.
11371137
/// </summary>
1138-
/// <param name="variableName">The name of the variable that will trigger the breakpoint. This value is required and may not be null.</param>
1139-
/// <param name="accessMode">The variable access mode that will trigger the breakpoint. By default variable breakpoints will trigger only when the variable is updated.</param>
1138+
/// <param name="variableName">The name of the variable that will trigger the breakpoint. This value may not be null.</param>
1139+
/// <param name="accessMode">The variable access mode that will trigger the breakpoint.</param>
11401140
/// <param name="action">The action to take when the breakpoint is hit. If null, PowerShell will break into the debugger when the breakpoint is hit.</param>
11411141
/// <param name="path">The path to the script file where the breakpoint may be hit. If null, the breakpoint may be hit anywhere the variable is accessed using the specified access mode.</param>
1142-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1142+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11431143
/// <returns>The variable breakpoint that was set.</returns>
1144-
public override VariableBreakpoint SetVariableBreakpoint(string variableName, VariableAccessMode accessMode = VariableAccessMode.Write, ScriptBlock action = null, string path = null, int? runspaceId = null) =>
1144+
public override VariableBreakpoint SetVariableBreakpoint(string variableName, VariableAccessMode accessMode, ScriptBlock action, string path, int? runspaceId) =>
11451145
_wrappedDebugger.SetVariableBreakpoint(variableName, accessMode, action, path, runspaceId);
11461146

11471147
/// <summary>
11481148
/// Sets a line breakpoint in the debugger.
11491149
/// </summary>
1150-
/// <param name="path">The path to the script file where the breakpoint may be hit. This value is required and may not be null.</param>
1151-
/// <param name="line">The line in the script file where the breakpoint may be hit. This value is required and must be greater than or equal to 1.</param>
1150+
/// <param name="path">The path to the script file where the breakpoint may be hit. This value may not be null.</param>
1151+
/// <param name="line">The line in the script file where the breakpoint may be hit. This value must be greater than or equal to 1.</param>
11521152
/// <param name="column">The column in the script file where the breakpoint may be hit. If 0, the breakpoint will trigger on any statement on the line.</param>
11531153
/// <param name="action">The action to take when the breakpoint is hit. If null, PowerShell will break into the debugger when the breakpoint is hit.</param>
1154-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1154+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11551155
/// <returns>The line breakpoint that was set.</returns>
1156-
public override LineBreakpoint SetLineBreakpoint(string path, int line, int column = 0, ScriptBlock action = null, int? runspaceId = null) =>
1156+
public override LineBreakpoint SetLineBreakpoint(string path, int line, int column, ScriptBlock action, int? runspaceId) =>
11571157
_wrappedDebugger.SetLineBreakpoint(path, line, column, action, runspaceId);
11581158

11591159
/// <summary>
11601160
/// Enables a breakpoint in the debugger.
11611161
/// </summary>
1162-
/// <param name="breakpoint">The breakpoint to enable in the debugger. This value is required and may not be null.</param>
1163-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1162+
/// <param name="breakpoint">The breakpoint to enable in the debugger. This value may not be null.</param>
1163+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11641164
/// <returns>The updated breakpoint if it was found; null if the breakpoint was not found in the debugger.</returns>
1165-
public override Breakpoint EnableBreakpoint(Breakpoint breakpoint, int? runspaceId = null) =>
1165+
public override Breakpoint EnableBreakpoint(Breakpoint breakpoint, int? runspaceId) =>
11661166
_wrappedDebugger.EnableBreakpoint(breakpoint, runspaceId);
11671167

11681168
/// <summary>
11691169
/// Disables a breakpoint in the debugger.
11701170
/// </summary>
1171-
/// <param name="breakpoint">The breakpoint to enable in the debugger. This value is required and may not be null.</param>
1172-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1171+
/// <param name="breakpoint">The breakpoint to enable in the debugger. This value may not be null.</param>
1172+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11731173
/// <returns>The updated breakpoint if it was found; null if the breakpoint was not found in the debugger.</returns>
1174-
public override Breakpoint DisableBreakpoint(Breakpoint breakpoint, int? runspaceId = null) =>
1174+
public override Breakpoint DisableBreakpoint(Breakpoint breakpoint, int? runspaceId) =>
11751175
_wrappedDebugger.DisableBreakpoint(breakpoint, runspaceId);
11761176

11771177
/// <summary>
11781178
/// Removes a breakpoint from the debugger.
11791179
/// </summary>
1180-
/// <param name="breakpoint">The breakpoint to remove from the debugger. This value is required and may not be null.</param>
1181-
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. Defaults to null (current runspace).</param>
1180+
/// <param name="breakpoint">The breakpoint to remove from the debugger. This value may not be null.</param>
1181+
/// <param name="runspaceId">The runspace id of the runspace you want to interact with. A null value will use the current runspace.</param>
11821182
/// <returns>True if the breakpoint was removed from the debugger; false otherwise.</returns>
1183-
public override bool RemoveBreakpoint(Breakpoint breakpoint, int? runspaceId = null) =>
1183+
public override bool RemoveBreakpoint(Breakpoint breakpoint, int? runspaceId) =>
11841184
_wrappedDebugger.RemoveBreakpoint(breakpoint, runspaceId);
11851185

11861186
/// <summary>

0 commit comments

Comments
 (0)