コード例 #1
0
ファイル: Commands.cs プロジェクト: net10010/dnSpy
        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) { }
            }
        }
コード例 #2
0
ファイル: BookmarksOperations.cs プロジェクト: zhh007/dnSpy
        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) { }
            }
        }
コード例 #3
0
ファイル: Commands.cs プロジェクト: formylover/dnSpy-1
        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) { }
            }
        }
コード例 #4
0
        public override string GetNewObjectExpression(DmdConstructorInfo ctor, string argumentExpression, DmdType expectedType)
        {
            argumentExpression = LanguageValueNodeFactory.RemoveFormatSpecifiers(argumentExpression);
            var sb     = ObjectCache.AllocStringBuilder();
            var output = new StringBuilderTextColorOutput(sb);

            output.Write(BoxedTextColor.Keyword, "New");
            output.Write(BoxedTextColor.Text, " ");
            FormatTypeName(output, ctor.DeclaringType);
            output.Write(BoxedTextColor.Punctuation, "(");
            var  castType = ctor.GetMethodSignature().GetParameterTypes()[0];
            bool needCast = !expectedType.CanCastTo(castType);

            if (needCast)
            {
                output.Write(BoxedTextColor.Keyword, "CType");
                output.Write(BoxedTextColor.Punctuation, "(");
            }
            output.Write(BoxedTextColor.Text, argumentExpression);
            if (needCast)
            {
                output.Write(BoxedTextColor.Punctuation, ",");
                output.WriteSpace();
                new Formatters.VisualBasic.VisualBasicTypeFormatter(new StringBuilderTextColorOutput(sb), VisualBasicValueNodeFactory.TypeFormatterOptions, null).Format(castType, null);
                output.Write(BoxedTextColor.Punctuation, ")");
            }
            output.Write(BoxedTextColor.Punctuation, ")");
            return(ObjectCache.FreeAndToString(ref sb));
        }
コード例 #5
0
        protected override string GetNewObjectExpression(DmdConstructorInfo ctor, string argumentExpression)
        {
            var sb     = Formatters.ObjectCache.AllocStringBuilder();
            var output = new StringBuilderTextColorOutput(sb);

            output.Write(BoxedTextColor.Keyword, "New");
            output.Write(BoxedTextColor.Text, " ");
            FormatTypeName(output, ctor.DeclaringType);
            output.Write(BoxedTextColor.Punctuation, "(");
            output.Write(BoxedTextColor.Text, argumentExpression);
            output.Write(BoxedTextColor.Punctuation, ")");
            return(Formatters.ObjectCache.FreeAndToString(ref sb));
        }
コード例 #6
0
ファイル: LocalsListHelper.cs プロジェクト: xisuo67/dnSpy
        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) { }
        }
コード例 #7
0
        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) { }
            }
        }
コード例 #8
0
        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) { }
            }
        }
コード例 #9
0
        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) { }
            }
        }
コード例 #10
0
        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) { }
            }
        }
コード例 #11
0
ファイル: Commands.cs プロジェクト: rdavydov/dnSpy
        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) { }
            }
        }
コード例 #12
0
        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) { }
        }
コード例 #13
0
        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());
        }
コード例 #14
0
        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) { }
        }
コード例 #15
0
        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) { }
            }
        }
コード例 #16
0
ファイル: Commands.cs プロジェクト: pashav15/pashav
        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) { }
            }
        }