Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was reading through the code of StackOverflow's new SQL Object Mapper. And I noticed at the bottom of the SqlMapper.cs there is some code that I had never seen before. After reading some of the documentation on MSDN and a tutorial on MSIL this feels a little over my head.

As a professional .NET developer (6 years), should I invest time to learn this? What is the advantage of understanding the ILGenerator?

I hope I'm not confusing things and the question is clear.


share|improve this question

closed as off-topic by durron597, MichaelT, enderland, Snowman, Dan Pichelman Jul 13 '15 at 18:21

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – durron597, Dan Pichelman
  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – enderland, Snowman
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 5 down vote accepted

I can't write MSIL, so keep in mind that my answer would be akin to the blind leading the blind :)

That said, I think it may be a better question to ask "Why would you want to work directly with MSIL"? The answers would then help you decide if you even need to worry about it.

This question does a pretty good job at going over what you can do in MSIL that you can't do in other .net languages - which is presumably the main reason you'd even worry about MSIL. If things listed here are foreign to you, then read up on those topics first. I'd also recommend reading CLR via C# by Jeffrey Richter if you haven't already. It is definitely something you should read (or be familiar with the concepts covered) before you worry about MSIL (it does go into MSIL, and the things that the CLR - and hence MSIL will allow you to do that C# doesn't).

Bottom line, I'd say that there are plenty of prerequisites to learning to work directly with MSIL, and by the time you've mastered those concepts you'll know when you should break out the MSIL and learn/use it.

share|improve this answer

Yes, you'd better learn MSIL, because code generation is a very powerful (probably, the most powerful) programming technique, and in .NET it is really easy to compile a highly efficient code from your domain specific languages. Some of the IL features are not available from C# (e.g., tail calls).

Needless to mention that it will also help to understand better how .NET works. And it won't require a significant effort to learn, as .NET is one of the simplest VMs out there, it is much simpler than, say, JVM.

share|improve this answer

I'm currently working with something called Object List View. Some of the magic behind how it works is that it generates IL code on the fly. I've never encountered this before, and I've been working with .NET for about as long as you have.

I can't tell you what you should or should not be studying on your own, but this is something I am planning on learning to do on my own this summer.

share|improve this answer
thanks for the information, it does look like an interesting control. – Peter May 26 '11 at 8:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.