Esempio n. 1
0
 public ModuleState(CorModuleDefFile corModuleDefFile, IModuleDocumentNode moduleNode, HashSet <uint> modifiedTypes, HashSet <uint> loadClassHash)
 {
     this.CorModuleDefFile = corModuleDefFile;
     this.ModuleNode       = moduleNode;
     this.ModifiedTypes    = modifiedTypes;
     this.LoadClassHash    = loadClassHash;
 }
Esempio n. 2
0
            SolveAllMethods(IMethodAnnotations methodAnnotations, IModuleDocumentNode moduleNode, List <DeadInstr> deadInstructions, CancellationToken token)
            {
                this.methodAnnotations = methodAnnotations;
                this.moduleNode        = moduleNode;

                this.methods = new List <MethodDef>();

                var module = moduleNode.GetModule();

                if (module.HasTypes)
                {
                    foreach (TypeDef type in (IEnumerable <TypeDef>)module.Types)
                    {
                        AddMethods(methods, type);
                    }
                }

                this.origMethodBodys = new List <MethodBody>();
                foreach (var method in this.methods)
                {
                    this.origMethodBodys.Add(method.MethodBody);
                }

                this.deadInstructions = new DeadInstr[deadInstructions.Count];
                deadInstructions.CopyTo(this.deadInstructions);

                this.isBodyModified = new List <bool>();

                this.token = token;
            }
Esempio n. 3
0
 public NamespaceNodeCreator(string ns, IModuleDocumentNode modNode)
 {
     this.modNode = modNode;
     this.nsNode  = modNode.FindNode(ns);
     if (this.nsNode == null)
     {
         this.nsNode        = modNode.Create(ns);
         this.nsNodeCreated = true;
     }
 }
Esempio n. 4
0
 public AddUpdatedNodesHelper(Lazy <IMethodAnnotations> methodAnnotations, IModuleDocumentNode 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.Document.ModuleDef))
     {
         throw new InvalidOperationException();
     }
 }
Esempio n. 5
0
 public TreeViewUpdater(IDocumentTabService documentTabService, CorModuleDefFile cmdf, IModuleDocumentNode node, HashSet <uint> modifiedTypes, HashSet <uint> loadedClassTokens)
 {
     Debug.Assert(node.Document == cmdf);
     this.documentTabService = documentTabService;
     this.CorModuleDefFile   = cmdf;
     this.ModuleNode         = node;
     this.modifiedTypes      = new HashSet <uint>(modifiedTypes);
     this.loadedClassTokens  = loadedClassTokens;
     this.checkedTypes       = new HashSet <TypeDef>();
     this.modNode            = node;
 }
Esempio n. 6
0
 protected AddNetModuleToAssemblyCommand(IUndoCommandService undoCommandService, IDsDocumentNode asmNode, IModuleDocumentNode modNode, bool modNodeWasCreated)
 {
     this.undoCommandService = undoCommandService;
     if (!(asmNode is IAssemblyDocumentNode))
     {
         asmNode = (IAssemblyDocumentNode)asmNode.TreeNode.Parent.Data;
     }
     this.asmNode           = (IAssemblyDocumentNode)asmNode;
     this.modNode           = modNode;
     this.modNodeWasCreated = modNodeWasCreated;
 }
 public EditedMethodBodyUpdater(Lazy <IMethodAnnotations> methodAnnotations, IModuleDocumentNode modNode, MethodDef originalMethod, Emit.MethodBody newBody, MethodImplAttributes newImplAttributes)
 {
     this.methodAnnotations = methodAnnotations;
     this.ownerNode         = modNode.Context.DocumentTreeView.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);
 }
Esempio n. 8
0
        static INamespaceNode GetOrCreateNamespaceNode(IModuleDocumentNode 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);
        }
