protected override void OnPointerReleased(PointerReleasedEventArgs e) { previewPointVisible = true; var textView = TextView; var offset = _editor.GetOffsetFromPoint(e.GetPosition(this)); if (offset != -1) { var lineClicked = -1; lineClicked = textView.Document.GetLineByOffset(offset).LineNumber; // convert from text line to visual line. var currentBreakPoint = _manager.OfType <Breakpoint>().FirstOrDefault(bp => bp.FileName == _editor.Editor.SourceFile.FilePath && bp.Line == lineClicked) as BreakEvent; if (currentBreakPoint != null) { _manager.Remove(currentBreakPoint); } else { if (!string.IsNullOrEmpty(_editor.Editor.SourceFile.FilePath)) { _manager.Add(_editor.Editor.SourceFile.FilePath, lineClicked); } } } InvalidateVisual(); }
public static void SetLiveUpdateMode(PinnedWatch watch, bool liveUpdate) { if (watch.LiveUpdate == liveUpdate) { return; } watch.LiveUpdate = liveUpdate; if (liveUpdate) { var bp = new Breakpoint(watch.File, watch.Line); bp.TraceExpression = "{" + watch.Expression + "}"; bp.HitAction = HitAction.PrintExpression; bp.NonUserBreakpoint = true; lock (breakpoints) breakpoints.Add(bp); pinnedWatches.Bind(watch, bp); } else { pinnedWatches.Bind(watch, null); lock (breakpoints) breakpoints.Remove(watch.BoundTracer); } }
public async Task WhenStoreModifiedExternallyThenIteratingOverBreakpointsShouldNotThrow() { var store = new BreakpointStore(); Action <int> threadAddAction = (x) => { store.Add(new Breakpoint($"fileName{x}.cs", 10)); }; Action threadEnumerateAction = () => { foreach (var bk in store.GetBreakpointsAtFile("fileName1.cs")) { } }; List <Task> tasks = new List <Task> (); for (int i = 0; i < 10; i++) { tasks.Add(Task.Run(() => { threadAddAction(i); })); tasks.Add(Task.Run(() => { threadEnumerateAction(); })); } foreach (var task in tasks) { await task; } }
public void GetBreakpointsAtFileReturnsCorrectFiles() { var store = new BreakpointStore(); store.Add(new Breakpoint("fileName1.cs", 10)); store.Add(new Breakpoint("fileName1.cs", 20)); store.Add(new Breakpoint("fileName2.cs", 10)); store.Add(new Breakpoint("fileName3.cs", 15)); int count = 0; foreach (var bk in store.GetBreakpointsAtFile("fileName1.cs")) { count++; Assert.AreEqual("fileName1.cs", bk.FileName); } Assert.AreEqual(2, count); }
internal void SetAllLiveUpdateBreakpoints(BreakpointStore bps) { lock (watches) { foreach (PinnedWatch w in watches) { if (w.LiveUpdate) { var bp = CreateLiveUpdateBreakpoint(w); Bind(w, bp); bps.Add(bp); } } } }