99using System . Linq ;
1010using System . Management . Automation ;
1111using System . Management . Automation . Language ;
12+ using System . Threading ;
1213using System . Threading . Tasks ;
1314using Microsoft . Extensions . Logging ;
1415using Microsoft . PowerShell . EditorServices . Logging ;
@@ -23,9 +24,6 @@ internal class BreakpointService
2324 private readonly ILogger < BreakpointService > _logger ;
2425 private readonly PowerShellContextService _powerShellContextService ;
2526
26- private readonly ConcurrentDictionary < string , List < Breakpoint > > _breakpointsPerFile =
27- new ConcurrentDictionary < string , List < Breakpoint > > ( ) ;
28-
2927 private static int breakpointHitCounter ;
3028
3129 public BreakpointService (
@@ -298,8 +296,10 @@ private ScriptBlock GetBreakpointActionScriptBlock(
298296
299297 if ( hitCount . HasValue )
300298 {
299+ Interlocked . Increment ( ref breakpointHitCounter ) ;
300+
301301 string globalHitCountVarName =
302- $ "$global:{ s_psesGlobalVariableNamePrefix } BreakHitCounter_{ breakpointHitCounter ++ } ";
302+ $ "$global:{ s_psesGlobalVariableNamePrefix } BreakHitCounter_{ breakpointHitCounter } ";
303303
304304 wrappedCondition =
305305 $ "if ({ breakpoint . Condition } ) {{ if (++{ globalHitCountVarName } -eq { hitCount } ) {{ break }} }}";
@@ -404,7 +404,7 @@ private string ExtractAndScrubParseExceptionMessage(ParseException parseExceptio
404404 return FormatInvalidBreakpointConditionMessage ( condition , parseException . Message ) ;
405405 }
406406
407- private string FormatInvalidBreakpointConditionMessage ( string condition , string message )
407+ private static string FormatInvalidBreakpointConditionMessage ( string condition , string message )
408408 {
409409 return $ "'{ condition } ' is not a valid PowerShell expression. { message } ";
410410 }
0 commit comments