I'm currently working on a compiler(transpiler?) from methbases to C# expression trees which uses ILSpy. The general problem I'm having is linking System.Reflection.MethodBases to the correct methodDeclarations in the NRefactory AST outputted by ILSpy.
I'm well aware of ILSpy's ability to give an AST for an entire assembly, such as:
AssemblyDefinition pAssembly = AssemblyDefinition.ReadAssembly(filename, parameters);
AstBuilder pDecompiler = new AstBuilder(new DecompilerContext(pAssembly.MainModule));
pDecompiler.AddAssembly(pAssembly);
pDecompiler.RunTransformations();
ast = pDecompiler.SyntaxTree;
However, would it be possible to invoke ILSpy for a small snippet of IL, such as you can obtain by calling:
m.GetMethodBody().GetILAsByteArray()
This would make it very easy to solve the methodbase pairing problem, to which I have a very horrid solution at the moment.