public AssemblyLoader (AssemblyBrowserWidget widget, string fileName)
		{
			if (widget == null)
				throw new ArgumentNullException ("widget");
			if (fileName == null)
				throw new ArgumentNullException ("fileName");
			this.widget = widget;
			this.FileName = fileName;
			if (!File.Exists (fileName))
				throw new ArgumentException ("File doesn't exist.", "fileName");
			this.assemblyLoaderTask = Task.Factory.StartNew<AssemblyDefinition> (() => {
				try {
					return AssemblyDefinition.ReadAssembly (FileName, new ReaderParameters {
						AssemblyResolver = this
					});
				} catch (Exception e) {
					LoggingService.LogError ("Error while reading assembly " + FileName, e);
					return null;
				}
			}, src.Token);
			
			this.unresolvedAssembly = new Lazy<IUnresolvedAssembly> (delegate {
				try {
					return widget.CecilLoader.LoadAssembly (Assembly);
				} catch (Exception e) {
					LoggingService.LogError ("Error while loading assembly", e);
					return new ICSharpCode.NRefactory.TypeSystem.Implementation.DefaultUnresolvedAssembly (FileName);
				}
			});
		}
		public override void Dispose ()
		{ 
			IsDisposed = true;
			base.Dispose ();
			widget = null;
			GC.Collect ();
		}
 static void AppendLink(StringBuilder sb, string link, string text)
 {
     sb.Append("<span style=\"text.link\"><u><a ref=\"");
     sb.Append(AssemblyBrowserWidget.FormatText(link.Replace("<", "").Replace(">", "")));
     sb.Append("\">");
     sb.Append(AssemblyBrowserWidget.FormatText(text.Replace("::", ".").Replace("<", "").Replace(">", "")));
     sb.Append("</a></u></span>");
 }
Exemple #4
0
 public SearchIdleRunner(AssemblyBrowserWidget assemblyBrowserWidget, string pattern, CancellationToken token)
 {
     this.assemblyBrowserWidget = assemblyBrowserWidget;
     this.publicOnly            = assemblyBrowserWidget.PublicApiOnly;
     this.token       = token;
     this.pattern     = pattern;
     this.definitions = assemblyBrowserWidget.definitions;
     this.searchMode  = assemblyBrowserWidget.searchMode;
     matcher          = StringMatcher.GetMatcher(pattern, true);
 }
 public override void Dispose()
 {
     IsDisposed = true;
     base.Dispose();
     widget = null;
     if (Disposed != null)
     {
         Disposed(this, EventArgs.Empty);
     }
 }
Exemple #6
0
        protected override void OnDispose()
        {
            if (cts != null)
            {
                cts.Cancel();
                cts.Dispose();
                cts = null;
            }

            widget = null;
            Disposed?.Invoke(this, EventArgs.Empty);
            base.OnDispose();
        }
        public override void Dispose()
        {
            IsDisposed = true;
            base.Dispose();
            if (currentWs != null)
            {
                currentWs.WorkspaceLoaded -= Handle_WorkspaceLoaded;
            }

            widget = null;
            if (Disposed != null)
            {
                Disposed(this, EventArgs.Empty);
            }
        }
        protected override void OnDispose()
        {
            IsDisposed = true;
            if (currentWs != null)
            {
                currentWs.WorkspaceLoaded -= Handle_WorkspaceLoaded;
            }

            widget = null;
            if (Disposed != null)
            {
                Disposed(this, EventArgs.Empty);
            }
            base.OnDispose();
        }
Exemple #9
0
        public void Open(INamedElement element)
        {
            var member = element as IUnresolvedEntity;

            if (member == null)
            {
                var entity = element as IMember;
                if (entity != null)
                {
                    member = entity.UnresolvedMember;
                }
            }
            if (member == null)
            {
                return;
            }
            var url = AssemblyBrowserWidget.GetIdString(member);

            widget.Open(url);
        }
		public AssemblyLoader (AssemblyBrowserWidget widget, string fileName)
		{
			if (widget == null)
				throw new ArgumentNullException (nameof (widget));
			if (fileName == null)
				throw new ArgumentNullException (nameof (fileName));
			this.widget = widget;
			FileName = fileName;
			if (!File.Exists (fileName))
				throw new ArgumentException ("File doesn't exist.", nameof (fileName));
			assemblyLoaderTask = Task.Run (() => {
				try {
					var asm = AssemblyDefinition.ReadAssembly (FileName, new ReaderParameters {
						AssemblyResolver = this
					});
					return Tuple.Create (asm, widget.CecilLoader.LoadAssembly (asm));
				} catch (Exception e) {
					LoggingService.LogError ("Error while reading assembly " + FileName, e);
					return null;
				}
			}, src.Token);
		}
        public AssemblyLoader(AssemblyBrowserWidget widget, string fileName)
        {
            if (widget == null)
            {
                throw new ArgumentNullException("widget");
            }
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            this.widget   = widget;
            this.FileName = fileName;
            if (!File.Exists(fileName))
            {
                throw new ArgumentException("File doesn't exist.", "fileName");
            }
            this.assemblyLoaderTask = Task.Factory.StartNew <AssemblyDefinition> (() =>
            {
                return(AssemblyDefinition.ReadAssembly(FileName, new ReaderParameters()
                {
                    AssemblyResolver = this
                }));
            });

            this.unresolvedAssembly = new Lazy <IUnresolvedAssembly> (delegate
            {
                try
                {
                    return(widget.CecilLoader.LoadAssembly(Assembly));
                }
                catch (Exception e)
                {
                    LoggingService.LogError("Error while loading assembly", e);
                    return(new ICSharpCode.NRefactory.TypeSystem.Implementation.DefaultUnresolvedAssembly(FileName));
                }
            });
        }
