CCI vs. Mono.Cecil -- advantages and disadvantages
Asked Answered
P

2

20

I have seen articles discussing these two similar frameworks, but most of them are two years old or so. I assume both projects are much more mature now than they were two years ago, and the situation is a more complex one.

So given the current states of each of the libraries, I was hoping someone could provide a detailed explanation of the advantages and disadvantages of each, and which should be preferred at present time.

Pitfall answered 18/7, 2011 at 0:36 Comment(4)
Not sure why there are 2 close requests. The question is perfectly valid.Halie
Why the votes for "not constructive"? The question does ask for facts and current status of the project, not "which one you like better". Please don't be deletionists of SO ;)Facing
I also am curious as to this question. A nice detailed answer comparing the two would be much appreciated, so I'm going to set a bounty here. :-)Mumbletypeg
Thanks for setting the bounty. We got a very nice answer herePitfall
L
12

CCI

Pros:

  • Can give you finer-grained control on your performance
  • The latest version is a bit more mature

Cons:

  • The object model is more complicated (and confusing if you're new to IL/low-level reflections, like I am)

Cecil (referring to the newer git-hub version)

Pros:

  • Has a simpler object model so will be easier to get started on

Cons:

  • The latest version is less mature, so has fewer code samples available
  • The API is a work-in-progress
  • You won't have as much control over name-caching (for perf)

Which I'd choose

Couting up the pros/cons, it sure looks like I'd pick CCI over Cecil. But I wouldn't.

Cecil is up-and-coming, has an easy API design, has an active authorship (well, did 7.5 months ago, and still seems to now), and was painless to debug through on any issue I encountered.

CCI was quite painful to code against - the interface-based design is taken too far. The code is hard to debug through. Some things seem complete at first glance, but aren't, or don't handle more than a single use case. The NameTable stuff made my head spin (more than it already was).

Lactiferous answered 17/9, 2011 at 15:22 Comment(11)
I can't quite remember, but I also think CCI has better support for high-level code generation. Also, support was good/fast for Cecil :)Lactiferous
Can you provide any direct evidence for some of this comments? Also, I'm curious about performance. My suspicion is that Cecil has had much more work gone into it really. It seems to be more used in open-source projects too. Any thoughts?Mumbletypeg
@Noldorin: This is my anecdotal experience from trying both out 7 and a half months ago. I got a semi-working solution in CCI, and ditched it for Cecil. Yes, there's probably a lot more work put into it Cecil since then. I remember my worst problems were with: detecting all dependent types, determining base types, and doing code generation. My project was to reflect over a type graph and code-gen cleaned-up versions of the types, using lists rather than arrays, nullable types, etc. CCI provided automatic (but incomplete?) visitor-pattern traversal. I don't think Cecil did.Lactiferous
@Noldorin: Also I think CCI had high-level codegen support (?), and Cecil didn't. So I used T4 templates for generating the code once I had the basic types/properties created. Sorry if any of this ends up being misinformation, I just haven't touched it since I finished that project. It took some hero-coding to finish... :)Lactiferous
@Noldorin: As for performance, CCI has this NameTable concept that should reduce some of the duplication of reflection overhead. It was a pain to work with, tho.Lactiferous
Thanks for the information. I'm tempted to choose Cecil now that you mention these things. CCI looks active still, but won't it effectively be replaced by the MS Roslyn project when it comes out (the library for compiler-as-a-service)?Mumbletypeg
@Noldorin: Don't know much of anything about the Roslyn project, so I can't really comment. You could ask that on their mailing list I suppose :)Lactiferous
No problem. Thanks for the info anyway, I think you deserve the bounty. :-)Mumbletypeg
let us continue this discussion in chatMumbletypeg
Too bad I was away and didn't have the chance to log in when this discussion happened. Anyway that is a very nice answer. From the little experience I got from playing with both, I agree that CCI felt harder to use than Cecil, and getting community support was easier for Cecil. It is true though that CCI gives you more control, and could be considered more powerful.Pitfall
@cloudraven: I don't know how much more control it really gives you. It lets you optimize perf with the string table, but other than that I think they have technical parity with the opcodes they allow you to emit, and where they allow you to emit them. CCI has a high-level wrapper for its code-gen support, but that isn't always useful (e.g. if you're like me and prefer/can use a T4 template to do the actual code gen).Lactiferous
O
1

Cecil - because for me, community support for it is better than the CCI. I have always found answers on mailing lists / sites quicker for cecil.

Overpowering answered 20/7, 2011 at 12:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.