How can we help you today? How can we help you today?

How programmaticaly change selected type?

I try change name (or add new method, or delete field, or rename field and so on) of selected type declaration from my add-in and Reflector allways throw System.NotSupportedException
This is example of code from my add-in:
// rename selected type after clicking button on my add-in window
        // AssemblyBrowser is property that sets to (IAssemblyBrowser)serviceProvider.GetService(typeof(IAssemblyBrowser)) on package loading
        private void buttonRename_Click(object sender, EventArgs e)
        {
            ITypeDeclaration typeDeclaration = AssemblyBrowser.ActiveItem as ITypeDeclaration;

            if (typeDeclaration != null)
            {
                typeDeclaration.Name = "MyName";
            }
        }
Exception throws in Reflector's method ᝽.set_Name(String value).

Where is my mistake and how I can change type declaration?
Aliera
0

Comments

1 comment

  • haleyjason
    As far as I know the types are sort of readonly in Reflector - meaning you can't change values. However you could create your own cloner by using the objects in the CodeModel - but doing so will snowball on you mostlikely. Once you clone one object, you'll need to clone all of its children and members, etc.
    haleyjason
    0

Add comment

Please sign in to leave a comment.