Exemple #12
0
 public AssemblyResolver(PEFile assembly, AssemblyBrowserWidget widget)
 {
     this.assembly = assembly;
     this.widget   = widget;
 }
 public AssemblyReferenceNodeBuilder(AssemblyBrowserWidget assemblyBrowserWidget)
 {
     this.Widget = assemblyBrowserWidget;
 }
 public MethodDefinitionNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
		public ProjectNodeBuilder (AssemblyBrowserWidget widget)
		{
			Widget = widget;
		}
Exemple #16
0
 public AssemblyNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
Exemple #17
0
			public AssemblyResolver (AssemblyBrowserWidget widget)
			{
				this.widget = widget;
			}
 public AssemblyBrowserTypeNodeBuilder(AssemblyBrowserWidget assemblyBrowserWidget)
 {
     this.Widget = assemblyBrowserWidget;
 }
        public static string Disassemble(DomCecilMethod method, bool markup)
        {
            if (method.MethodDefinition.IsPInvokeImpl)
            {
                return(GettextCatalog.GetString("Method is P/Invoke"));
            }
            if (method.MethodDefinition.Body == null)
            {
                IType type = method.DeclaringType;
                return(type == null ||  type.ClassType == ClassType.Interface ? GettextCatalog.GetString("Interface method") : GettextCatalog.GetString("Abstract method"));
            }

            StringBuilder result = new StringBuilder();

            foreach (Instruction instruction in method.MethodDefinition.Body.Instructions)
            {
                if (markup)
                {
                    result.Append("<b>");
                }
                result.Append(GetInstructionOffset(instruction));
                result.Append(markup ? ":</b> " : ": ");
                result.Append(instruction.OpCode);
                if (markup)
                {
                    result.Append("<i>");
                }
                if (instruction.Operand != null)
                {
                    result.Append(' ');
                    if (instruction.Operand is string)
                    {
                        result.Append('"');
                        result.Append(AssemblyBrowserWidget.FormatText(instruction.Operand.ToString()));
                        result.Append('"');
                    }
                    else if (instruction.Operand is Mono.Cecil.Cil.Instruction)
                    {
                        result.Append(GetInstructionOffset((Mono.Cecil.Cil.Instruction)instruction.Operand));
                    }
                    else if (instruction.Operand is Mono.Cecil.TypeDefinition)
                    {
                        AppendLink(result,
                                   new DomCecilType((Mono.Cecil.TypeDefinition)instruction.Operand).HelpUrl,
                                   instruction.Operand.ToString());
                    }
                    else if (instruction.Operand is Mono.Cecil.MethodDefinition)
                    {
                        Mono.Cecil.MethodDefinition md = instruction.Operand as Mono.Cecil.MethodDefinition;
                        AppendLink(result,
                                   new DomCecilMethod(md)
                        {
                            DeclaringType = new DomCecilType(md.DeclaringType)
                        }.HelpUrl,
                                   instruction.Operand.ToString());
                    }
                    else if (instruction.Operand is Mono.Cecil.FieldDefinition)
                    {
                        Mono.Cecil.FieldDefinition fd = instruction.Operand as Mono.Cecil.FieldDefinition;
                        AppendLink(result,
                                   new DomCecilField(fd)
                        {
                            DeclaringType = new DomCecilType(fd.DeclaringType)
                        }.HelpUrl,
                                   instruction.Operand.ToString());
                    }
                    else if (instruction.Operand is Mono.Cecil.PropertyDefinition)
                    {
                        Mono.Cecil.PropertyDefinition pd = instruction.Operand as Mono.Cecil.PropertyDefinition;
                        AppendLink(result,
                                   new DomCecilProperty(pd)
                        {
                            DeclaringType = new DomCecilType(pd.DeclaringType)
                        }.HelpUrl,
                                   instruction.Operand.ToString());
                    }
                    else if (instruction.Operand is Mono.Cecil.TypeReference)
                    {
                        AppendLink(result,
                                   "T:" + ((TypeReference)instruction.Operand).FullName,
                                   instruction.Operand.ToString());
                    }
                    else if (instruction.Operand is Mono.Cecil.MethodReference)
                    {
                        Mono.Cecil.MethodReference mr = instruction.Operand as Mono.Cecil.MethodReference;
                        StringBuilder id            = new StringBuilder(mr.DeclaringType.ToString());
                        bool          isConstructor = mr.Name == ".ctor";
                        if (!isConstructor)
                        {
                            id.Append("." + mr.Name);
                        }
                        id.Append("(");
                        for (int i = 0; i < mr.Parameters.Count; i++)
                        {
                            if (i > 0)
                            {
                                id.Append(',');
                            }
                            id.Append(mr.Parameters[i].ParameterType.FullName);
                        }
                        id.Append(")");
                        AppendLink(result, (isConstructor ? "C:" : "M:") + id, id.ToString());
                    }
                    else if (instruction.Operand is Mono.Cecil.FieldReference)
                    {
                        Mono.Cecil.FieldReference fr = instruction.Operand as Mono.Cecil.FieldReference;
                        string id = fr.DeclaringType + "." + fr.Name;
                        AppendLink(result, "F:" + id, id);
                    }
                    else if (instruction.Operand is Mono.Cecil.PropertyReference)
                    {
                        Mono.Cecil.PropertyReference pr = instruction.Operand as Mono.Cecil.PropertyReference;
                        string id = pr.DeclaringType + "." + pr.Name;
                        AppendLink(result, "P:" + id, id);
                    }
                    else
                    {
                        result.Append(AssemblyBrowserWidget.FormatText(instruction.Operand.ToString()));
                    }
                }
                if (markup)
                {
                    result.Append("</i>");
                }
                result.AppendLine();
            }
            result.AppendLine();
            return(result.ToString());
        }
 public ReferenceNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
		public BaseTypeFolderNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
		}
 public EventDefinitionNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
		public ReferenceFolderNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
		}
		public ModuleDefinitionNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
			
		}
		public DomPropertyNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
			
		}
		public AssemblyBrowserViewContent()
		{
			ContentName = GettextCatalog.GetString ("Assembly Browser");
			widget = new AssemblyBrowserWidget ();
			IsDisposed = false;
		}
		public AssemblyBrowserViewContent()
		{
			widget = new AssemblyBrowserWidget ();
			IsDisposed = false;
		}
 public DomPropertyNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
 public DomEventNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
