public override string GetNewObjectExpression(DmdConstructorInfo ctor, string argumentExpression, DmdType expectedType) { argumentExpression = LanguageValueNodeFactory.RemoveFormatSpecifiers(argumentExpression); var sb = ObjectCache.AllocStringBuilder(); var output = new DbgStringBuilderTextWriter(sb); output.Write(DbgTextColor.Keyword, "New"); output.Write(DbgTextColor.Text, " "); FormatTypeName(output, ctor.DeclaringType); output.Write(DbgTextColor.Punctuation, "("); var castType = ctor.GetMethodSignature().GetParameterTypes()[0]; bool needCast = !expectedType.CanCastTo(castType); if (needCast) { output.Write(DbgTextColor.Keyword, "CType"); output.Write(DbgTextColor.Punctuation, "("); } output.Write(DbgTextColor.Text, argumentExpression); if (needCast) { output.Write(DbgTextColor.Punctuation, ","); output.Write(DbgTextColor.Text, " "); new Formatters.VisualBasic.VisualBasicTypeFormatter(output, VisualBasicValueNodeFactory.TypeFormatterOptions, null).Format(castType, null); output.Write(DbgTextColor.Punctuation, ")"); } output.Write(DbgTextColor.Punctuation, ")"); return(ObjectCache.FreeAndToString(ref sb)); }
public override void Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteImage(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteName(output, vm.Process); output.Write(DbgTextColor.Text, "\t"); formatter.WriteId(output, vm.Process); output.Write(DbgTextColor.Text, "\t"); formatter.WriteTitle(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteState(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteDebugging(output, vm.Process); output.Write(DbgTextColor.Text, "\t"); formatter.WriteArchitecture(output, vm.Process.Architecture); output.Write(DbgTextColor.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 DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; bool needTab = false; foreach (var column in exceptionsVM.Descs.Columns) { if (!column.IsVisible) { continue; } if (column.Name == string.Empty) { continue; } if (needTab) { output.Write(DbgTextColor.Text, "\t"); } switch (column.Id) { case ExceptionsWindowColumnIds.BreakWhenThrown: formatter.WriteName(output, vm); break; case ExceptionsWindowColumnIds.Category: formatter.WriteCategory(output, vm); break; case ExceptionsWindowColumnIds.Conditions: formatter.WriteConditions(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) { } } }
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 DbgStringBuilderTextWriter(); 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(DbgTextColor.Text, "\t"); // Add an extra tab here to emulate VS output output.Write(DbgTextColor.Text, "\t"); formatter.WriteName(output, node); output.Write(DbgTextColor.Text, "\t"); formatter.WriteValueAndObjectId(output, node, out _); output.Write(DbgTextColor.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 Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteName(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteLabels(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteCondition(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteHitCount(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteFilter(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteWhenHit(output, vm); output.Write(DbgTextColor.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 Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteName(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteOptimized(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteDynamic(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteInMemory(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteOrder(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteVersion(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteTimestamp(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteAddress(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteProcess(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WriteAppDomain(output, vm.Module); output.Write(DbgTextColor.Text, "\t"); formatter.WritePath(output, vm.Module); output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; bool needTab = false; foreach (var column in processesVM.Descs.Columns) { if (!column.IsVisible) { continue; } if (needTab) { output.Write(DbgTextColor.Text, "\t"); } switch (column.Id) { case ProcessesWindowColumnIds.Icon: formatter.WriteImage(output, vm); break; case ProcessesWindowColumnIds.Name: formatter.WriteName(output, vm.Process); break; case ProcessesWindowColumnIds.ID: formatter.WriteId(output, vm.Process); break; case ProcessesWindowColumnIds.Title: formatter.WriteTitle(output, vm); break; case ProcessesWindowColumnIds.State: formatter.WriteState(output, vm); break; case ProcessesWindowColumnIds.Debugging: formatter.WriteDebugging(output, vm.Process); break; case ProcessesWindowColumnIds.ProcessArchitecture: formatter.WriteArchitecture(output, vm.Process.Architecture); break; case ProcessesWindowColumnIds.Path: formatter.WritePath(output, vm.Process); break; default: throw new InvalidOperationException(); } needTab = true; } output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; bool needTab = false; foreach (var column in threadsVM.Descs.Columns) { if (!column.IsVisible) { continue; } if (column.Name == string.Empty) { continue; } if (needTab) { output.Write(DbgTextColor.Text, "\t"); } switch (column.Id) { case ThreadsWindowColumnIds.Icon: formatter.WriteImage(output, vm); break; case ThreadsWindowColumnIds.ThreadID: formatter.WriteId(output, vm.Thread); break; case ThreadsWindowColumnIds.ThreadManagedId: formatter.WriteManagedId(output, vm.Thread); break; case ThreadsWindowColumnIds.ThreadCategory: formatter.WriteCategoryText(output, vm); break; case ThreadsWindowColumnIds.Name: formatter.WriteName(output, vm.Thread); break; case ThreadsWindowColumnIds.ThreadLocation: formatter.WriteLocation(output, vm); break; case ThreadsWindowColumnIds.ThreadPriority: formatter.WritePriority(output, vm); break; case ThreadsWindowColumnIds.ThreadAffinityMask: formatter.WriteAffinityMask(output, vm); break; case ThreadsWindowColumnIds.ThreadSuspendedCount: formatter.WriteSuspendedCount(output, vm.Thread); break; case ThreadsWindowColumnIds.ProcessName: formatter.WriteProcessName(output, vm.Thread); break; case ThreadsWindowColumnIds.AppDomain: formatter.WriteAppDomain(output, vm.Thread); break; case ThreadsWindowColumnIds.ThreadState: formatter.WriteState(output, vm.Thread); break; default: throw new InvalidOperationException(); } needTab = true; } output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; bool needTab = false; foreach (var column in modulesVM.Descs.Columns) { if (!column.IsVisible) { continue; } if (column.Name == string.Empty) { continue; } if (needTab) { output.Write(DbgTextColor.Text, "\t"); } switch (column.Id) { case ModulesWindowColumnIds.Icon: break; case ModulesWindowColumnIds.Name: formatter.WriteName(output, vm.Module); break; case ModulesWindowColumnIds.OptimizedModule: formatter.WriteOptimized(output, vm.Module); break; case ModulesWindowColumnIds.DynamicModule: formatter.WriteDynamic(output, vm.Module); break; case ModulesWindowColumnIds.InMemoryModule: formatter.WriteInMemory(output, vm.Module); break; case ModulesWindowColumnIds.Order: formatter.WriteOrder(output, vm.Module); break; case ModulesWindowColumnIds.Version: formatter.WriteVersion(output, vm.Module); break; case ModulesWindowColumnIds.Timestamp: formatter.WriteTimestamp(output, vm.Module); break; case ModulesWindowColumnIds.Address: formatter.WriteAddress(output, vm.Module); break; case ModulesWindowColumnIds.Process: formatter.WriteProcess(output, vm.Module); break; case ModulesWindowColumnIds.AppDomain: formatter.WriteAppDomain(output, vm.Module); break; case ModulesWindowColumnIds.Path: formatter.WritePath(output, vm.Module); break; default: throw new InvalidOperationException(); } needTab = true; } output.WriteLine(); } var s = output.ToString(); if (s.Length > 0) { try { Clipboard.SetText(s); } catch (ExternalException) { } } }
public override void Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; bool needTab = false; foreach (var column in codeBreakpointsVM.Descs.Columns) { if (!column.IsVisible) { continue; } if (column.Name == string.Empty) { continue; } if (needTab) { output.Write(DbgTextColor.Text, "\t"); } switch (column.Id) { case CodeBreakpointsColumnIds.Name: formatter.WriteName(output, vm); break; case CodeBreakpointsColumnIds.Labels: formatter.WriteLabels(output, vm); break; case CodeBreakpointsColumnIds.Condition: formatter.WriteCondition(output, vm); break; case CodeBreakpointsColumnIds.HitCount: formatter.WriteHitCount(output, vm); break; case CodeBreakpointsColumnIds.Filter: formatter.WriteFilter(output, vm); break; case CodeBreakpointsColumnIds.WhenHit: formatter.WriteWhenHit(output, vm); break; case CodeBreakpointsColumnIds.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) { } } }
public override void Copy() { var output = new DbgStringBuilderTextWriter(); foreach (var vm in SortedSelectedItems) { var formatter = vm.Context.Formatter; formatter.WriteImage(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteId(output, vm.Thread); output.Write(DbgTextColor.Text, "\t"); formatter.WriteManagedId(output, vm.Thread); output.Write(DbgTextColor.Text, "\t"); formatter.WriteCategoryText(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteName(output, vm.Thread); output.Write(DbgTextColor.Text, "\t"); formatter.WriteLocation(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WritePriority(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteAffinityMask(output, vm); output.Write(DbgTextColor.Text, "\t"); formatter.WriteSuspendedCount(output, vm.Thread); output.Write(DbgTextColor.Text, "\t"); formatter.WriteProcessName(output, vm.Thread); output.Write(DbgTextColor.Text, "\t"); formatter.WriteAppDomain(output, vm.Thread); output.Write(DbgTextColor.Text, "\t"); formatter.WriteState(output, vm.Thread); 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 DbgStringBuilderTextWriter(); var msg = breakpoint.BoundBreakpointsMessage; if (msg.Severity != DbgBoundCodeBreakpointSeverity.None) { output.Write(DbgTextColor.Error, msg.Message); output.WriteLine(); output.WriteLine(); } output.Write(DbgTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Location); output.Write(DbgTextColor.Text, ": "); WriteLocation(output, breakpoint, textView, span); const string INDENTATION = " "; if (breakpoint.Condition is not null || breakpoint.HitCount is not null || breakpoint.Filter is not null) { output.WriteLine(); output.WriteLine(); output.Write(DbgTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Conditions); if (breakpoint.Condition is not null) { output.WriteLine(); output.Write(DbgTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Condition.Value); } if (breakpoint.HitCount is not null) { output.WriteLine(); output.Write(DbgTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.HitCount.Value, dbgCodeBreakpointHitCountService.GetHitCount(breakpoint)); } if (breakpoint.Filter is not null) { output.WriteLine(); output.Write(DbgTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Filter.Value); } } if (breakpoint.Trace is not null) { output.WriteLine(); output.WriteLine(); output.Write(DbgTextColor.Text, dnSpy_Debugger_Resources.GlyphToolTip_Actions); if (!breakpoint.Trace.Value.Continue) { output.WriteLine(); output.Write(DbgTextColor.Text, INDENTATION); output.Write(DbgTextColor.Text, dnSpy_Debugger_Resources.Breakpoints_GlyphMargin_BreakWhenBreakpointHit); } output.WriteLine(); output.Write(DbgTextColor.Text, INDENTATION); breakpointConditionsFormatter.WriteToolTip(output, breakpoint.Trace.Value); } return(output.ToString()); }