Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
365 views
in Technique[技术] by (71.8m points)

c# - A tool for easy IL code inspection

Sometimes I would like to quickly see the IL representation of my code snippets in C#, to understand what exactly happens to various code statements under the hood, like it's done here for example.

I know there are ildasm, Reflector, ILSpy, dotPeek and probably quite some other tools available. What I'm wondering here is that if there is any more elegant way from writing some lines of code to seeing the corresponding IL, than compiling your .net code, loading the assembly into one of those programs and finding the code you are curious about.

Maybe having a plugin for visual studio, which would add a right click option for "build and see IL code" or any other convenient way?

Edit:

After some more googling I found NDasm codeplex project which does what I was looking for - integrates into visual studio.

But vcsjones' LINQPad suggestion is great as well, thus I am marking it as accepted, thanks. A really useful tool ...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I typically use LINQPad for that. Just paste in some C# and switch to the IL view. For example:

enter image description here

I like it because you can also just post expressions or statements instead of a full program:

enter image description here

Best of all, it's free (with optional premium features).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...