Exemple #30
0
 public NamespaceBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
 public BaseTypeFolderNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
		public AssemblyBrowserTypeNodeBuilder (AssemblyBrowserWidget assemblyBrowserWidget)
		{
			this.Widget = assemblyBrowserWidget;
		}
Exemple #33
0
 public AssemblyBrowserViewContent()
 {
     DocumentTitle = GettextCatalog.GetString("Assembly Browser");
     widget        = new AssemblyBrowserWidget();
     FillWidget();
 }
		public DomReturnTypeNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
		}
 public ProjectNodeBuilder(AssemblyBrowserWidget widget)
 {
     Widget = widget;
 }
 public AssemblyBrowserViewContent()
 {
     widget     = new AssemblyBrowserWidget();
     IsDisposed = false;
 }
		public AssemblyNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
		}
		public AssemblyReferenceNodeBuilder (AssemblyBrowserWidget assemblyBrowserWidget)
		{
			this.Widget = assemblyBrowserWidget;
		}
		public NamespaceBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
			
		}
Exemple #40
0
 protected AssemblyBrowserTypeNodeBuilder(AssemblyBrowserWidget assemblyBrowserWidget)
 {
     this.Widget = assemblyBrowserWidget;
 }
		public DomEventNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
		}
		public override void Dispose ()
		{ 
			IsDisposed = true;
			base.Dispose ();
			widget = null;
			if (Disposed != null)
				Disposed (this, EventArgs.Empty);
		}
		public DomMethodNodeBuilder (AssemblyBrowserWidget widget) : base (widget)
		{
			
		}
 public DomReturnTypeNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
 public AssemblyBrowserViewContent()
 {
     ContentName = GettextCatalog.GetString("Assembly Browser");
     widget      = new AssemblyBrowserWidget();
     IsDisposed  = false;
 }
Exemple #46
0
 public RoslynTypeNodeBuilder(AssemblyBrowserWidget widget)
 {
     Widget = widget;
 }
 public DomFieldNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }
Exemple #48
0
 public PropertyDefinitionNodeBuilder(AssemblyBrowserWidget widget) : base(widget)
 {
 }