Project Description

PostCrap is a flyweight attribute based aspect injection .NET post compiler

It is written in C# and uses Mono.Cecil to modify assemblies and inject method intercepting stubs

It is not to be confused with the mature and well known post compiler PostSharp

PostCrap was conceived in under 3 nights (at home) as a test of what was acceptable NIH at the workplace :-)

Why would you use this?
  • You are smart enough to know about AOP but no so much about the standard interception facilities provided by dependency injection containers such as Castle Windsor Ninject etc
  • You know all about these containers but are working with an existing app that doesn't use DI
  • You are a object oriented encapsulation freak and just won't allow the containers to dynamic proxy your components
  • You just want to write the darn thing yourself - in that case this can serve as a simple reference implementation
  • This should get you started using Mono.Cecil - I learnt a lot on how it supports generics when working on this


This project would not have been possible without Mono.Cecil or NUnit - thanks!

The interception approach is quite similar to what you'd see say in Castle Dynamic Proxy


Interception for generic methods is not currently supported (should be quite simple to add though)

Last edited Mar 2, 2010 at 3:38 AM by ajaishankar, version 6