August 14, 2007 spout writing

How you doin’?”

I wanted to figure out how to emit a new CLR type at run-time using Reflection.Emit and Google revealed the following article: Generating Code at Run Time With Reflection.Emit in DDJ.As usual, I skip most of the initial prose to the first code sample (I don’t need some author’s fancy intro — I just want the code!). Then, I’m reading along and I find some phrases I enjoy, e.g.

If you plan on generating lots of calls to Console.WriteLine(), you should be aware that the ILGenerator class exposes a method for just that purpose: ILGenerator.EmitWriteLine() generates the exact same code as our example. (Could this be the first assembler ever devised that includes explicit support for creating Hello, World” sample programs?)”


When creating a dynamic assembly with Reflection.Emit, you must declare, ahead of time, what you plan on doing with it. Do you want to run it or save it? Or both? (Of course, if your answer is neither,’ then you should probably should have stopped reading this article long ago.)”

By the end of the piece, I’ve enjoyed the story and it told me exactly what I wanted and then some, pointing out some pitfalls I would’ve missed, being entertaining along the way. It’s rare that I enjoy an article so much and I’m thinking I should send the author an email, congratulating him/her on his/her tight, fun prose.

And then I get to the author bios:

Chris Sells is a blah blah blah.”

Shawn Van Ness is a blah blah blah.”

Of course, now I remember Shawn writing this piece and me helping him with the polish. At this point, I feel a bit like the Joey Tribbiani of Windows technical writing…