@@ -27,8 +27,6 @@ internal static class BreakpointApiUtils
27
27
28
28
private static readonly Lazy < Func < Debugger , int ? , List < Breakpoint > > > s_getBreakpointsLazy ;
29
29
30
- private static readonly Lazy < Action < Debugger , IEnumerable < Breakpoint > , int ? > > s_setBreakpointsLazy ;
31
-
32
30
private static readonly Lazy < Func < Debugger , Breakpoint , int ? , bool > > s_removeBreakpointLazy ;
33
31
34
32
private static int breakpointHitCounter ;
@@ -39,16 +37,17 @@ internal static class BreakpointApiUtils
39
37
40
38
static BreakpointApiUtils ( )
41
39
{
42
- // If this version of PowerShell does not support the new Breakpoint APIs introduced in PowerShell 7.0.0-preview.4 ,
40
+ // If this version of PowerShell does not support the new Breakpoint APIs introduced in PowerShell 7.0.0,
43
41
// do nothing as this class will not get used.
44
- if ( typeof ( Debugger ) . GetMethod ( "SetLineBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) == null )
42
+ if ( ! SupportsBreakpointApis )
45
43
{
46
44
return ;
47
45
}
48
46
49
47
s_setLineBreakpointLazy = new Lazy < Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > > ( ( ) =>
50
48
{
51
- MethodInfo setLineBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetLineBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) ;
49
+ Type [ ] setLineBreakpointParameters = new [ ] { typeof ( string ) , typeof ( int ) , typeof ( int ) , typeof ( ScriptBlock ) , typeof ( int ? ) } ;
50
+ MethodInfo setLineBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetLineBreakpoint" , setLineBreakpointParameters ) ;
52
51
53
52
return ( Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > ) Delegate . CreateDelegate (
54
53
typeof ( Func < Debugger , string , int , int , ScriptBlock , int ? , LineBreakpoint > ) ,
@@ -58,7 +57,8 @@ static BreakpointApiUtils()
58
57
59
58
s_setCommandBreakpointLazy = new Lazy < Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > > ( ( ) =>
60
59
{
61
- MethodInfo setCommandBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetCommandBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) ;
60
+ Type [ ] setCommandBreakpointParameters = new [ ] { typeof ( string ) , typeof ( ScriptBlock ) , typeof ( string ) , typeof ( int ? ) } ;
61
+ MethodInfo setCommandBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetCommandBreakpoint" , setCommandBreakpointParameters ) ;
62
62
63
63
return ( Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > ) Delegate . CreateDelegate (
64
64
typeof ( Func < Debugger , string , ScriptBlock , string , int ? , CommandBreakpoint > ) ,
@@ -68,27 +68,19 @@ static BreakpointApiUtils()
68
68
69
69
s_getBreakpointsLazy = new Lazy < Func < Debugger , int ? , List < Breakpoint > > > ( ( ) =>
70
70
{
71
- MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "GetBreakpoints" , BindingFlags . Public | BindingFlags . Instance ) ;
71
+ Type [ ] getBreakpointsParameters = new [ ] { typeof ( int ? ) } ;
72
+ MethodInfo getBreakpointsMethod = typeof ( Debugger ) . GetMethod ( "GetBreakpoints" , getBreakpointsParameters ) ;
72
73
73
74
return ( Func < Debugger , int ? , List < Breakpoint > > ) Delegate . CreateDelegate (
74
75
typeof ( Func < Debugger , int ? , List < Breakpoint > > ) ,
75
76
firstArgument : null ,
76
- removeBreakpointMethod ) ;
77
- } ) ;
78
-
79
- s_setBreakpointsLazy = new Lazy < Action < Debugger , IEnumerable < Breakpoint > , int ? > > ( ( ) =>
80
- {
81
- MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "SetBreakpoints" , BindingFlags . Public | BindingFlags . Instance ) ;
82
-
83
- return ( Action < Debugger , IEnumerable < Breakpoint > , int ? > ) Action . CreateDelegate (
84
- typeof ( Action < Debugger , IEnumerable < Breakpoint > , int ? > ) ,
85
- firstArgument : null ,
86
- removeBreakpointMethod ) ;
77
+ getBreakpointsMethod ) ;
87
78
} ) ;
88
79
89
80
s_removeBreakpointLazy = new Lazy < Func < Debugger , Breakpoint , int ? , bool > > ( ( ) =>
90
81
{
91
- MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "RemoveBreakpoint" , BindingFlags . Public | BindingFlags . Instance ) ;
82
+ Type [ ] removeBreakpointParameters = new [ ] { typeof ( Breakpoint ) , typeof ( int ? ) } ;
83
+ MethodInfo removeBreakpointMethod = typeof ( Debugger ) . GetMethod ( "RemoveBreakpoint" , removeBreakpointParameters ) ;
92
84
93
85
return ( Func < Debugger , Breakpoint , int ? , bool > ) Delegate . CreateDelegate (
94
86
typeof ( Func < Debugger , Breakpoint , int ? , bool > ) ,
@@ -107,8 +99,6 @@ static BreakpointApiUtils()
107
99
108
100
private static Func < Debugger , int ? , List < Breakpoint > > GetBreakpointsDelegate => s_getBreakpointsLazy . Value ;
109
101
110
- private static Action < Debugger , IEnumerable < Breakpoint > , int ? > SetBreakpointsDelegate => s_setBreakpointsLazy . Value ;
111
-
112
102
private static Func < Debugger , Breakpoint , int ? , bool > RemoveBreakpointDelegate => s_removeBreakpointLazy . Value ;
113
103
114
104
#endregion
0 commit comments