Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate IL source code with csc (C# compiler) or dmcs (mono C# compiler)?

Tags:

c#

mono

il

csc

gcc has an option of -s to generate assembly source code. Does csc (MS C# compiler) or dmcs (mono C# compiler) have equivalence? I mean do those compilers provide an option to generate IL source code that can be read not the execution binary?

like image 275
prosseek Avatar asked Jan 19 '23 21:01

prosseek


2 Answers

It's very easy to get to the IL: just use ildasm. The /text option prints the result to the console, which you can divert to a file.

like image 87
Jordão Avatar answered Jan 31 '23 00:01

Jordão


A C# compiler always generates IL (CIL in the case for .net), because thats the way .net works, but if you mean you want to precompile this in to machine code to speed up execution you can use ngen.exe (see HERE).

If you just want to see the generated IL you can use ILSpy.

like image 34
Christoph Fink Avatar answered Jan 31 '23 01:01

Christoph Fink