Beispiel #1
0
 public ModuleState(CorModuleDefFile corModuleDefFile, IModuleFileNode moduleNode, HashSet <uint> modifiedTypes, HashSet <uint> loadClassHash)
 {
     this.CorModuleDefFile = corModuleDefFile;
     this.ModuleNode       = moduleNode;
     this.ModifiedTypes    = modifiedTypes;
     this.LoadClassHash    = loadClassHash;
 }
		public NamespaceNodeCreator(string ns, IModuleFileNode modNode) {
			this.modNode = modNode;
			this.nsNode = modNode.FindNode(ns);
			if (this.nsNode == null) {
				this.nsNode = modNode.Create(ns);
				this.nsNodeCreated = true;
			}
		}
Beispiel #3
0
 public AddUpdatedNodesHelper(Lazy <IMethodAnnotations> methodAnnotations, IModuleFileNode modNode, ModuleImporter importer)
 {
     this.modNode                  = modNode;
     this.newTypeNodeCreators      = importer.NewNonNestedTypes.Select(a => new TypeNodeCreator(modNode, a.TargetType)).ToArray();
     this.existingTypeNodeUpdaters = importer.MergedNonNestedTypes.Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray();
     if (!importer.MergedNonNestedTypes.All(a => a.TargetType.Module == modNode.DnSpyFile.ModuleDef))
     {
         throw new InvalidOperationException();
     }
 }
Beispiel #4
0
		public TreeViewUpdater(IFileTabManager fileTabManager, CorModuleDefFile cmdf, IModuleFileNode node, HashSet<uint> modifiedTypes, HashSet<uint> loadedClassTokens) {
			Debug.Assert(node.DnSpyFile == cmdf);
			this.fileTabManager = fileTabManager;
			this.CorModuleDefFile = cmdf;
			this.ModuleNode = node;
			this.modifiedTypes = new HashSet<uint>(modifiedTypes);
			this.loadedClassTokens = loadedClassTokens;
			this.checkedTypes = new HashSet<TypeDef>();
			this.modNode = node;
		}
 public NamespaceNodeCreator(string ns, IModuleFileNode modNode)
 {
     this.modNode = modNode;
     this.nsNode  = modNode.FindNode(ns);
     if (this.nsNode == null)
     {
         this.nsNode        = modNode.Create(ns);
         this.nsNodeCreated = true;
     }
 }
Beispiel #6
0
 protected AddNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode, bool modNodeWasCreated)
 {
     this.undoCommandManager = undoCommandManager;
     if (!(asmNode is IAssemblyFileNode))
     {
         asmNode = (IAssemblyFileNode)asmNode.TreeNode.Parent.Data;
     }
     this.asmNode           = (IAssemblyFileNode)asmNode;
     this.modNode           = modNode;
     this.modNodeWasCreated = modNodeWasCreated;
 }
Beispiel #7
0
 public TreeViewUpdater(IFileTabManager fileTabManager, CorModuleDefFile cmdf, IModuleFileNode node, HashSet <uint> modifiedTypes, HashSet <uint> loadedClassTokens)
 {
     Debug.Assert(node.DnSpyFile == cmdf);
     this.fileTabManager    = fileTabManager;
     this.CorModuleDefFile  = cmdf;
     this.ModuleNode        = node;
     this.modifiedTypes     = new HashSet <uint>(modifiedTypes);
     this.loadedClassTokens = loadedClassTokens;
     this.checkedTypes      = new HashSet <TypeDef>();
     this.modNode           = node;
 }
 public EditedMethodBodyUpdater(Lazy <IMethodAnnotations> methodAnnotations, IModuleFileNode modNode, MethodDef originalMethod, Emit.MethodBody newBody, MethodImplAttributes newImplAttributes)
 {
     this.methodAnnotations = methodAnnotations;
     this.ownerNode         = modNode.Context.FileTreeView.FindNode(originalMethod);
     if (ownerNode == null)
     {
         throw new InvalidOperationException();
     }
     this.method            = originalMethod;
     this.originalBodyState = new BodyState(originalMethod, methodAnnotations.Value.IsBodyModified(method));
     this.newBodyState      = new BodyState(newBody, newImplAttributes, true);
 }
