Пример #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;
 }
Пример #2
0
		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;
			}
		}
Пример #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();
     }
 }
Пример #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;
		}
Пример #5
0
 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;
     }
 }
Пример #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;
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
        }
Пример #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);
        }
Пример #12
0
 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);
 }
Пример #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);
 }
Пример #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();
        }
Пример #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;
			}
Пример #16
0
 AddExistingNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
     : base(undoCommandManager, asmNode, modNode, false)
 {
 }
Пример #17
0
 AddNewNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
     : base(undoCommandManager, asmNode, modNode, true)
 {
 }
Пример #18
0
 public FieldNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, FieldDef field)
 {
     this.ownerNode = ownerNode;
     this.fieldNode = modNode.Context.FileTreeView.Create(field);
 }
Пример #19
0
		AddExistingNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
			: base(undoCommandManager, asmNode, modNode, false) {
		}
Пример #20
0
 public PropertyNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, PropertyDef property)
 {
     this.ownerNode = ownerNode;
     this.propNode  = modNode.Context.FileTreeView.Create(property);
 }
Пример #21
0
 public MethodNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, MethodDef method)
 {
     this.ownerNode  = ownerNode;
     this.methodNode = modNode.Context.FileTreeView.Create(method);
 }
Пример #22
0
 static IAssemblyFileNode GetParentAssembly(IModuleFileNode modNode) =>
 modNode?.TreeNode?.Parent?.Data as IAssemblyFileNode;
Пример #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;
		}
Пример #24
0
 EditMethodBodyCodeCommand(Lazy <IMethodAnnotations> methodAnnotations, IModuleFileNode modNode, ModuleImporter importer)
 {
     this.addUpdatedNodesHelper = new AddUpdatedNodesHelper(methodAnnotations, modNode, importer);
 }
Пример #25
0
		static IAssemblyFileNode GetParentAssembly(IModuleFileNode modNode) {
			var parent = modNode == null ? null : modNode.TreeNode.Parent;
			return parent == null ? null : parent.Data as IAssemblyFileNode;
		}
Пример #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;
		}
Пример #27
0
		ModuleSettingsCommand(IModuleFileNode modNode, ModuleOptions newOptions) {
			this.modNode = modNode;
			this.newOptions = newOptions;
			this.origOptions = new ModuleOptions(modNode.DnSpyFile.ModuleDef);
		}
Пример #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);
		}
Пример #29
0
 public EventNodeCreator(IModuleFileNode modNode, ITypeNode ownerNode, EventDef @event)
 {
     this.ownerNode = ownerNode;
     this.eventNode = modNode.Context.FileTreeView.Create(@event);
 }
Пример #30
0
 public ReferencesFolderNode(ITreeNodeGroup treeNodeGroup, IModuleFileNode moduleNode)
 {
     Debug.Assert(moduleNode.DnSpyFile.ModuleDef != null);
     this.TreeNodeGroup = treeNodeGroup;
     this.moduleNode    = moduleNode;
 }
Пример #31
0
        static IAssemblyFileNode GetParentAssembly(IModuleFileNode modNode)
        {
            var parent = modNode == null ? null : modNode.TreeNode.Parent;

            return(parent == null ? null : parent.Data as IAssemblyFileNode);
        }
Пример #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;
		}
Пример #33
0
 ModuleSettingsCommand(IModuleFileNode modNode, ModuleOptions newOptions)
 {
     this.modNode     = modNode;
     this.newOptions  = newOptions;
     this.origOptions = new ModuleOptions(modNode.DnSpyFile.ModuleDef);
 }
Пример #34
0
 public ReferencesFolderNode(ITreeNodeGroup treeNodeGroup, IModuleFileNode moduleNode)
 {
     Debug.Assert(moduleNode.DnSpyFile.ModuleDef != null);
     this.treeNodeGroup = treeNodeGroup;
     this.moduleNode = moduleNode;
 }
Пример #35
0
		AddNewNetModuleToAssemblyCommand(IUndoCommandManager undoCommandManager, IDnSpyFileNode asmNode, IModuleFileNode modNode)
			: base(undoCommandManager, asmNode, modNode, true) {
		}