protected string CompileAndRunMethod <TDelegate, TParam>(TDelegate action, params TParam[] arguments) { var asm = GetAssembly(); var method = ImportMethod(asm, action); var context = new TestContext(asm, arguments.Cast <object>().ToArray()); context.MethodContexts.Add(CodeStream.Create(context, method)); try { //compile context = this.AssemblyCompiler.Compile(context) as TestContext; Helper.IsNotNull(context); //run the compiled exe and return output return(Helper.Execute(context.Output)); } catch (Exception e) { Helper.Break(); throw; } finally { if (context != null) { foreach (var file in context.OutputFiles) { File.Delete(file.Filename); } File.Delete(context.Output); } } }
public IMethodCompilerContext GetContext(IAssemblyCompilerContext context, MethodReference method) { return(CodeStream.Create(context, method)); }