rename metadata as parameters and returns the methods?

26 views
Skip to first unread message

aixeiger

unread,
Mar 18, 2013, 11:27:16 PM3/18/13
to mono-...@googlegroups.com
I read in a blog that can make proxies but I did not understand, I also read that literally I can not change the references to members, because the assembly crash, and wanted to ask if someone can enlighten me on how to make proxies to change the metadata of the arguments / method parameters?

Simon

unread,
Mar 19, 2013, 1:02:39 AM3/19/13
to mono-...@googlegroups.com
What Blog? Do you have a link?

What are you actually trying to achieve?

What code have you tried so far?

aixeiger

unread,
Mar 19, 2013, 4:45:07 PM3/19/13
to mono-...@googlegroups.com
not much

in this piece of code just rename metadata methods, fields and properties

but I do not rename the arguments / parameters and returns the methods

and a friend told me that for the parameters / arguments is the collection ParameterDefinition in MethodDefinition.Parameter but he said that these can not be renamed so only offer, as I do in the code for the other things he says to do proxies

but not like them


AssemblyDefinition definition = AssemblyDefinition.ReadAssembly(assembly);
                foreach (ModuleDefinition moduleDef in definition.Modules)
                    {
                        foreach (TypeDefinition typeDef in moduleDef.Types)
                        {
                            foreach (MethodDefinition methodDef in typeDef.Methods)
                            {
                                if(!methodDef.IsSpecialName&&!methodDef.IsRuntimeSpecialName&&!methodDef.IsConstructor)
                                    methodDef.Name = generateName(); // just string name generate here
                            }
                            foreach (PropertyDefinition propertyDef in typeDef.Properties)
                            {
                                    propertyDef.Name = generateName();
                            }
                            foreach (FieldDefinition fielDef in typeDef.Fields)
                            {
                                    fielDef.Name = generateName();
                            }
                        }
                    }
                definition.Write(n);
                }

Simon

unread,
Mar 20, 2013, 5:51:26 PM3/20/13
to mono-...@googlegroups.com
and the other two questions...
Reply all
Reply to author
Forward
0 new messages