示例#1
0
        public List <ReferenceSegment> Decompile(TextEditor data, ITreeNavigator navigator, DecompileFlags flags)
        {
            var assemblyLoader = (AssemblyLoader)navigator.DataItem;

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetAssemblyLoader(navigator), b =>
                                                  b.DecompileModuleAndAssemblyAttributes(), flags: flags));
        }
示例#2
0
        public List <ReferenceSegment> Decompile(TextEditorData data, ITreeNavigator navigator, bool publicOnly)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var type = CecilLoader.GetCecilObject((IUnresolvedTypeDefinition)navigator.DataItem);

            if (type == null)
            {
                return(null);
            }
            var settings = new DecompilerSettings()
            {
                AnonymousMethods     = true,
                AutomaticEvents      = true,
                AutomaticProperties  = true,
                ForEachStatement     = true,
                LockStatement        = true,
                HideNonPublicMembers = publicOnly
            };

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), type, builder => {
                builder.AddType(type);
            }, settings));
        }
        public List <ReferenceSegment> Decompile(TextEditorData data, ITreeNavigator navigator, bool publicOnly)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var type = CecilLoader.GetCecilObject((IUnresolvedTypeDefinition)navigator.DataItem);

            if (type == null)
            {
                return(null);
            }
            var types      = DesktopService.GetMimeTypeInheritanceChain(data.Document.MimeType);
            var codePolicy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy> (types);
            var settings   = new DecompilerSettings()
            {
                AnonymousMethods        = true,
                AutomaticEvents         = true,
                AutomaticProperties     = true,
                ForEachStatement        = true,
                LockStatement           = true,
                CSharpFormattingOptions = codePolicy.CreateOptions()

                                          //,
//				HideNonPublicMembers = publicOnly
            };

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), type, builder =>
            {
                builder.AddType(type);
            }, settings));
        }
        public List <ReferenceSegment> Decompile(TextEditorData data, ITreeNavigator navigator)
        {
            DomCecilMethod method = navigator.DataItem as DomCecilMethod;

            if (method == null)
            {
                return(null);
            }
            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), ((DomCecilType)method.DeclaringType).TypeDefinition, b => b.AddMethod(method.MethodDefinition)));
        }
        List <ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile(TextEditorData data, ITreeNavigator navigator, bool publicOnly)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var field = CecilLoader.GetCecilObject((IUnresolvedField)navigator.DataItem);

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), field.DeclaringType, b => b.AddField(field)));
        }
        List <ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile(TextEditor data, ITreeNavigator navigator, bool publicOnly)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var property = GetCecilLoader(navigator).GetCecilObject((IUnresolvedProperty)navigator.DataItem);

            if (property == null)
            {
                return(null);
            }
            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), property.DeclaringType, b => b.AddProperty(property)));
        }
示例#7
0
        List <ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile(TextEditor data, ITreeNavigator navigator, DecompileFlags flags)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var evt = GetCecilLoader(navigator).GetCecilObject <EventDefinition>((IUnresolvedEvent)navigator.DataItem);

            if (evt == null)
            {
                return(null);
            }
            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetAssemblyLoader(navigator), b => b.Decompile(evt), flags: flags));
        }
示例#8
0
        public List <ReferenceSegment> Decompile(TextEditor data, ITreeNavigator navigator, DecompileFlags flags)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var type = (IUnresolvedTypeDefinition)navigator.DataItem;

            if (type == null)
            {
                return(null);
            }
            var settings = DomMethodNodeBuilder.GetDecompilerSettings(data, flags.PublicOnly);

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetAssemblyLoader(navigator), builder => builder.DecompileType(type.FullTypeName), flags: flags));
        }
        public List <ReferenceSegment> Decompile(TextEditorData data, ITreeNavigator navigator, bool publicOnly)
        {
            var method = (IUnresolvedMethod)navigator.DataItem;

            if (HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var cecilMethod = CecilLoader.GetCecilObject(method);

            if (cecilMethod == null)
            {
                return(null);
            }
            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), cecilMethod.DeclaringType, b => b.AddMethod(cecilMethod)));
        }
示例#10
0
        public List <ReferenceSegment> Decompile(TextEditor data, ITreeNavigator navigator, DecompileFlags flags)
        {
            var method = (IUnresolvedMethod)navigator.DataItem;

            if (HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var cecilMethod = GetCecilLoader(navigator).GetCecilObject <MethodDefinition> (method);

            if (cecilMethod == null)
            {
                return(null);
            }
            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetAssemblyLoader(navigator), b => b.Decompile(cecilMethod), flags: flags));
        }
