Nerdy tidbits from my life as a software engineer

Tuesday, March 31, 2009

Very Annoying

I need to write some code that iterates through an array of IL byte code.  To do this, I need to be able to recognize a particular instruction and advance a pointer in an array.  It’s not that hard, except for one thing: there is no built-in array of OpCodes in the System.Reflection.Emit library.  This means in my code, I need to create a static array by hand just so I can iterate through it in a nice, clean, abstract way.  There are at least 100 OpCodes I’ll need to add to my list in order to do this.  So the question is, why doesn’t the OpCodes class define this array for me?  Wouldn’t that seem like a logical field to be in there?

I really hate tedious work.