@@ -23,13 +23,15 @@ internal static class BreakpointApiUtils
23
23
24
24
private const string s_psesGlobalVariableNamePrefix = "__psEditorServices_" ;
25
25
26
- private static readonly Lazy < Func < Debugger , string , int , int , ScriptBlock , LineBreakpoint > > s_setLineBreakpointLazy ;
26
+ private static readonly Lazy < Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > > s_setLineBreakpointLazy ;
27
27
28
- private static readonly Lazy < Func < Debugger , string , ScriptBlock , string , CommandBreakpoint > > s_setCommandBreakpointLazy ;
28
+ private static readonly Lazy < Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > > s_setCommandBreakpointLazy ;
29
29
30
- private static readonly Lazy < Func < Debugger , List < Breakpoint > > > s_getBreakpointsLazy ;
30
+ private static readonly Lazy < Func < Debugger , int ? , List < Breakpoint > > > s_getBreakpointsLazy ;
31
31
32
- private static readonly Lazy < Func < Debugger , Breakpoint , bool > > s_removeBreakpointLazy ;
32
+ private static readonly Lazy < Action < Debugger , IEnumerable < Breakpoint > , int ? > > s_setBreakpointsLazy ;
33
+
34
+ private static readonly Lazy < Func < Debugger , Breakpoint , int ? , bool > > s_removeBreakpointLazy ;
33
35
34
36
private static int breakpointHitCounter ;
35
37
@@ -46,42 +48,52 @@ static BreakpointApiUtils()
46
48
return ;
47
49
}
48
50
49
- s_setLineBreakpointLazy = new Lazy < Func < Debugger , string , int , int , ScriptBlock , LineBreakpoint > > ( ( ) =>
51
+ s_setLineBreakpointLazy = new Lazy < Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > > ( ( ) =>
50
52
{
51
53
MethodInfo setLineBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetLineBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) ;
52
54
53
- return ( Func < Debugger , string , int , int , ScriptBlock , LineBreakpoint > ) Delegate . CreateDelegate (
54
- typeof ( Func < Debugger , string , int , int , ScriptBlock , LineBreakpoint > ) ,
55
+ return ( Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > ) Delegate . CreateDelegate (
56
+ typeof ( Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > ) ,
55
57
firstArgument : null ,
56
58
setLineBreakpointMethod ) ;
57
59
} ) ;
58
60
59
- s_setCommandBreakpointLazy = new Lazy < Func < Debugger , string , ScriptBlock , string , CommandBreakpoint > > ( ( ) =>
61
+ s_setCommandBreakpointLazy = new Lazy < Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > > ( ( ) =>
60
62
{
61
63
MethodInfo setCommandBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetCommandBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) ;
62
64
63
- return ( Func < Debugger , string , ScriptBlock , string , CommandBreakpoint > ) Delegate . CreateDelegate (
64
- typeof ( Func < Debugger , string , ScriptBlock , string , CommandBreakpoint > ) ,
65
+ return ( Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > ) Delegate . CreateDelegate (
66
+ typeof ( Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > ) ,
65
67
firstArgument : null ,
66
68
setCommandBreakpointMethod ) ;
67
69
} ) ;
68
70
69
- s_getBreakpointsLazy = new Lazy < Func < Debugger , List < Breakpoint > > > ( ( ) =>
71
+ s_getBreakpointsLazy = new Lazy < Func < Debugger , int ? , List < Breakpoint > > > ( ( ) =>
70
72
{
71
73
MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "GetBreakpoints" , BindingFlags . Public | BindingFlags . Instance ) ;
72
74
73
- return ( Func < Debugger , List < Breakpoint > > ) Delegate . CreateDelegate (
74
- typeof ( Func < Debugger , List < Breakpoint > > ) ,
75
+ return ( Func < Debugger , int ? , List < Breakpoint > > ) Delegate . CreateDelegate (
76
+ typeof ( Func < Debugger , int ? , List < Breakpoint > > ) ,
77
+ firstArgument : null ,
78
+ removeBreakpointMethod ) ;
79
+ } ) ;
80
+
81
+ s_setBreakpointsLazy = new Lazy < Action < Debugger , IEnumerable < Breakpoint > , int ? > > ( ( ) =>
82
+ {
83
+ MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetBreakpoints" , BindingFlags . Public | BindingFlags . Instance ) ;
84
+
85
+ return ( Action < Debugger , IEnumerable < Breakpoint > , int ? > ) Action . CreateDelegate (
86
+ typeof ( Action < Debugger , IEnumerable < Breakpoint > , int ? > ) ,
75
87
firstArgument : null ,
76
88
removeBreakpointMethod ) ;
77
89
} ) ;
78
90
79
- s_removeBreakpointLazy = new Lazy < Func < Debugger , Breakpoint , bool > > ( ( ) =>
91
+ s_removeBreakpointLazy = new Lazy < Func < Debugger , Breakpoint , int ? , bool > > ( ( ) =>
80
92
{
81
93
MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "RemoveBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) ;
82
94
83
- return ( Func < Debugger , Breakpoint , bool > ) Delegate . CreateDelegate (
84
- typeof ( Func < Debugger , Breakpoint , bool > ) ,
95
+ return ( Func < Debugger , Breakpoint , int ? , bool > ) Delegate . CreateDelegate (
96
+ typeof ( Func < Debugger , Breakpoint , int ? , bool > ) ,
85
97
firstArgument : null ,
86
98
removeBreakpointMethod ) ;
87
99
} ) ;
@@ -91,19 +103,21 @@ static BreakpointApiUtils()
91
103
92
104
#region Public Static Properties
93
105
94
- private static Func < Debugger , string , int , int , ScriptBlock , LineBreakpoint > SetLineBreakpointDelegate => s_setLineBreakpointLazy . Value ;
106
+ private static Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > SetLineBreakpointDelegate => s_setLineBreakpointLazy . Value ;
107
+
108
+ private static Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > SetCommandBreakpointDelegate => s_setCommandBreakpointLazy . Value ;
95
109
96
- private static Func < Debugger , string , ScriptBlock , string , CommandBreakpoint > SetCommandBreakpointDelegate => s_setCommandBreakpointLazy . Value ;
110
+ private static Func < Debugger , int ? , List < Breakpoint > > GetBreakpointsDelegate => s_getBreakpointsLazy . Value ;
97
111
98
- private static Func < Debugger , List < Breakpoint > > GetBreakpointsDelegate => s_getBreakpointsLazy . Value ;
112
+ private static Action < Debugger , IEnumerable < Breakpoint > , int ? > SetBreakpointsDelegate => s_setBreakpointsLazy . Value ;
99
113
100
- private static Func < Debugger , Breakpoint , bool > RemoveBreakpointDelegate => s_removeBreakpointLazy . Value ;
114
+ private static Func < Debugger , Breakpoint , int ? , bool > RemoveBreakpointDelegate => s_removeBreakpointLazy . Value ;
101
115
102
116
#endregion
103
117
104
118
#region Public Static Methods
105
119
106
- public static Breakpoint SetBreakpoint ( Debugger debugger , BreakpointDetailsBase breakpoint )
120
+ public static Breakpoint SetBreakpoint ( Debugger debugger , BreakpointDetailsBase breakpoint , int ? runspaceId = null )
107
121
{
108
122
ScriptBlock actionScriptBlock = null ;
109
123
string logMessage = breakpoint is BreakpointDetails bd ? bd . LogMessage : null ;
@@ -118,24 +132,24 @@ public static Breakpoint SetBreakpoint(Debugger debugger, BreakpointDetailsBase
118
132
switch ( breakpoint )
119
133
{
120
134
case BreakpointDetails lineBreakpoint :
121
- return SetLineBreakpointDelegate ( debugger , lineBreakpoint . Source , lineBreakpoint . LineNumber , lineBreakpoint . ColumnNumber ?? 0 , actionScriptBlock ) ;
135
+ return SetLineBreakpointDelegate ( debugger , lineBreakpoint . Source , lineBreakpoint . LineNumber , lineBreakpoint . ColumnNumber ?? 0 , actionScriptBlock , runspaceId ) ;
122
136
123
137
case CommandBreakpointDetails commandBreakpoint :
124
- return SetCommandBreakpointDelegate ( debugger , commandBreakpoint . Name , null , null ) ;
138
+ return SetCommandBreakpointDelegate ( debugger , commandBreakpoint . Name , null , null , runspaceId ) ;
125
139
126
140
default :
127
141
throw new NotImplementedException ( "Other breakpoints not supported yet" ) ;
128
142
}
129
143
}
130
144
131
- public static List < Breakpoint > GetBreakpoints ( Debugger debugger )
145
+ public static List < Breakpoint > GetBreakpoints ( Debugger debugger , int ? runspaceId = null )
132
146
{
133
- return GetBreakpointsDelegate ( debugger ) ;
147
+ return GetBreakpointsDelegate ( debugger , runspaceId ) ;
134
148
}
135
149
136
- public static bool RemoveBreakpoint ( Debugger debugger , Breakpoint breakpoint )
150
+ public static bool RemoveBreakpoint ( Debugger debugger , Breakpoint breakpoint , int ? runspaceId = null )
137
151
{
138
- return RemoveBreakpointDelegate ( debugger , breakpoint ) ;
152
+ return RemoveBreakpointDelegate ( debugger , breakpoint , runspaceId ) ;
139
153
}
140
154
141
155
public static ScriptBlock GetBreakpointActionScriptBlock ( string condition , string hitCondition , string logMessage )
0 commit comments