void UpdateBreakpoints() { //Disposed if (protocolClient == null) { return; } var bks = breakpoints.Select(b => b.Key).OfType <Mono.Debugging.Client.Breakpoint> ().Where(b => b.Enabled && !string.IsNullOrEmpty(b.FileName)).GroupBy(b => b.FileName).ToArray(); var filesForRemoval = pathsWithBreakpoints.Where(path => !bks.Any(b => b.Key == path)).ToArray(); pathsWithBreakpoints = bks.Select(b => b.Key).ToList(); foreach (var path in filesForRemoval) { protocolClient.SendRequest(new SetBreakpointsRequest(new Source(Path.GetFileName(path), path), new List <SourceBreakpoint> ()), null); } foreach (var sourceFile in bks) { var source = new Source(Path.GetFileName(sourceFile.Key), sourceFile.Key); protocolClient.SendRequest(new SetBreakpointsRequest( source, sourceFile.Select(b => new SourceBreakpoint { Line = b.Line, Column = b.Column, Condition = b.ConditionExpression //TODO: HitCondition = b.HitCountMode + b.HitCount, wait for .Net Core Debugger }).ToList()), (obj) => { Task.Run(() => { for (int i = 0; i < obj.Breakpoints.Count; i++) { breakpoints [sourceFile.ElementAt(i)].SetStatus(obj.Breakpoints [i].Line != -1 ? BreakEventStatus.Bound : BreakEventStatus.NotBound, ""); if (obj.Breakpoints [i].Line != sourceFile.ElementAt(i).OriginalLine) { breakpoints [sourceFile.ElementAt(i)].AdjustBreakpointLocation(obj.Breakpoints [i].Line, obj.Breakpoints [i].Column ?? 1); } } }); }); } //Notice that .NET Core adapter doesn't support Functions breakpoints yet: https://github.com/OmniSharp/omnisharp-vscode/issues/295 protocolClient.SendRequest( new SetFunctionBreakpointsRequest( breakpoints.Select(b => b.Key).OfType <MonoFunctionBreakpoint> () .Where(b => b.Enabled) .Select(b => new VsCodeFunctionBreakpoint(b.FunctionName)) .ToList()), (obj) => { }); }
void UpdateBreakpoints() { //Disposed if (protocolClient == null) { return; } var bks = breakpoints.Select(b => b.Key).OfType <Mono.Debugging.Client.Breakpoint> ().Where(b => b.Enabled).GroupBy(b => b.FileName).ToArray(); var filesForRemoval = pathsWithBreakpoints.Where(path => !bks.Any(b => b.Key == path)).ToArray(); pathsWithBreakpoints = bks.Select(b => b.Key).ToList(); foreach (var path in filesForRemoval) { protocolClient.SendRequest(new SetBreakpointsRequest(new Source(Path.GetFileName(path), path), new List <SourceBreakpoint> ()), null); } foreach (var sourceFile in bks) { var source = new Source(Path.GetFileName(sourceFile.Key), sourceFile.Key); protocolClient.SendRequest(new SetBreakpointsRequest( source, sourceFile.Select(b => new SourceBreakpoint { Line = b.Line, Column = b.Column, Condition = b.ConditionExpression //TODO: HitCondition = b.HitCountMode + b.HitCount, wait for .Net Core Debugger }).ToList()), (obj) => { Task.Run(() => { for (int i = 0; i < obj.Breakpoints.Count; i++) { breakpoints [sourceFile.ElementAt(i)].SetStatus(obj.Breakpoints [i].Line != -1 ? BreakEventStatus.Bound : BreakEventStatus.NotBound, ""); if (obj.Breakpoints [i].Line != sourceFile.ElementAt(i).OriginalLine) { breakpoints [sourceFile.ElementAt(i)].AdjustBreakpointLocation(obj.Breakpoints [i].Line, obj.Breakpoints [i].Column ?? 1); } } }); }); } }
void UpdateBreakpoints() { var bks = breakpoints.Select(b => b.Key).OfType <Mono.Debugging.Client.Breakpoint> ().Where(b => b.Enabled && !string.IsNullOrEmpty(b.FileName)).GroupBy(b => b.FileName).ToArray(); var filesForRemoval = pathsWithBreakpoints.Where(path => !bks.Any(b => b.Key == path)).ToArray(); pathsWithBreakpoints = bks.Select(b => b.Key).ToList(); foreach (var path in filesForRemoval) { //Disposed if (protocolClient == null) { return; } protocolClient.SendRequest( new SetBreakpointsRequest( new Source { Name = Path.GetFileName(path), Path = path }) { Breakpoints = new List <SourceBreakpoint> () }, null); } foreach (var sourceFile in bks) { var source = new Source { Name = Path.GetFileName(sourceFile.Key), Path = sourceFile.Key }; //Disposed if (protocolClient == null) { return; } protocolClient.SendRequest( new SetBreakpointsRequest(source) { Breakpoints = sourceFile.Select(b => new SourceBreakpoint { Line = b.OriginalLine, Column = b.OriginalColumn, Condition = b.ConditionExpression, HitCondition = GetHitCondition(b) }).ToList() }, (args) => { Task.Run(() => { for (int i = 0; i < args.Breakpoints.Count; i++) { var breakpoint = sourceFile.ElementAt(i); if (breakpoints.TryGetValue(breakpoint, out var breakInfo)) { breakInfo.SetStatus(args.Breakpoints[i].Line != -1 ? BreakEventStatus.Bound : BreakEventStatus.NotBound, ""); if (args.Breakpoints[i].Line != breakpoint.OriginalLine) { breakInfo.AdjustBreakpointLocation(args.Breakpoints[i].Line, args.Breakpoints[i].Column ?? 1); } } } }).Ignore(); });