Monday, November 12, 2007

Enough with Mono.Cecil.

After hitting several NullReferenceExceptions with Mono.Cecil's source code, enough is enough. I can't seem to make heads or tails of how to fix this problem, and frankly, I think it's pretty damn sloppy not to check for a simple null reference. Here's a chunk of the offending code:

Photo Sharing and Video Hosting at Photobucket

It would be OK if this happened only once; the problem is that I can see several sections of code where they make the same mistake over and over again. The number one thing that I hate is when other people write sloppy code and it leaves me no choice but to wait for them to fix it because the code is too complicated to fix on my own. Mono.Cecil has zero unit tests, so there's hardly any way to actually determine which part of the entire library actually works. And frankly, it really doesn't matter to me whether or not they're still in 'beta', or 'alpha', or whatever version--it still doesn't excuse the fact that no matter what version your program should be, these people should have the common sense (as well as the decency) to do some basic error checking!

That's it. I'm tired of this shit. I'm writing my own library.

6 comments:

  1. Hahah, I just had flashbacks when trying to use the SharpDevelop Code Editor, that lead me to writing my own :)

    ReplyDelete
  2. I can't understand how you could fail using cecil. I've written an aspect library that instruments:

    * C'tor
    * Property read / write
    * Field read / write
    etc.. joinpoints
    and other introductory mechanism like mixins etc.

    I have not the same experience as you have...

    ReplyDelete
  3. Just because we didn't have the same experience doesn't mean that it didn't happen.

    For a sophisticated library such as Cecil's, how hard is it to write something like:

    if (arg1 == null)
    throw new ArgumentNullException("arg1");

    This isn't rocket science--it's just checking for a NullReferenceException. Is that too much to ask?

    ReplyDelete
  4. Are you saying that an explicit check that throws an argumentnullexception is better than no check, which throws a nullreferenceexception?

    Considering the source is available, it becomes very similar errors, so I don't think it's that much of a big issue...

    ReplyDelete
  5. Hi Sebastien,

    Actually I was saying that Mono.Cecil doesn't do any semantic checking before emitting a method. Instead, it kept throwing a NullReferenceException, and that really didn't explain the problem.

    ReplyDelete
  6. Jason Bock has done a great intro screencast to Cecil over at DimeCasts.

    You can check it out here http://www.dimecasts.net/Casts/CastDetails/59

    ReplyDelete

Ratings by outbrain