Esempio n. 9
0
 RemoveNetModuleFromAssemblyCommand(Lazy <IUndoCommandService> undoCommandService, IModuleDocumentNode modNode)
 {
     this.undoCommandService = undoCommandService;
     this.asmNode            = (IAssemblyDocumentNode)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.Document.AssemblyDef != null &&
                  asmNode.Document.AssemblyDef.Modules.IndexOf(modNode.Document.ModuleDef) == this.removeIndex);
     this.removeIndexDocument = asmNode.Document.Children.IndexOf(modNode.Document);
     Debug.Assert(this.removeIndexDocument >= 0);
 }
Esempio n. 10
0
        static ITypeNode GetOrCreateNonNestedTypeTreeNode(IModuleDocumentNode 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);
        }
Esempio n. 11
0
 public NestedTypeNodeCreator(IModuleDocumentNode 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.DocumentTreeView.CreateNested(nestedType);
 }
Esempio n. 12
0
 public TypeNodeCreator(IModuleDocumentNode 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.Document.ModuleDef.Types;
     this.nsNodeCreator = new NamespaceNodeCreator(type.Namespace, modNode);
     this.typeNode      = modNode.Context.DocumentTreeView.Create(type);
 }
Esempio n. 13
0
        public ExistingTypeNodeUpdater(Lazy <IMethodAnnotations> methodAnnotations, IModuleDocumentNode modNode, MergedImportedType type)
        {
            this.typeNode = modNode.Context.DocumentTreeView.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();
        }
Esempio n. 14
0
 public MethodNodeCreator(IModuleDocumentNode modNode, ITypeNode ownerNode, MethodDef method)
 {
     this.ownerNode  = ownerNode;
     this.methodNode = modNode.Context.DocumentTreeView.Create(method);
 }
Esempio n. 15
0
 static IAssemblyDocumentNode GetParentAssembly(IModuleDocumentNode modNode) =>
 modNode?.TreeNode?.Parent?.Data as IAssemblyDocumentNode;
Esempio n. 16
0
 ModuleSettingsCommand(IModuleDocumentNode modNode, ModuleOptions newOptions)
 {
     this.modNode     = modNode;
     this.newOptions  = newOptions;
     this.origOptions = new ModuleOptions(modNode.Document.ModuleDef);
 }
Esempio n. 17
0
 public PropertyNodeCreator(IModuleDocumentNode modNode, ITypeNode ownerNode, PropertyDef property)
 {
     this.ownerNode = ownerNode;
     this.propNode  = modNode.Context.DocumentTreeView.Create(property);
 }
Esempio n. 18
0
 public FieldNodeCreator(IModuleDocumentNode modNode, ITypeNode ownerNode, FieldDef field)
 {
     this.ownerNode = ownerNode;
     this.fieldNode = modNode.Context.DocumentTreeView.Create(field);
 }
Esempio n. 19
0
 EditMethodBodyCodeCommand(Lazy <IMethodAnnotations> methodAnnotations, IModuleDocumentNode modNode, ModuleImporter importer)
 {
     this.addUpdatedNodesHelper = new AddUpdatedNodesHelper(methodAnnotations, modNode, importer);
 }
Esempio n. 20
0
 public EventNodeCreator(IModuleDocumentNode modNode, ITypeNode ownerNode, EventDef @event)
 {
     this.ownerNode = ownerNode;
     this.eventNode = modNode.Context.DocumentTreeView.Create(@event);
 }
Esempio n. 21
0
 AddNewNetModuleToAssemblyCommand(IUndoCommandService undoCommandService, IDsDocumentNode asmNode, IModuleDocumentNode modNode)
     : base(undoCommandService, asmNode, modNode, true)
 {
 }
Esempio n. 22
0
 public ReferencesFolderNode(ITreeNodeGroup treeNodeGroup, IModuleDocumentNode moduleNode)
 {
     Debug.Assert(moduleNode.Document.ModuleDef != null);
     this.TreeNodeGroup = treeNodeGroup;
     this.moduleNode    = moduleNode;
 }
Esempio n. 23
0
 AddExistingNetModuleToAssemblyCommand(IUndoCommandService undoCommandService, IDsDocumentNode asmNode, IModuleDocumentNode modNode)
     : base(undoCommandService, asmNode, modNode, false)
 {
 }