Beispiel #9
0
 RemoveNetModuleFromAssemblyCommand(Lazy <IUndoCommandManager> undoCommandManager, IModuleFileNode modNode)
 {
     this.undoCommandManager = undoCommandManager;
     this.asmNode            = (IAssemblyFileNode)modNode.TreeNode.Parent.Data;
     Debug.Assert(this.asmNode != null);
     this.modNode     = modNode;
     this.removeIndex = asmNode.TreeNode.DataChildren.ToList().IndexOf(modNode);
     Debug.Assert(this.removeIndex > 0);
     Debug.Assert(asmNode.DnSpyFile.AssemblyDef != null &&
                  asmNode.DnSpyFile.AssemblyDef.Modules.IndexOf(modNode.DnSpyFile.ModuleDef) == this.removeIndex);
     this.removeIndexDnSpyFile = asmNode.DnSpyFile.Children.IndexOf(modNode.DnSpyFile);
     Debug.Assert(this.removeIndexDnSpyFile >= 0);
 }
Beispiel #10
0
        static INamespaceNode GetOrCreateNamespaceNode(IModuleFileNode modNode, string ns)
        {
            modNode.TreeNode.EnsureChildrenLoaded();
            var nsNode = modNode.TreeNode.DataChildren.OfType <INamespaceNode>().FirstOrDefault(a => a.Name == ns);

            if (nsNode != null)
            {
                return(nsNode);
            }
            nsNode = modNode.Create(ns);
            modNode.TreeNode.AddChild(nsNode.TreeNode);
            return(nsNode);
        }
Beispiel #11
0
        static ITypeNode GetOrCreateNonNestedTypeTreeNode(IModuleFileNode modNode, TypeDef type)
        {
            Debug.Assert(type != null && type.DeclaringType == null);
            modNode.TreeNode.EnsureChildrenLoaded();
            ITypeNode typeNode;
            var       nsNode = GetOrCreateNamespaceNode(modNode, type.Namespace);

            typeNode = nsNode.TreeNode.DataChildren.OfType <ITypeNode>().FirstOrDefault(a => a.TypeDef == type);
            if (typeNode != null)
            {
                return(typeNode);
            }
            typeNode = nsNode.Create(type);
            nsNode.TreeNode.AddChild(typeNode.TreeNode);
            return(typeNode);
        }
 public NestedTypeNodeCreator(IModuleFileNode modNode, ITypeNode ownerTypeNode, TypeDef nestedType)
 {
     if (modNode == null)
     {
         throw new ArgumentNullException(nameof(modNode));
     }
     if (nestedType == null)
     {
         throw new ArgumentNullException(nameof(nestedType));
     }
     if (nestedType.Module != null)
     {
         throw new ArgumentException();
     }
     this.ownerTypeNode  = ownerTypeNode;
     this.nestedTypeNode = modNode.Context.FileTreeView.CreateNested(nestedType);
 }
Beispiel #13
0
 public TypeNodeCreator(IModuleFileNode modNode, TypeDef type)
 {
     if (modNode == null)
     {
         throw new ArgumentNullException(nameof(modNode));
     }
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     // Can't be a nested type, and can't be part of a module yet
     if (type.DeclaringType != null || type.Module != null)
     {
         throw new ArgumentException();
     }
     this.ownerList     = modNode.DnSpyFile.ModuleDef.Types;
     this.nsNodeCreator = new NamespaceNodeCreator(type.Namespace, modNode);
     this.typeNode      = modNode.Context.FileTreeView.Create(type);
 }
