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?
Asked
Active
Viewed 1,700 times
4
-
3I am pretty sure csc JUST compiles to IL, the framework it runs on turns it into executable code at runtime. – Ben Robinson Aug 29 '11 at 15:10
-
Actually, Mono contains both csc, gmcs and dmcs - that's just a steps of Mono C# compiler evolution, when it supports generics and dynamics. In Mono 2.8+ they are the same. – abatishchev Aug 29 '11 at 15:18
2 Answers
7
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.

Jordão
- 55,340
- 13
- 112
- 144
-
You could also use Cecil to extract it, but that's not as straight-forward. – Jonathan Dickinson Aug 29 '11 at 15:16
2
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.

Christoph Fink
- 22,727
- 9
- 68
- 113