Search code examples
.netaoppostsharpmono.cecilcci

Mono Cecil vs. PostSharp Core vs. Microsoft CCI for implementing AOP framework


Which is the better in terms of capabilities, easy of use, documentation, samples, community/support, VS integration, known implementations, long-term viability, and build speed to implement a custom AOP framework?

I'll start with what I know (I have only tried PostSharp to so far):

  • Microsoft Common Compiler Instrastruture (CCI): I've read that is used for FxCop, ILMerge, Spec# and Code Contracts. It seems to be very low level as it does not even take care of correcting offsets for branch codes that are borken when IL is modified with it.
  • PostSharp is 5 years old, has many capabilities for AOP (e.g. abstracts some things you would need to have to do manually with IL away), source code available, developed/supported by only one guy but he is planning on making this a business, has documentation but could be better, builds take about twice as long, very little samples on how to inject IL and version 2.0 will be released soon which promises to be much improved.
  • Mono Cecil: Written by one guy, part of the Mono suite and there is a plug-in for Reflector called Reflexil that uses Mono Cecil.

Solution

  • Both Microsoft.CCI and Mono.Cecil are low-level, and don't validate produced assemblies. It takes lots of time to find the reason of problem, if there is any error in generated code or assembly structure.
    I'd recommend using PostSharp if it's features are enough for you tasks.
    Otherwise... Mono.Cecil has better, more understandable and easy in use object model. However, I had an ugly bug when used it in my program (reference to the wrong method was saved in the assembly; I think there was some bug with metadata tokens handling)
    Microsoft.CCI has an ugly, utterly over-designed object model in the same time lacking many simple features; however, it's more mature than Mono.Cecil. Finally, I abandoned Mono.Cecil and used Microsoft.CCI for my program.