protected override void CopyItemsAsText(LocalVM[] locals) { Array.Sort(locals, (a, b) => a.Index.CompareTo(b.Index)); var output = new StringBuilderTextColorOutput(); for (int i = 0; i < locals.Length; i++) { if (i > 0) { output.WriteLine(); } var local = locals[i]; output.Write(BoxedTextColor.Number, local.Index.ToString()); output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Text, local.IsPinned ? dnSpy_AsmEditor_Resources.Local_Pinned_Character : string.Empty); output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Text, local.DebuggerHidden ? dnSpy_AsmEditor_Resources.Local_CompilerGenerated_Character : string.Empty); output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Local, local.Name ?? string.Empty); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, local.Type); } if (locals.Length > 1) { output.WriteLine(); } try { Clipboard.SetText(output.ToString()); } catch (ExternalException) { } }
public override void Execute(BreakpointCtxMenuContext context) { var output = new StringBuilderTextColorOutput(); foreach (var vm in context.SelectedItems) { var printer = new BreakpointPrinter(output, debuggerSettings.UseHexadecimal, languageManager.Language); printer.WriteName(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAssembly(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteModule(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteFile(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new StringBuilderTextColorOutput(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteIsEnabled(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteId(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteModuleName(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteDynamic(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteInMemory(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteOrder(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteProcessName(output, vm.ModuleBreakpoint); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteAppDomainName(output, vm.ModuleBreakpoint); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new StringBuilderTextColorOutput(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteName(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteLabels(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteLocation(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteModule(output, vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Execute(LocalsCtxMenuContext context) { var output = new StringBuilderTextColorOutput(); foreach (var vm in context.SelectedItems) { //TODO: Break if it takes too long and the user cancels var printer = new ValuePrinter(output, debuggerSettings.UseHexadecimal); printer.WriteExpander(vm); output.Write(BoxedTextColor.Text, "\t"); // Add an extra here to emulate VS output output.Write(BoxedTextColor.Text, "\t"); printer.WriteName(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteValue(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteType(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new StringBuilderTextColorOutput(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteImage(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteName(output, vm.Process); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteId(output, vm.Process); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteTitle(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteState(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteDebugging(output, vm.Process); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteMachine(output, vm.Process.Machine); output.Write(BoxedTextColor.Text, "\t"); formatter.WritePath(output, vm.Process); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new StringBuilderTextColorOutput(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; bool needTab = false; foreach (var column in bookmarksVM.Descs.Columns) { if (!column.IsVisible) { continue; } if (column.Name == string.Empty) { continue; } if (needTab) { output.Write(BoxedTextColor.Text, "\t"); } switch (column.Id) { case BookmarksWindowColumnIds.Name: formatter.WriteName(output, vm); break; case BookmarksWindowColumnIds.Labels: formatter.WriteLabels(output, vm); break; case BookmarksWindowColumnIds.Location: formatter.WriteLocation(output, vm); break; case BookmarksWindowColumnIds.Module: formatter.WriteModule(output, vm); break; default: throw new InvalidOperationException(); } needTab = true; } output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
protected override void CopyItemsAsText(ExceptionHandlerVM[] ehs) { Array.Sort(ehs, (a, b) => a.Index.CompareTo(b.Index)); var output = new StringBuilderTextColorOutput(); for (int i = 0; i < ehs.Length; i++) { if (i > 0) { output.WriteLine(); } var eh = ehs[i]; output.Write(BoxedTextColor.Number, eh.Index.ToString()); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, eh.TryStartVM.SelectedItem); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, eh.TryEndVM.SelectedItem); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, eh.FilterStartVM.SelectedItem); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, eh.HandlerStartVM.SelectedItem); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, eh.HandlerEndVM.SelectedItem); output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Text, ((EnumVM)eh.HandlerTypeVM.Items[eh.HandlerTypeVM.SelectedIndex]).Name); output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, eh.CatchType); } if (ehs.Length > 1) { output.WriteLine(); } try { Clipboard.SetText(output.ToString()); } catch (ExternalException) { } }
public override void CopyValue(IValueNodesVM vm) { if (!CanCopyValue(vm)) { return; } //TODO: Show a progress dlg box and allow the user to cancel it if it's taking too long var output = new StringBuilderTextColorOutput(); int count = 0; foreach (var node in SortedSelectedNodes(vm)) { if (count > 0) { output.WriteLine(); } count++; // Don't write the object id since the command is "copy value" (VS copies the object id, though) node.Context.Formatter.WriteValue(output, node, out _); } if (count > 1) { output.WriteLine(); } var s = output.ToString(); if (count != 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new StringBuilderTextColorOutput(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteImage(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteId(output, vm.Thread); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteManagedId(output, vm.Thread); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteCategoryText(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteName(output, vm.Thread); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteLocation(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WritePriority(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteAffinityMask(output, vm); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteSuspendedCount(output, vm.Thread); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteProcessName(output, vm.Thread); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteAppDomain(output, vm.Thread); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteState(output, vm.Thread); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Execute(ThreadsCtxMenuContext context) { var output = new StringBuilderTextColorOutput(); foreach (var vm in context.SelectedItems) { var printer = new ThreadPrinter(output, debuggerSettings.UseHexadecimal, theDebugger.Value.Debugger); printer.WriteCurrent(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteId(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteManagedId(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteCategory(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteName(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteLocation(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WritePriority(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAffinityMask(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteSuspended(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteProcess(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAppDomain(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteUserState(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy(IValueNodesVM vm) { if (!CanCopy(vm)) { return; } //TODO: Show a progress dlg box and allow the user to cancel it if it's taking too long var output = new StringBuilderTextColorOutput(); var expressions = new List <string>(); foreach (var node in SortedSelectedNodes(vm)) { if (node.RawNode.CanEvaluateExpression) { expressions.Add(node.RawNode.Expression); } var formatter = node.Context.Formatter; formatter.WriteExpander(output, node); output.Write(BoxedTextColor.Text, "\t"); // Add an extra tab here to emulate VS output output.Write(BoxedTextColor.Text, "\t"); formatter.WriteName(output, node); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteValueAndObjectId(output, node, out _); output.Write(BoxedTextColor.Text, "\t"); formatter.WriteType(output, node); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { var dataObj = new DataObject(); dataObj.SetText(s); dataObj.SetData(ClipboardFormats.VARIABLES_WINDOW_EXPRESSIONS, expressions.ToArray()); Clipboard.SetDataObject(dataObj); } catch (ExternalException) { } } }
public override void Execute(ExceptionsCtxMenuContext context) { var output = new StringBuilderTextColorOutput(); foreach (var vm in context.SelectedItems) { var printer = new ExceptionPrinter(output); printer.WriteName(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Execute(ModulesCtxMenuContext context) { var output = new StringBuilderTextColorOutput(); foreach (var vm in context.SelectedItems) { var printer = new ModulePrinter(output, debuggerSettings.UseHexadecimal, theDebugger.Value.Debugger); printer.WriteName(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteOptimized(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteDynamic(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteInMemory(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteOrder(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteVersion(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteTimestamp(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAddress(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteProcess(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WriteAppDomain(vm); output.Write(BoxedTextColor.Text, "\t"); printer.WritePath(vm); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
string GetToolTipContent(DbgCodeBreakpoint breakpoint, ITextView textView, SnapshotSpan span) { var output = new StringBuilderTextColorOutput(); var msg = breakpoint.BoundBreakpointsMessage; if (msg.Severity != DbgBoundCodeBreakpointSeverity.None) { output.Write(BoxedTextColor.Error, msg.Message); output.WriteLine(); output.WriteLine(); } output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Location); output.Write(BoxedTextColor.Text, ": "); WriteLocation(output, breakpoint, textView, span); const string INDENTATION = " "; if (breakpoint.Condition != null || breakpoint.HitCount != null || breakpoint.Filter != null) { output.WriteLine(); output.WriteLine(); output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Conditions); if (breakpoint.Condition != null) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Condition.Value); } if (breakpoint.HitCount != null) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.HitCount.Value, dbgCodeBreakpointHitCountService.GetHitCount(breakpoint)); } if (breakpoint.Filter != null) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Filter.Value); } } if (breakpoint.Trace != null) { output.WriteLine(); output.WriteLine(); output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Actions); if (!breakpoint.Trace.Value.Continue) { output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); output.Write(BoxedTextColor.Text, dnSpy_Debugger_Resources.Breakpoints_GlyphMargin_BreakWhenBreakpointHit); } output.WriteLine(); output.Write(BoxedTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Trace.Value); } return(output.ToString()); }
public static void CopyItemsAsTextToClipboard(InstructionVM[] instrs) { var output = new StringBuilderTextColorOutput(); for (int i = 0; i < instrs.Length; i++) { if (i > 0) { output.WriteLine(); } var instr = instrs[i]; output.Write(BoxedTextColor.Number, instr.Index.ToString()); output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Label, instr.Offset.ToString("X4")); output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.OpCode, instr.Code.ToOpCode().ToString()); switch (instr.InstructionOperandVM.InstructionOperandType) { case InstructionOperandType.None: break; case InstructionOperandType.SByte: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.SByte.StringValue); break; case InstructionOperandType.Byte: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Byte.StringValue); break; case InstructionOperandType.Int32: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Int32.StringValue); break; case InstructionOperandType.Int64: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Int64.StringValue); break; case InstructionOperandType.Single: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Single.StringValue); break; case InstructionOperandType.Double: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Double.StringValue); break; case InstructionOperandType.String: output.Write(BoxedTextColor.Text, "\t"); output.Write(BoxedTextColor.String, instr.InstructionOperandVM.String.StringValue); break; case InstructionOperandType.Field: case InstructionOperandType.Method: case InstructionOperandType.Token: case InstructionOperandType.Type: case InstructionOperandType.MethodSig: case InstructionOperandType.BranchTarget: case InstructionOperandType.SwitchTargets: case InstructionOperandType.Local: case InstructionOperandType.Parameter: output.Write(BoxedTextColor.Text, "\t"); BodyUtils.WriteObject(output, instr.InstructionOperandVM.Value); break; default: throw new InvalidOperationException(); } } if (instrs.Length > 1) { output.WriteLine(); } try { Clipboard.SetText(output.ToString()); } catch (ExternalException) { } }