I was using CodeMutatingVisitor to walk an assembly to scan for static method calls and replace them. Basically the flow went like this:
var testAssembly = host.LoadUnitFrom("somePath") as IAssembly;
var mutableAssembly = Decompiler.GetCodeModelFromMetadataModel(host, testAssembly, null);
var registrar = new StaticMethodCallRegistrar(host);
where the 'registrar' looked like this:
public class StaticMethodCallRegistrar : CodeMutatingVisitor
public StaticMethodCallRegistrar(IMetadataHost host) : base(host)
public override IExpression Visit(MethodCall methodCall)
// Do something
This code no longer works with recent changes to CodeModel. I'm wondering by what method I should achieve this traversal now.
For a little bit of background, I'm basically writing a post-compiler that does method replacement (for now just on static methods). The workflow is:
1 - Scan assembly for static method calls (shown above)
2 - Replace static methods identified with calls to different static methods (achieved by a second CodeMutatingVisitor that actually changes the value methodCall.MethodToCall)
I've actually always felt I was going about this the wrong way, but for quite some time it has worked nicely. I wasn't able to understand much from herman's svn comments or the diff for the latest changes to Mutator.cs in MutableCodeModel.
(P.S. Though it was frustrating at first to try to understand how to use the mutable CodeModel, now that I've become more familiar with it and developed some utilities of my own to easy in it's usage, I've really enjoyed working with this library. It is
incredibly powerful, and I appreciate the breadth and depth of the entire CCI library!)