Programmatically translate C# to IL
I have my portfolio which uses the CSharpCodeProvider namespace to programmatically compile user entered code. Is there a class in Reflection or one of the "CSharp" 开发者_开发知识库namespaces which will allow me to translate C# to MSIL?
How does Reflector or LINQPad do this?
Reflector translates IL to C#.
What you want is the opposite.
It's called Microsoft.CSharp.CSharpCodeProvider
.
You programmatically configure it, but then it runs the csc.exe compiler to generate whatever you like. If you set the target to "netmodule" I guess it would generate bare IL.
Try to look at System.Reflection.Emit namespace.
精彩评论