Cecil Can Be Maddening

As much as I like Cecil, it can also be really frustrating to work with. It has very little documentation, so trying to figure out how things work or why things don't work can be irritating. I'm currently running into an issue where I'm trying to get all of the properties from a TypeDefinition, but the Properties collection has no values. All of the properties are on the base class, and for some reason Cecil doesn't "flatten" things out, so it doesn't consider those properties to be part of the subclass. I don't know why it's acting this way, but it's definitely not what I expected.

I'm also getting weird duplicate metadata token issues whenever I change method implementations. I have no idea what I'm doing wrong - this almost feels like a bug.

Oh, and if you ever add local variables to a method, make sure you set InitLocals to true.

Cecil is one of the best options out there for assembly modification, but it also has some warts on it as well.

Update: Some of these issues have been solved by friendly people - go here, here, and here for the threads.

* Posted at 11.05.2008 01:11:29 PM (Last Update: 11.07.2008 03:29:05 AM) | 1 comment | Link | RSS *

Comments

# Cecil, from Jeff Brown at 11.07.2008 03:29:03 AM

I gave a fair shot at using Cecil as part of a disk-based reflection protocol for Gallio but it's an uphill battle.

They really need to fix how they handle attribute metadata. References to types and enums are just broken last time I checked. I submitted a patch for this actually... wonder if it's been adopted. ;-)

I wish Cecil would add native support for PDBs too. Turns out to be very difficult since the Microsoft PDB format is undocumented and has only been very partially reverse-engineered.

Add a Comment

(*) = Required field
Name (*):

E-Mail (*):

Web Site:

Title (*):

Comments (*):

Enter the code you see (*)



Quote
"Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing." Dick Brandon
Twitter History
follow me on Twitter
Blog History