简体   繁体   中英

Can Roslyn compile C# to CIL

Can the Roslyn C# compiler be used to compile C# to CIL human readable code? Like the examples shown here : https://en.wikipedia.org/wiki/Common_Intermediate_Language

I know it can produce bytecode in EXE/DLL form, but I'm interested in the CIL code.

Either from the command line or API.

I know a disassembler could be used on the bytecode files but I would prefer a more direct approach.

Thanks.

Simply call ildasm.exe as your post-build step. Solutions should be composable steps instead of one monolithic monstrosity.

SharpLab can translate C#, Visual Basic, or F# on-the-fly to a number of formats, one of which is CIL.

It does so using Roslyn from the Roslyn repo and you can select which version you want it to use.

It's not an extension/command line tool/API, but it's likely to be very useful for anyone else trying to view CIL easily.

C# is automatically compiled to CIL. That is the target platform. (*Not sure about .NET Native/UWP).

Since it seems to me, that your goal is to show the generated CIL code, take a look at Msiler :

If you by chance use Resharper, there is an IL-Viewer included .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM