Reputation: 3896
How to parse C# source code for generating IL opcodes, that could be used in DynamicMethod?
I want to execute code dynamically without generating unnecessary assemblies. Something like this:
var body = "return \"sample\";";
var dm = new DynamicMethod("method_" + Guid.NewGuid().ToString("N"), typeof(string), null);
var parser = new SomeKindOfCSharpParser();
parser.Emit(body, m.GetILGenerator());
Upvotes: 2
Views: 1272
Reputation: 5843
There is no way to implement it.
You have a few ways to implement it:
Upvotes: 1