[英]View CIL of C# code on Linux with mono
I want to inspect the generated CIL code of the following C# source file on Linux: 我想在Linux上检查以下C#源文件的生成的CIL代码:
using System;
namespace PrintPrimes
{
class Algorithm
{
static bool IsPrime(int p)
{
for (int i=2;i<p;i++)
{
for (int j=i;j<p;j++)
{
if (i*j == p)
{
return false;
}
}
}
return true;
}
static void Main()
{
for (int p=2;p<=20;p++)
{
if (IsPrime(p))
{
Console.WriteLine(p + " ");
}
}
}
}
}
When I compile and run it everything is fine: 当我编译并运行它时,一切都很好:
$ mcs -out:PrintPrimes PrintPrimes.cs
$ ./PrintPrimes
2
3
5
7
11
13
17
19
But how can I get the human readable CIL output? 但是,如何获得人类可读的CIL输出?
Mono disassembler, extracts IL code from an assembly: Mono反汇编程序,从程序集中提取IL代码:
monodis FILE-name
Full reference can be found here: https://www.mono-project.com/docs/tools+libraries/tools/monodis/ 完整的参考资料可以在这里找到: https : //www.mono-project.com/docs/tools+libraries/tools/monodis/
Dis/Assembling CIL Code (Mono Project) 分解/汇编CIL代码(Mono项目)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.