示例#11
0
        public List <ReferenceSegment> Decompile(TextEditor data, ITreeNavigator navigator, bool publicOnly)
        {
            var assembly        = ((AssemblyLoader)navigator.DataItem).UnresolvedAssembly;
            var compilationUnit = Widget.CecilLoader.GetCecilObject(assembly);

            if (compilationUnit == null)
            {
                LoggingService.LogError("Can't get cecil object for assembly:" + assembly);
                return(new List <ReferenceSegment> ());
            }
            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), null, b => {
                if (b != null)
                {
                    b.AddAssembly(compilationUnit, true);
                }
            }));
        }
示例#12
0
        string IAssemblyBrowserNodeBuilder.GetDecompiledCode(ITreeNavigator navigator)
        {
            IProperty     property = (IProperty)navigator.DataItem;
            StringBuilder result   = new StringBuilder();

            result.Append(DomMethodNodeBuilder.GetAttributes(Ambience, property.Attributes));
            result.Append(Ambience.GetString(property, DomTypeNodeBuilder.settings));
            result.Append(" {"); result.AppendLine();
            DomCecilProperty cecilProperty = property as DomCecilProperty;

            if (property.HasGet)
            {
                result.Append("\t");
                if (property.GetterModifier != property.Modifiers)
                {
                    result.Append("<span style=\"keyword.modifier\">");
                    result.Append(Ambience.GetString(property.GetterModifier));
                    result.Append("</span> ");
                }
                result.Append("<b>get</b> {"); result.AppendLine();
                string text = DomMethodNodeBuilder.Decompile(cecilProperty.GetMethod as DomCecilMethod, true).Replace("\t", "\t\t");

                result.Append(GetBody(text));
                result.Append("\t}"); result.AppendLine();
            }
            if (property.HasSet)
            {
                result.Append("\t");
                if (property.SetterModifier != property.Modifiers)
                {
                    result.Append("<span style=\"keyword.modifier\">");
                    result.Append(Ambience.GetString(property.SetterModifier));
                    result.Append("</span> ");
                }
                result.Append("<b>set</b> {"); result.AppendLine();
                string text = DomMethodNodeBuilder.Decompile(cecilProperty.SetMethod as DomCecilMethod, true).Replace("\t", "\t\t");
                result.Append(GetBody(text));
                result.Append("\t}"); result.AppendLine();
            }
            result.Append("}");
            return(result.ToString());
        }
示例#13
0
        public List <ReferenceSegment> Decompile(TextEditor data, ITreeNavigator navigator, bool publicOnly)
        {
            if (DomMethodNodeBuilder.HandleSourceCodeEntity(navigator, data))
            {
                return(null);
            }
            var type = CecilLoader.GetCecilObject((IUnresolvedTypeDefinition)navigator.DataItem);

            if (type == null)
            {
                return(null);
            }
            var types      = DesktopService.GetMimeTypeInheritanceChain(data.MimeType);
            var codePolicy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy> (types);
            var settings   = CreateDecompilerSettings(publicOnly, codePolicy);

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), type, builder => {
                builder.AddType(type);
            }, settings));
        }
示例#14
0
        public List <ReferenceSegment> Decompile(TextEditorData data, ITreeNavigator navigator)
        {
            var type = (DomCecilType)navigator.DataItem;

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), type.TypeDefinition, b => b.AddType(type.TypeDefinition)));
        }
        public List <ReferenceSegment> Disassemble(TextEditorData data, ITreeNavigator navigator)
        {
            DomCecilCompilationUnit compilationUnit = (DomCecilCompilationUnit)navigator.DataItem;

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), null, b => b.AddAssembly(compilationUnit.AssemblyDefinition, true)));
        }
        List <ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile(TextEditorData data, ITreeNavigator navigator)
        {
            var property = (DomCecilProperty)navigator.DataItem;

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), ((DomCecilType)property.DeclaringType).TypeDefinition, b => b.AddProperty(property.PropertyDefinition)));
        }
示例#17
0
        public List <ReferenceSegment> Disassemble(TextEditorData data, ITreeNavigator navigator)
        {
            var compilationUnit = Widget.CecilLoader.GetCecilObject(((AssemblyLoader)navigator.DataItem).UnresolvedAssembly);

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), null, b => b.AddAssembly(compilationUnit, true)));
        }
示例#18
0
        List <ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile(TextEditorData data, ITreeNavigator navigator)
        {
            var evt = (DomCecilEvent)navigator.DataItem;

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), ((DomCecilType)evt.DeclaringType).TypeDefinition, b => b.AddEvent(evt.EventDefinition)));
        }
