RenameNamespaceCommand(string newName, NamespaceNode nsNode) { this.newName = newName; origName = nsNode.Name; this.nsNode = nsNode; existingNsNode = (NamespaceNode)nsNode.TreeNode.Parent.DataChildren.FirstOrDefault(a => a is NamespaceNode && newName == ((NamespaceNode)a).Name); var module = nsNode.GetModule(); Debug.Assert(module != null); if (module == null) { throw new InvalidOperationException(); } origParentNode = (DocumentTreeNodeData)nsNode.TreeNode.Parent.Data; origParentChildIndex = origParentNode.TreeNode.Children.IndexOf(nsNode.TreeNode); Debug.Assert(origParentChildIndex >= 0); if (origParentChildIndex < 0) { throw new InvalidOperationException(); } // Make sure the exact same namespace names are restored if we undo. The names are UTF8 // strings, but not necessarily canonicalized if it's an obfuscated assembly. nsNode.TreeNode.EnsureChildrenLoaded(); origChildren = nsNode.TreeNode.DataChildren.Cast <TypeNode>().ToArray(); typeNamespaces = new UTF8String[nsNode.TreeNode.Children.Count]; for (int i = 0; i < typeNamespaces.Length; i++) { typeNamespaces[i] = origChildren[i].TypeDef.Namespace; } typeRefInfos = GetTypeRefInfos(module, new[] { nsNode }); }