Beispiel #14
0
        public ExistingTypeNodeUpdater(Lazy <IMethodAnnotations> methodAnnotations, IModuleFileNode modNode, MergedImportedType type)
        {
            this.typeNode = modNode.Context.FileTreeView.FindNode(type.TargetType);
            if (this.typeNode == null)
            {
                throw new InvalidOperationException();
            }
            this.nestedTypes1 = type.NewNestedTypes.OfType <MergedImportedType>().Select(a => new ExistingTypeNodeUpdater(methodAnnotations, modNode, a)).ToArray();
            this.nestedTypes2 = type.NewNestedTypes.OfType <NewImportedType>().Select(a => new NestedTypeNodeCreator(modNode, typeNode, a.TargetType)).ToArray();
            if (nestedTypes1.Length + nestedTypes2.Length != type.NewNestedTypes.Count)
            {
                throw new InvalidOperationException();
            }
            this.fields = type.NewFields.Select(a => new FieldNodeCreator(modNode, typeNode, a)).ToArray();
            var specialMethods = GetSpecialMethods(type);

            this.methods       = type.NewMethods.Where(a => !specialMethods.Contains(a)).Select(a => new MethodNodeCreator(modNode, typeNode, a)).ToArray();
            this.events        = type.NewEvents.Select(a => new EventNodeCreator(modNode, typeNode, a)).ToArray();
            this.properties    = type.NewProperties.Select(a => new PropertyNodeCreator(modNode, typeNode, a)).ToArray();
            this.editedMethods = type.EditedMethodBodies.Select(a => new EditedMethodBodyUpdater(methodAnnotations, modNode, a.OriginalMethod, a.NewBody, a.ImplAttributes)).ToArray();
        }
Beispiel #15
0
			public ModuleState(CorModuleDefFile corModuleDefFile, IModuleFileNode moduleNode, HashSet<uint> modifiedTypes, HashSet<uint> loadClassHash) {
				this.CorModuleDefFile = corModuleDefFile;
				this.ModuleNode = moduleNode;
				this.ModifiedTypes = modifiedTypes;
				this.LoadClassHash = loadClassHash;
			}
Beispiel #16
0
 AddExistingNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
     : base(undoCommandManager, asmNode, modNode, false)
 {
 }
Beispiel #17
0
 AddNewNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
     : base(undoCommandManager, asmNode, modNode, true)
 {
 }
 public FieldNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, FieldDef field)
 {
     this.ownerNode = ownerNode;
     this.fieldNode = modNode.Context.FileTreeView.Create(field);
 }
Beispiel #19
0
		AddExistingNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
			: base(undoCommandManager, asmNode, modNode, false) {
		}
 public PropertyNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, PropertyDef property)
 {
     this.ownerNode = ownerNode;
     this.propNode  = modNode.Context.FileTreeView.Create(property);
 }
Beispiel #21
0
 public MethodNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, MethodDef method)
 {
     this.ownerNode  = ownerNode;
     this.methodNode = modNode.Context.FileTreeView.Create(method);
 }
 static IAssemblyFileNode GetParentAssembly(IModuleFileNode modNode) =>
 modNode?.TreeNode?.Parent?.Data as IAssemblyFileNode;
Beispiel #23
0
		protected AddNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode, bool modNodeWasCreated) {
			this.undoCommandManager = undoCommandManager;
			if (!(asmNode is IAssemblyFileNode))
				asmNode = (IAssemblyFileNode)asmNode.TreeNode.Parent.Data;
			this.asmNode = (IAssemblyFileNode)asmNode;
			this.modNode = modNode;
			this.modNodeWasCreated = modNodeWasCreated;
		}
Beispiel #24
0
 EditMethodBodyCodeCommand(Lazy <IMethodAnnotations> methodAnnotations, IModuleFileNode modNode, ModuleImporter importer)
 {
     this.addUpdatedNodesHelper = new AddUpdatedNodesHelper(methodAnnotations, modNode, importer);
 }
		static IAssemblyFileNode GetParentAssembly(IModuleFileNode modNode) {
			var parent = modNode == null ? null : modNode.TreeNode.Parent;
			return parent == null ? null : parent.Data as IAssemblyFileNode;
		}
