9
9
using System . Linq ;
10
10
using System . Management . Automation ;
11
11
using System . Management . Automation . Language ;
12
+ using System . Threading ;
12
13
using System . Threading . Tasks ;
13
14
using Microsoft . Extensions . Logging ;
14
15
using Microsoft . PowerShell . EditorServices . Logging ;
@@ -23,9 +24,6 @@ internal class BreakpointService
23
24
private readonly ILogger < BreakpointService > _logger ;
24
25
private readonly PowerShellContextService _powerShellContextService ;
25
26
26
- private readonly ConcurrentDictionary < string , List < Breakpoint > > _breakpointsPerFile =
27
- new ConcurrentDictionary < string , List < Breakpoint > > ( ) ;
28
-
29
27
private static int breakpointHitCounter ;
30
28
31
29
public BreakpointService (
@@ -298,8 +296,10 @@ private ScriptBlock GetBreakpointActionScriptBlock(
298
296
299
297
if ( hitCount . HasValue )
300
298
{
299
+ Interlocked . Increment ( ref breakpointHitCounter ) ;
300
+
301
301
string globalHitCountVarName =
302
- $ "$global:{ s_psesGlobalVariableNamePrefix } BreakHitCounter_{ breakpointHitCounter ++ } ";
302
+ $ "$global:{ s_psesGlobalVariableNamePrefix } BreakHitCounter_{ breakpointHitCounter } ";
303
303
304
304
wrappedCondition =
305
305
$ "if ({ breakpoint . Condition } ) {{ if (++{ globalHitCountVarName } -eq { hitCount } ) {{ break }} }}";
@@ -404,7 +404,7 @@ private string ExtractAndScrubParseExceptionMessage(ParseException parseExceptio
404
404
return FormatInvalidBreakpointConditionMessage ( condition , parseException . Message ) ;
405
405
}
406
406
407
- private string FormatInvalidBreakpointConditionMessage ( string condition , string message )
407
+ private static string FormatInvalidBreakpointConditionMessage ( string condition , string message )
408
408
{
409
409
return $ "'{ condition } ' is not a valid PowerShell expression. { message } ";
410
410
}
0 commit comments