示例#19
0
        List <ReferenceSegment> IAssemblyBrowserNodeBuilder.Decompile(TextEditorData data, ITreeNavigator navigator)
        {
            var field = (DomCecilField)navigator.DataItem;

            return(DomMethodNodeBuilder.Decompile(data, DomMethodNodeBuilder.GetModule(navigator), ((DomCecilType)field.DeclaringType).TypeDefinition, b => b.AddField(field.FieldDefinition)));
        }
        void SearchDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try {
                string pattern = e.Argument.ToString().ToUpper();
                int    types = 0, curType = 0;
                foreach (DomCecilCompilationUnit unit in this.definitions)
                {
                    types += unit.Types.Count;
                }
                List <IMember> members = new List <IMember> ();
                switch (searchMode)
                {
                case SearchMode.Member:
                    foreach (DomCecilCompilationUnit unit in this.definitions)
                    {
                        foreach (IType type in unit.Types)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            curType++;
                            foreach (IMember member in type.Members)
                            {
                                if (worker.CancellationPending)
                                {
                                    return;
                                }
                                if (member.Name.ToUpper().Contains(pattern))
                                {
                                    members.Add(member);
                                }
                            }
                        }
                    }
                    Gtk.Application.Invoke(delegate {
                        IdeApp.Workbench.StatusBar.SetProgressFraction((double)curType / types);
                        foreach (MonoDevelop.Projects.Dom.IMember member in members)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            memberListStore.AppendValues(ImageService.GetPixbuf(member.StockIcon, Gtk.IconSize.Menu),
                                                         member.Name,
                                                         member.DeclaringType.FullName,
                                                         ((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName,
                                                         member);
                        }
                    });
                    break;

                case SearchMode.Disassembler:
                    Gtk.Application.Invoke(delegate {
                        IdeApp.Workbench.StatusBar.BeginProgress(GettextCatalog.GetString("Searching string in disassembled code..."));
                    });
                    foreach (DomCecilCompilationUnit unit in this.definitions)
                    {
                        foreach (IType type in unit.Types)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            curType++;
                            foreach (IMethod method in type.Methods)
                            {
                                if (worker.CancellationPending)
                                {
                                    return;
                                }
                                DomCecilMethod domMethod = method as DomCecilMethod;
                                if (domMethod == null)
                                {
                                    continue;
                                }
                                if (DomMethodNodeBuilder.Disassemble(domMethod, false).ToUpper().Contains(pattern))
                                {
                                    members.Add(method);
                                }
                            }
                        }
                    }
                    Gtk.Application.Invoke(delegate {
                        IdeApp.Workbench.StatusBar.SetProgressFraction((double)curType / types);
                        foreach (MonoDevelop.Projects.Dom.IMember member in members)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            memberListStore.AppendValues(ImageService.GetPixbuf(member.StockIcon, Gtk.IconSize.Menu),
                                                         member.Name,
                                                         member.DeclaringType.FullName,
                                                         ((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName,
                                                         member);
                        }
                    });
                    break;

                case SearchMode.Decompiler:
                    foreach (DomCecilCompilationUnit unit in this.definitions)
                    {
                        foreach (IType type in unit.Types)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            curType++;
                            foreach (IMethod method in type.Methods)
                            {
                                if (worker.CancellationPending)
                                {
                                    return;
                                }
                                DomCecilMethod domMethod = method as DomCecilMethod;
                                if (domMethod == null)
                                {
                                    continue;
                                }
                                if (DomMethodNodeBuilder.Decompile(domMethod, false).ToUpper().Contains(pattern))
                                {
                                    members.Add(method);
                                }
                            }
                        }
                    }
                    Gtk.Application.Invoke(delegate {
                        IdeApp.Workbench.StatusBar.SetProgressFraction((double)curType / types);
                        foreach (MonoDevelop.Projects.Dom.IMember member in members)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            memberListStore.AppendValues(ImageService.GetPixbuf(member.StockIcon, Gtk.IconSize.Menu),
                                                         member.Name,
                                                         member.DeclaringType.FullName,
                                                         ((DomCecilCompilationUnit)member.DeclaringType.CompilationUnit).AssemblyDefinition.Name.FullName,
                                                         member);
                        }
                    });
                    break;

                case SearchMode.Type:
                    foreach (DomCecilCompilationUnit unit in this.definitions)
                    {
                        foreach (IType type in unit.Types)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            if (type.FullName.ToUpper().IndexOf(pattern) >= 0)
                            {
                                members.Add(type);
                            }
                        }
                    }
                    Gtk.Application.Invoke(delegate {
                        foreach (IType type in members)
                        {
                            if (worker.CancellationPending)
                            {
                                return;
                            }
                            typeListStore.AppendValues(ImageService.GetPixbuf(type.StockIcon, Gtk.IconSize.Menu),
                                                       type.Name,
                                                       type.Namespace,
                                                       ((DomCecilCompilationUnit)type.CompilationUnit).AssemblyDefinition.Name.FullName,
                                                       type);
                        }
                    });

                    break;
                }
            } finally {
                Gtk.Application.Invoke(delegate {
                    IdeApp.Workbench.StatusBar.EndProgress();
                });
            }
        }