TypeDefSettingsCommand(ModuleDef module, ITypeNode typeNode, TypeDefOptions options) { this.module = module; this.typeNode = typeNode; this.newOptions = options; this.origOptions = new TypeDefOptions(typeNode.TypeDef); this.origParentNode = (IFileTreeNodeData)typeNode.TreeNode.Parent.Data; this.origParentChildIndex = this.origParentNode.TreeNode.Children.IndexOf(typeNode.TreeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; if (this.origParentNode is INamespaceNode) { var modNode = (IModuleFileNode)this.origParentNode.TreeNode.Parent.Data; if (newOptions.Namespace != origOptions.Namespace) { this.nsNodeCreator = new NamespaceNodeCreator(newOptions.Namespace, modNode); } } if (this.nameChanged || origOptions.Namespace != newOptions.Namespace) { this.typeRefInfos = RefFinder.FindTypeRefsToThisModule(module).Where(a => RefFinder.TypeEqualityComparerInstance.Equals(a, typeNode.TypeDef)).Select(a => new TypeRefInfo(a)).ToArray(); } }
TypeDefSettingsCommand(ModuleDef module, TypeTreeNode typeNode, TypeDefOptions options) { this.module = module; this.typeNode = typeNode; this.newOptions = options; this.origOptions = new TypeDefOptions(typeNode.TypeDefinition); this.origParentNode = (ILSpyTreeNode)typeNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(typeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; if (this.origParentNode is NamespaceTreeNode) { var asmNode = (AssemblyTreeNode)this.origParentNode.Parent; if (!AssemblyTreeNode.NamespaceStringEqualsComparer.Equals(newOptions.Namespace, origOptions.Namespace)) { this.nsNodeCreator = new NamespaceTreeNodeCreator(newOptions.Namespace, asmNode); } } if (this.nameChanged || origOptions.Namespace != newOptions.Namespace) { this.typeRefInfos = RefFinder.FindTypeRefsToThisModule(module).Where(a => RefFinder.TypeEqualityComparerInstance.Equals(a, typeNode.TypeDefinition)).Select(a => new TypeRefInfo(a)).ToArray(); } }
AssemblySettingsCommand(AssemblyDocumentNode asmNode, AssemblyOptions newOptions) { this.asmNode = asmNode; this.newOptions = newOptions; origOptions = new AssemblyOptions(asmNode.Document.AssemblyDef); if (newOptions.Name != origOptions.Name) { assemblyRefInfos = RefFinder.FindAssemblyRefsToThisModule(asmNode.Document.ModuleDef).Where(a => AssemblyNameComparer.NameAndPublicKeyTokenOnly.Equals(a, asmNode.Document.AssemblyDef)).Select(a => new AssemblyRefInfo(a)).ToArray(); } }
internal static TypeRefInfo[] GetTypeRefInfos(ModuleDef module, IEnumerable <NamespaceNode> nsNodes) { var types = new HashSet <ITypeDefOrRef>(RefFinder.TypeEqualityComparerInstance); foreach (var nsNode in nsNodes) { foreach (TypeNode typeNode in nsNode.TreeNode.DataChildren) { types.Add(typeNode.TypeDef); } } var typeRefs = RefFinder.FindTypeRefsToThisModule(module); return(typeRefs.Where(a => types.Contains(a)).Select(a => new TypeRefInfo(a)).ToArray()); }
FieldDefSettingsCommand(FieldNode fieldNode, FieldDefOptions options) { this.fieldNode = fieldNode; this.newOptions = options; this.origOptions = new FieldDefOptions(fieldNode.FieldDef); this.origParentNode = (DocumentTreeNodeData)fieldNode.TreeNode.Parent.Data; this.origParentChildIndex = this.origParentNode.TreeNode.Children.IndexOf(fieldNode.TreeNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; if (this.nameChanged) { this.memberRefInfos = RefFinder.FindMemberRefsToThisModule(fieldNode.GetModule()).Where(a => RefFinder.FieldEqualityComparerInstance.Equals(a, fieldNode.FieldDef)).Select(a => new MemberRefInfo(a)).ToArray(); } }
MethodDefSettingsCommand(MethodNode methodNode, MethodDefOptions options) { this.methodNode = methodNode; newOptions = options; origOptions = new MethodDefOptions(methodNode.MethodDef); origParentNode = (DocumentTreeNodeData)methodNode.TreeNode.Parent.Data; origParentChildIndex = origParentNode.TreeNode.Children.IndexOf(methodNode.TreeNode); Debug.Assert(origParentChildIndex >= 0); if (origParentChildIndex < 0) { throw new InvalidOperationException(); } nameChanged = origOptions.Name != newOptions.Name; if (nameChanged) { memberRefInfos = RefFinder.FindMemberRefsToThisModule(methodNode.GetModule()).Where(a => RefFinder.MethodEqualityComparerInstance.Equals(a, methodNode.MethodDef)).Select(a => new Field.MemberRefInfo(a)).ToArray(); } }
MethodDefSettingsCommand(MethodTreeNode methodNode, MethodDefOptions options) { this.methodNode = methodNode; this.newOptions = options; this.origOptions = new MethodDefOptions(methodNode.MethodDefinition); this.origParentNode = (ILSpyTreeNode)methodNode.Parent; this.origParentChildIndex = this.origParentNode.Children.IndexOf(methodNode); Debug.Assert(this.origParentChildIndex >= 0); if (this.origParentChildIndex < 0) { throw new InvalidOperationException(); } this.nameChanged = origOptions.Name != newOptions.Name; if (this.nameChanged) { this.memberRefInfos = RefFinder.FindMemberRefsToThisModule(ILSpyTreeNode.GetModule(methodNode)).Where(a => RefFinder.MethodEqualityComparerInstance.Equals(a, methodNode.MethodDefinition)).Select(a => new Field.MemberRefInfo(a)).ToArray(); } }