void AddReferenceWarningMessage(PEFile module, ITextOutput output) { var loadedAssembly = MainWindow.Instance.CurrentAssemblyList.GetAssemblies().FirstOrDefault(la => la.GetPEFileOrNull() == module); if (loadedAssembly == null || !loadedAssembly.LoadedAssemblyReferencesInfo.HasErrors) { return; } string line1 = Properties.Resources.WarningSomeAssemblyReference; string line2 = Properties.Resources.PropertyManuallyMissingReferencesListLoadedAssemblies; AddWarningMessage(module, output, line1, line2, Properties.Resources.ShowAssemblyLoad, Images.ViewCode, delegate { ILSpyTreeNode assemblyNode = MainWindow.Instance.FindTreeNode(module); assemblyNode.EnsureLazyChildren(); MainWindow.Instance.SelectNode(assemblyNode.Children.OfType <ReferenceFolderTreeNode>().Single()); }); }
/// <summary> /// Adds a TypeDefinition to the given node /// </summary> /// <param name="node">Destination node</param> /// <param name="type">Type to inject</param> /// <param name="afterModule">Action to call when the destination module is available</param> /// <param name="afterEnclosingType">Action to call when the enclosing type is available</param> public static void AddTreeNode(ILSpyTreeNode node, TypeDefinition type, Action <ModuleDefinition> afterModule, Action <TypeDefinition> afterEnclosingType) { //Ensures the lazy children of the node node.EnsureLazyChildren(); //Checks if the node is a module or not if (node is ModuleTreeNode) { //Module node var moduleNode = (ModuleTreeNode)node; //Injects in the module var module = moduleNode.Module; module.Types.Add(type); if (afterModule != null) { afterModule(module); } //Checks for the namespace var namespaceNode = moduleNode.Children .OfType <NamespaceTreeNode>() .FirstOrDefault(x => x.Text.ToString().ToLower() == (string.IsNullOrEmpty(type.Namespace) ? "-" : type.Namespace.ToLower())); if (namespaceNode != null) { //Adds the node to the namespace namespaceNode.Children.Add(new ILEditTreeNode(type, false)); SortChildren(namespaceNode); } else { //Creates a new namespace containing the new type and adds it to the module node namespaceNode = new NamespaceTreeNode(type.Namespace); namespaceNode.Children.Add(new ILEditTreeNode(type, false)); moduleNode.Children.Add(namespaceNode); SortChildren(moduleNode); } } else { //Marks the class as nested public type.Attributes |= TypeAttributes.NestedPublic; type.IsNestedPublic = true; //Injects in the type var type2 = (TypeDefinition)((IMemberTreeNode)node).Member; type2.NestedTypes.Add(type); if (afterEnclosingType != null) { afterEnclosingType(type2); } //Adds a node to the tree node.Children.Add(new ILEditTreeNode(type, false)); if (node is ILEditTreeNode) { ((ILEditTreeNode)node).RefreshChildren(); } else { SortChildren((TypeTreeNode)node); } } }