Example #1
0
        public override string GetTooltip(MemberReference member)
        {
            var     decompilerTypeSystem = new DecompilerTypeSystem(member.Module);
            ISymbol symbol;

            switch (member)
            {
            case MethodReference mr:
                symbol = decompilerTypeSystem.Resolve(mr);
                if (symbol == null)
                {
                    return(base.GetTooltip(member));
                }
                break;

            case PropertyReference pr:
                symbol = decompilerTypeSystem.Resolve(pr);
                if (symbol == null)
                {
                    return(base.GetTooltip(member));
                }
                break;

            case EventReference er:
                symbol = decompilerTypeSystem.Resolve(er);
                if (symbol == null)
                {
                    return(base.GetTooltip(member));
                }
                break;

            case FieldReference fr:
                symbol = decompilerTypeSystem.Resolve(fr);
                if (symbol == null)
                {
                    return(base.GetTooltip(member));
                }
                break;

            default:
                return(base.GetTooltip(member));
            }
            var flags = ConversionFlags.All & ~ConversionFlags.ShowBody;

            return(new CSharpAmbience()
            {
                ConversionFlags = flags
            }.ConvertSymbol(symbol));
        }
Example #2
0
            public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
            {
                base.DecompileMethod(method, output, options);
                if (!method.HasBody)
                {
                    return;
                }
                var      typeSystem = new DecompilerTypeSystem(method.Module);
                ILReader reader     = new ILReader(typeSystem);

                reader.WriteTypedIL(method.Body, typeSystem.Resolve(method), output, options.CancellationToken);
            }
Example #3
0
            public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
            {
                base.DecompileMethod(method, output, options);
                if (!method.HasBody)
                {
                    return;
                }
                var typeSystem             = new DecompilerTypeSystem(method.Module);
                var specializingTypeSystem = typeSystem.GetSpecializingTypeSystem(new SimpleTypeResolveContext(typeSystem.Resolve(method)));
                var reader = new ILReader(specializingTypeSystem);

                reader.UseDebugSymbols = options.DecompilerSettings.UseDebugSymbols;
                ILFunction         il      = reader.ReadIL(method.Body, options.CancellationToken);
                ILTransformContext context = new ILTransformContext {
                    Settings          = options.DecompilerSettings,
                    TypeSystem        = typeSystem,
                    CancellationToken = options.CancellationToken
                };

                context.Stepper.StepLimit = options.StepLimit;
                context.Stepper.IsDebug   = options.IsDebug;
                try {
                    il.RunTransforms(transforms, context);
                } catch (StepLimitReachedException) {
                } finally {
                    // update stepper even if a transform crashed unexpectedly
                    if (options.StepLimit == int.MaxValue)
                    {
                        Stepper = context.Stepper;
                        OnStepperUpdated(new EventArgs());
                    }
                }
                (output as ISmartTextOutput)?.AddUIElement(OptionsCheckBox(nameof(writingOptions.UseFieldSugar)));
                output.WriteLine();
                (output as ISmartTextOutput)?.AddUIElement(OptionsCheckBox(nameof(writingOptions.UseLogicOperationSugar)));
                output.WriteLine();
                (output as ISmartTextOutput)?.AddButton(Images.ViewCode, "Show Steps", delegate {
                    DebugSteps.Show();
                });
                output.WriteLine();
                il.WriteTo(output, writingOptions);
            }
Example #4
0
            public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
            {
                base.DecompileMethod(method, output, options);
                if (!method.HasBody)
                {
                    return;
                }
                var typeSystem             = new DecompilerTypeSystem(method.Module);
                var specializingTypeSystem = typeSystem.GetSpecializingTypeSystem(new SimpleTypeResolveContext(typeSystem.Resolve(method)));
                var reader = new ILReader(specializingTypeSystem);

                reader.UseDebugSymbols = options.DecompilerSettings.UseDebugSymbols;
                ILFunction il         = reader.ReadIL(method.Body, options.CancellationToken);
                var        namespaces = new HashSet <string>();
                var        decompiler = new CSharpDecompiler(typeSystem, options.DecompilerSettings)
                {
                    CancellationToken = options.CancellationToken
                };
                ILTransformContext context = decompiler.CreateILTransformContext(il);

                context.Stepper.StepLimit = options.StepLimit;
                context.Stepper.IsDebug   = options.IsDebug;
                try {
                    il.RunTransforms(transforms, context);
                } catch (StepLimitReachedException) {
                } catch (Exception ex) {
                    output.WriteLine(ex.ToString());
                    output.WriteLine();
                    output.WriteLine("ILAst after the crash:");
                } finally {
                    // update stepper even if a transform crashed unexpectedly
                    if (options.StepLimit == int.MaxValue)
                    {
                        Stepper = context.Stepper;
                        OnStepperUpdated(new EventArgs());
                    }
                }
                (output as ISmartTextOutput)?.AddButton(Images.ViewCode, "Show Steps", delegate {
                    DebugSteps.Show();
                });
                output.WriteLine();
                il.WriteTo(output, DebugSteps.Options);
            }