Beispiel #26
0
		static ITypeNode GetOrCreateNonNestedTypeTreeNode(IModuleFileNode modNode, TypeDef type) {
			Debug.Assert(type != null && type.DeclaringType == null);
			modNode.TreeNode.EnsureChildrenLoaded();
			ITypeNode typeNode;
			var nsNode = GetOrCreateNamespaceNode(modNode, type.Namespace);
			typeNode = nsNode.TreeNode.DataChildren.OfType<ITypeNode>().FirstOrDefault(a => a.TypeDef == type);
			if (typeNode != null)
				return typeNode;
			typeNode = nsNode.Create(type);
			nsNode.TreeNode.AddChild(typeNode.TreeNode);
			return typeNode;
		}
Beispiel #27
0
		ModuleSettingsCommand(IModuleFileNode modNode, ModuleOptions newOptions) {
			this.modNode = modNode;
			this.newOptions = newOptions;
			this.origOptions = new ModuleOptions(modNode.DnSpyFile.ModuleDef);
		}
Beispiel #28
0
		RemoveNetModuleFromAssemblyCommand(Lazy<IUndoCommandManager> undoCommandManager, IModuleFileNode modNode) {
			this.undoCommandManager = undoCommandManager;
			this.asmNode = (IAssemblyFileNode)modNode.TreeNode.Parent.Data;
			Debug.Assert(this.asmNode != null);
			this.modNode = modNode;
			this.removeIndex = asmNode.TreeNode.DataChildren.ToList().IndexOf(modNode);
			Debug.Assert(this.removeIndex > 0);
			Debug.Assert(asmNode.DnSpyFile.AssemblyDef != null &&
				asmNode.DnSpyFile.AssemblyDef.Modules.IndexOf(modNode.DnSpyFile.ModuleDef) == this.removeIndex);
			this.removeIndexDnSpyFile = asmNode.DnSpyFile.Children.IndexOf(modNode.DnSpyFile);
			Debug.Assert(this.removeIndexDnSpyFile >= 0);
		}
 public EventNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, EventDef @event)
 {
     this.ownerNode = ownerNode;
     this.eventNode = modNode.Context.FileTreeView.Create(@event);
 }
Beispiel #30
0
 public ReferencesFolderNode(ITreeNodeGroup treeNodeGroup, IModuleFileNode moduleNode)
 {
     Debug.Assert(moduleNode.DnSpyFile.ModuleDef != null);
     this.TreeNodeGroup = treeNodeGroup;
     this.moduleNode    = moduleNode;
 }
Beispiel #31
0
        static IAssemblyFileNode GetParentAssembly(IModuleFileNode modNode)
        {
            var parent = modNode == null ? null : modNode.TreeNode.Parent;

            return(parent == null ? null : parent.Data as IAssemblyFileNode);
        }
Beispiel #32
0
		static INamespaceNode GetOrCreateNamespaceNode(IModuleFileNode modNode, string ns) {
			modNode.TreeNode.EnsureChildrenLoaded();
			var nsNode = modNode.TreeNode.DataChildren.OfType<INamespaceNode>().FirstOrDefault(a => a.Name == ns);
			if (nsNode != null)
				return nsNode;
			nsNode = modNode.Create(ns);
			modNode.TreeNode.AddChild(nsNode.TreeNode);
			return nsNode;
		}
Beispiel #33
0
 ModuleSettingsCommand(IModuleFileNode modNode, ModuleOptions newOptions)
 {
     this.modNode     = modNode;
     this.newOptions  = newOptions;
     this.origOptions = new ModuleOptions(modNode.DnSpyFile.ModuleDef);
 }
 public ReferencesFolderNode(ITreeNodeGroup treeNodeGroup, IModuleFileNode moduleNode)
 {
     Debug.Assert(moduleNode.DnSpyFile.ModuleDef != null);
     this.treeNodeGroup = treeNodeGroup;
     this.moduleNode = moduleNode;
 }
Beispiel #35
0
		AddNewNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
			: base(undoCommandManager, asmNode, modNode, true) {
		}