public ReferenceFolderTreeNode(ModuleDefMD module, AssemblyTreeNode parentAssembly, AssemblyListTreeNode assemblyListTreeNode) { this.module = module; this.parentAssembly = parentAssembly; this.assemblyListTreeNode = assemblyListTreeNode; this.LazyLoading = true; }
public ReferenceFolderTreeNode(ModuleDef module, AssemblyTreeNode parentAssembly, DnSpyFileListTreeNode dnSpyFileListTreeNode) { this.module = module; this.parentAssembly = parentAssembly; this.dnSpyFileListTreeNode = dnSpyFileListTreeNode; this.LazyLoading = true; }
/// <summary> /// Looks up the type node corresponding to the type definition. /// Returns null if no matching node is found. /// </summary> public TypeTreeNode FindTypeNode(TypeDef def) { if (def == null) { return(null); } if (def.DeclaringType != null) { TypeTreeNode decl = FindTypeNode(def.DeclaringType); if (decl != null) { decl.EnsureChildrenFiltered(); return(decl.Children.OfType <TypeTreeNode>().FirstOrDefault(t => t.TypeDef == def)); } } else { AssemblyTreeNode asm = FindModuleNode(def.Module); if (asm != null) { return(asm.FindNonNestedTypeNode(def)); } } return(null); }
/// <summary> /// Looks up the type node corresponding to the type definition. /// Returns null if no matching node is found. /// </summary> public TypeTreeNode FindTypeNode(TypeDef def) { if (def == null) { return(null); } if (def.DeclaringType != null) { TypeTreeNode decl = FindTypeNode(def.DeclaringType); if (decl != null) { decl.EnsureLazyChildren(); return(decl.Children.OfType <TypeTreeNode>().FirstOrDefault(t => t.TypeDefinition == def && !t.IsHidden)); } } else { AssemblyTreeNode asm = FindAssemblyNode(def.Module.Assembly); if (asm != null) { return(asm.FindTypeNode(def)); } } return(null); }
/// <summary> /// Looks up the type node corresponding to the type definition. /// Returns null if no matching node is found. /// </summary> public TypeTreeNode FindTypeNode(ITypeDefinition def) { if (def == null) { return(null); } var declaringType = def.DeclaringTypeDefinition; if (declaringType != null) { TypeTreeNode decl = FindTypeNode(declaringType); if (decl != null) { decl.EnsureLazyChildren(); return(decl.Children.OfType <TypeTreeNode>().FirstOrDefault(t => t.TypeDefinition.MetadataToken == def.MetadataToken && !t.IsHidden)); } } else { AssemblyTreeNode asm = FindAssemblyNode(def.ParentModule); if (asm != null) { return(asm.FindTypeNode(def)); } } return(null); }
public TypeTreeNode(TypeDef type, AssemblyTreeNode parentAssemblyNode) { if (parentAssemblyNode == null) throw new ArgumentNullException("parentAssemblyNode"); if (type == null) throw new ArgumentNullException("type"); this.type = type; this.parentAssemblyNode = parentAssemblyNode; this.LazyLoading = true; }
public ModuleTreeNode(ModuleDefinition moduleDefinition, AssemblyTreeNode parentAssemblyNode) { if (moduleDefinition == null) throw new ArgumentNullException("moduleDefiniton"); module = moduleDefinition; assemblyNode = parentAssemblyNode; this.LazyLoading = true; }
public TreeViewUpdater(CorModuleDefFile cmdf, AssemblyTreeNode node, HashSet<uint> modifiedTypes, HashSet<uint> loadedClassTokens) { Debug.Assert(node.DnSpyFile == cmdf); this.CorModuleDefFile = cmdf; this.ModuleNode = node; this.modifiedTypes = new HashSet<uint>(modifiedTypes); this.loadedClassTokens = loadedClassTokens; this.checkedTypes = new HashSet<TypeDef>(); this.modNode = node; }
AssemblySettingsCommand(AssemblyTreeNode asmNode, AssemblyOptions newOptions) { this.asmNode = asmNode; this.newOptions = newOptions; this.origOptions = new AssemblyOptions(asmNode.LoadedAssembly.AssemblyDefinition); if (newOptions.Name != origOptions.Name) this.assemblyRefInfos = RefFinder.FindAssemblyRefsToThisModule(asmNode.LoadedAssembly.ModuleDefinition).Where(a => AssemblyNameComparer.NameAndPublicKeyTokenOnly.Equals(a, asmNode.LoadedAssembly.AssemblyDefinition)).Select(a => new AssemblyRefInfo(a)).ToArray(); }
public AssemblyReferenceTreeNode(AssemblyNameReference r, AssemblyTreeNode parentAssembly) { if (parentAssembly == null) throw new ArgumentNullException("parentAssembly"); if (r == null) throw new ArgumentNullException("r"); this.r = r; this.parentAssembly = parentAssembly; this.LazyLoading = true; }
public ModuleTreeNode(ModuleDefinition moduleDefinition, AssemblyTreeNode parentAssemblyNode) { if (moduleDefinition == null) { throw new ArgumentNullException("moduleDefiniton"); } module = moduleDefinition; assemblyNode = parentAssemblyNode; this.LazyLoading = true; }
public TypeTreeNode(TypeDefinition type, AssemblyTreeNode parentAssemblyNode) { if (parentAssemblyNode == null) throw new ArgumentNullException("parentAssemblyNode"); if (type == null) throw new ArgumentNullException("type"); this.type = type; this.parentAssemblyNode = parentAssemblyNode; this.LazyLoading = true; this.Foreground = IsPublicAPI ? NodeBrushes.Normal : NodeBrushes.Private; }
internal AssemblyReferenceTreeNode(AssemblyRef r, AssemblyTreeNode parentAssembly, DnSpyFileListTreeNode dnSpyFileListTreeNode) { if (parentAssembly == null) throw new ArgumentNullException("parentAssembly"); if (dnSpyFileListTreeNode == null) throw new ArgumentNullException("dnSpyFileListTreeNode"); if (r == null) throw new ArgumentNullException("r"); this.r = r; this.dnSpyFileListTreeNode = dnSpyFileListTreeNode; this.parentAssembly = parentAssembly; this.LazyLoading = true; }
public NamespaceTreeNodeCreator(string ns, AssemblyTreeNode asmNode) { Debug.Assert(asmNode.IsModule); if (!asmNode.IsModule) throw new InvalidOperationException(); this.asmNode = asmNode; this.nsNode = asmNode.FindNamespaceNode(ns); if (this.nsNode == null) { this.nsNode = new NamespaceTreeNode(ns); this.nsNodeCreated = true; } }
public TypeTreeNode(TypeDefinition type, AssemblyTreeNode parentAssemblyNode) { if (parentAssemblyNode == null) { throw new ArgumentNullException(nameof(parentAssemblyNode)); } if (type == null) { throw new ArgumentNullException(nameof(type)); } this.TypeDefinition = type; this.ParentAssemblyNode = parentAssemblyNode; this.LazyLoading = true; }
public TypeTreeNode(TypeDef type, AssemblyTreeNode parentAssemblyNode) { if (parentAssemblyNode == null) { throw new ArgumentNullException("parentAssemblyNode"); } if (type == null) { throw new ArgumentNullException("type"); } this.type = type; this.parentAssemblyNode = parentAssemblyNode; this.LazyLoading = true; }
public AssemblyReferenceTreeNode(AssemblyNameReference r, AssemblyTreeNode parentAssembly) { if (parentAssembly == null) { throw new ArgumentNullException("parentAssembly"); } if (r == null) { throw new ArgumentNullException("r"); } this.r = r; this.parentAssembly = parentAssembly; this.LazyLoading = true; }
public TypeTreeNode(TypeDefinition type, AssemblyTreeNode parentAssemblyNode) { if (parentAssemblyNode == null) { throw new ArgumentNullException("parentAssemblyNode"); } if (type == null) { throw new ArgumentNullException("type"); } this.type = type; this.parentAssemblyNode = parentAssemblyNode; this.LazyLoading = true; this.Foreground = IsPublicAPI ? NodeBrushes.Normal : NodeBrushes.Private; }
static IEnumerable <AssemblyTreeNode> GetAllRelatedNodes(AssemblyTreeNode node) { if (node.Parent is AssemblyTreeNode) { node = (AssemblyTreeNode)node.Parent; } yield return(node); foreach (var child in node.Children) { var asmChild = child as AssemblyTreeNode; if (asmChild != null) { yield return(asmChild); } } }
public void RegisterCached(LoadedAssembly asm, AssemblyTreeNode asmNode) { CachedAssemblyTreeNode cachedInfo; if (!cachedAsmTreeNodes.TryGetValue(asm, out cachedInfo)) { cachedAsmTreeNodes.Add(asm, cachedInfo = new CachedAssemblyTreeNode(asmNode)); } else { Debug.Assert(cachedInfo.AssemblyTreeNode == asmNode); if (cachedInfo.AssemblyTreeNode != asmNode) { throw new InvalidOperationException(); } } cachedInfo.Counter++; }
/// <summary> /// Looks up the event node corresponding to the namespace definition. /// Returns null if no matching node is found. /// </summary> public NamespaceTreeNode FindNamespaceNode(INamespace def) { var module = def.ContributingModules.FirstOrDefault(); if (module == null) { return(null); } AssemblyTreeNode assemblyNode = FindAssemblyNode(module); if (assemblyNode == null) { return(null); } assemblyNode.EnsureLazyChildren(); return(assemblyNode.Children.OfType <NamespaceTreeNode>().FirstOrDefault(n => def.FullName.Length == 0 || def.FullName.Equals(n.Text))); }
/// <summary> /// Looks up the type node corresponding to the type definition. /// Returns null if no matching node is found. /// </summary> public TypeTreeNode FindTypeNode(TypeDefinition def) { if (def == null) { return(null); } if (def.DeclaringType != null) { TypeTreeNode decl = FindTypeNode(def.DeclaringType); if (decl != null) { decl.EnsureLazyChildren(); return(decl.Children.OfType <TypeTreeNode>().FirstOrDefault(t => t.TypeDefinition == def && !t.IsHidden)); } } else { if (def.Module.Assembly == null) //def.Module.Assembly is null in secodary modules ... { foreach (AssemblyTreeNode node in this.Children) { if (node.LoadedAssembly.IsLoaded) { var t = node.FindTypeNode(def); if (t != null) { return(t); } } } return(null); } else { AssemblyTreeNode asm = FindAssemblyNode(def.Module.Assembly); if (asm != null) { return(asm.FindTypeNode(def)); } } } return(null); }
internal AssemblyReferenceTreeNode(AssemblyRef r, AssemblyTreeNode parentAssembly, AssemblyListTreeNode assemblyListTreeNode) { if (parentAssembly == null) { throw new ArgumentNullException("parentAssembly"); } if (assemblyListTreeNode == null) { throw new ArgumentNullException("assemblyListTreeNode"); } if (r == null) { throw new ArgumentNullException("r"); } this.r = r; this.assemblyListTreeNode = assemblyListTreeNode; this.parentAssembly = parentAssembly; this.LazyLoading = true; }
/// <summary> /// Called when it's been converted to an assembly /// </summary> /// <param name="modNode">Old child as returned by <see cref="OnConvertedToNetModule()"/></param> internal void OnConvertedToAssembly(AssemblyTreeNode modNode = null) { Debug.Assert(Children.Count == 0 || !(Children[0] is AssemblyTreeNode)); Debug.Assert(!(Parent is AssemblyTreeNode)); SharpTreeNode[] oldChildren = null; if (!LazyLoading) { // Children already loaded oldChildren = Children.ToArray(); Children.Clear(); } Debug.Assert(Children.Count == 0); if (Children.Count != 0) { throw new InvalidOperationException(); } var newChild = modNode ?? new AssemblyTreeNode(assembly); Debug.Assert(newChild.Parent == null); if (newChild.Parent != null) { throw new InvalidOperationException(); } Children.Add(newChild); newChild.LazyLoading = LazyLoading; LazyLoading = false; if (oldChildren != null) { newChild.Children.AddRange(oldChildren); newChild.typeDict.AddRange(typeDict); typeDict.Clear(); newChild.namespaces.AddRange(namespaces); namespaces.Clear(); } Debug.Assert(typeDict.Count == 0); Debug.Assert(namespaces.Count == 0); RaiseUIPropsChanged(); }
public ModuleReferenceTreeNode(AssemblyTreeNode parentAssembly, ModuleReferenceHandle r, MetadataReader module) { this.parentAssembly = parentAssembly ?? throw new ArgumentNullException(nameof(parentAssembly)); if (r.IsNil) { throw new ArgumentNullException(nameof(r)); } this.metadata = module; this.handle = r; this.reference = module.GetModuleReference(r); this.moduleName = metadata.GetString(reference.Name); foreach (var h in module.AssemblyFiles) { var file = module.GetAssemblyFile(h); if (module.StringComparer.Equals(file.Name, moduleName)) { this.file = file; this.fileHandle = h; this.containsMetadata = file.ContainsMetadata; break; } } }
/// <summary> /// Called when it's been converted to an assembly /// </summary> /// <param name="modNode">Old child as returned by <see cref="OnConvertedToNetModule()"/></param> internal void OnConvertedToAssembly(AssemblyTreeNode modNode = null) { Debug.Assert(Children.Count == 0 || !(Children[0] is AssemblyTreeNode)); Debug.Assert(!(Parent is AssemblyTreeNode)); SharpTreeNode[] oldChildren = null; if (!LazyLoading) { // Children already loaded oldChildren = Children.ToArray(); Children.Clear(); } Debug.Assert(Children.Count == 0); if (Children.Count != 0) throw new InvalidOperationException(); var newChild = modNode ?? new AssemblyTreeNode(assembly); Debug.Assert(newChild.Parent == null); if (newChild.Parent != null) throw new InvalidOperationException(); Children.Add(newChild); newChild.LazyLoading = LazyLoading; LazyLoading = false; if (oldChildren != null) { newChild.Children.AddRange(oldChildren); newChild.typeDict.AddRange(typeDict); typeDict.Clear(); newChild.namespaces.AddRange(namespaces); namespaces.Clear(); } Debug.Assert(typeDict.Count == 0); Debug.Assert(namespaces.Count == 0); RaiseUIPropsChanged(); }
public bool IsModified(AssemblyTreeNode asmNode) { return IsModified(asmNode.LoadedAssembly); }
RemoveNetModuleFromAssemblyCommand(AssemblyTreeNode modNode) { this.asmNode = (AssemblyTreeNode)modNode.Parent; Debug.Assert(this.asmNode != null); this.modNode = modNode; this.removeIndex = asmNode.Children.IndexOf(modNode); Debug.Assert(this.removeIndex > 0); Debug.Assert(asmNode.LoadedAssembly.AssemblyDefinition != null && asmNode.LoadedAssembly.AssemblyDefinition.Modules.IndexOf(modNode.LoadedAssembly.ModuleDefinition) == this.removeIndex); }
public TypeTreeNode(ITypeDefinition typeDefinition, AssemblyTreeNode parentAssemblyNode) { this.ParentAssemblyNode = parentAssemblyNode ?? throw new ArgumentNullException(nameof(parentAssemblyNode)); this.TypeDefinition = typeDefinition ?? throw new ArgumentNullException(nameof(typeDefinition)); this.LazyLoading = true; }
public ModuleState(CorModuleDefFile corModuleDefFile, AssemblyTreeNode moduleNode, HashSet<uint> modifiedTypes, HashSet<uint> loadClassHash) { this.CorModuleDefFile = corModuleDefFile; this.ModuleNode = moduleNode; this.ModifiedTypes = modifiedTypes; this.LoadClassHash = loadClassHash; }
static ModuleDef GetModule(AssemblyTreeNode node) { return GoToMDTableRowHexEditorCommand.HasPENode(node) ? node.DnSpyFile.ModuleDef : null; }
static void OnFileNameChangedInternal(AssemblyTreeNode node) { node.RaisePropertyChanged("Text"); node.RaisePropertyChanged("ToolTip"); }
public AssemblyReferenceTreeNode(AssemblyReference r, AssemblyTreeNode parentAssembly) { this.r = r ?? throw new ArgumentNullException(nameof(r)); this.parentAssembly = parentAssembly ?? throw new ArgumentNullException(nameof(parentAssembly)); this.LazyLoading = true; }
public ReferenceFolderTreeNode(ModuleDefinition module, AssemblyTreeNode parentAssembly) { this.module = module; this.parentAssembly = parentAssembly; this.LazyLoading = true; }
static IEnumerable<AssemblyTreeNode> GetAllRelatedNodes(AssemblyTreeNode node) { if (node.Parent is AssemblyTreeNode) node = (AssemblyTreeNode)node.Parent; yield return node; foreach (var child in node.Children) { var asmChild = child as AssemblyTreeNode; if (asmChild != null) yield return asmChild; } }
public void RegisterCached(LoadedAssembly asm, AssemblyTreeNode asmNode) { CachedAssemblyTreeNode cachedInfo; if (!cachedAsmTreeNodes.TryGetValue(asm, out cachedInfo)) cachedAsmTreeNodes.Add(asm, cachedInfo = new CachedAssemblyTreeNode(asmNode)); else { Debug.Assert(cachedInfo.AssemblyTreeNode == asmNode); if (cachedInfo.AssemblyTreeNode != asmNode) throw new InvalidOperationException(); } cachedInfo.Counter++; }
public UndoRedoInfo(AssemblyTreeNode node, bool isInUndo, bool isInRedo) { this.IsInUndo = isInUndo; this.IsInRedo = isInRedo; this.Node = node; }
internal static bool HasPENode(AssemblyTreeNode node) { if (node == null) return false; // Currently only nodes loaded from files on disk have a PE node return node.DnSpyFile.PEImage != null && node.DnSpyFile.LoadedFromFile; }
public CachedAssemblyTreeNode(AssemblyTreeNode asmNode) { this.AssemblyTreeNode = asmNode; }
public AssemblyTreeNodeCreator(AssemblyTreeNode asmNode) : this(asmNode.LoadedAssembly, asmNode, true) { }
public void Dispose() { if (asmNode != null) MainWindow.Instance.AssemblyListTreeNode.UnregisterCached(asmNode.LoadedAssembly); asmNode = null; }
AddExistingNetModuleToAssemblyCommand(AssemblyTreeNode asmNode, LoadedAssembly asm) : base(asmNode, new AssemblyTreeNode(asm), false) { }
AssemblySettingsCommand(AssemblyTreeNode asmNode, AssemblyOptions newOptions) { this.asmNode = asmNode; this.newOptions = newOptions; this.origOptions = new AssemblyOptions(asmNode.LoadedAssembly.AssemblyDefinition); }
public static bool AskUserToSaveIfModified(AssemblyTreeNode asmNode) { return AskUserToSaveIfModified(new[] { asmNode.LoadedAssembly }); }
ModuleSettingsCommand(AssemblyTreeNode modNode, ModuleOptions newOptions) { this.modNode = modNode; this.newOptions = newOptions; this.origOptions = new ModuleOptions(modNode.LoadedAssembly.ModuleDefinition); }
AssemblyTreeNodeCreator(LoadedAssembly asm, AssemblyTreeNode asmNode, bool restoreIndex) { this.asmNode = asmNode ?? new AssemblyTreeNode(asm); this.restoreIndex = restoreIndex; MainWindow.Instance.AssemblyListTreeNode.RegisterCached(asm, this.asmNode); }
RemoveAssemblyCommand(AssemblyTreeNode[] asmNodes) { this.savedStates = new AssemblyTreeNodeCreator[asmNodes.Length]; try { for (int i = 0; i < this.savedStates.Length; i++) this.savedStates[i] = new AssemblyTreeNodeCreator(asmNodes[i]); } catch { Dispose(); throw; } }
static IEnumerable<AssemblyTreeNode> GetAssemblyNodes(AssemblyTreeNode node) { if (!node.IsAssembly || node.Children.Count == 0) yield return node; else { foreach (AssemblyTreeNode child in node.Children) yield return child; } }
public ReferenceFolderTreeNode(PEFile module, AssemblyTreeNode parentAssembly) { this.module = module; this.parentAssembly = parentAssembly; this.LazyLoading = true; }