开发者

Programmatically translate C# to IL

开发者 https://www.devze.com 2022-12-08 05:25 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消