in Imported ~ read.

Yet another AOP framework

In past years I was working with different aspect oriented frameworks. A lot with postsharp in its early days when it was open source and then changed its license to a more closed model. I have helped project to use aop to allow easier development and write less but expressive code that is just focused on the work it should do. I often used ready to use frameworks like postsharp or spring-aop to get that work done but those tools are pretty powerful and that might become a problem when the people in the project aren't familiar with aop, then they start seeing nails everywhere and want to hammer them with aop. I also implemented it myself but those were focused on the project and not that genric that I would have published them to public, also the contract wouldn't have allowed me to do so. In the last days I found some spare time to implement the basic stuff. The project should be:

  • lightweight
  • fully runtime based (I might implement a compile time version with rosly later)
  • Interface based

The project is currently in its early stage and has the basic stuff done you can:

  • intercept calls before and after the real implementation is called
  • intercept exceptions
  • handle exception so they don't bubble up the stack
  • manipulate the return value

The architecture is based on a service locator which is used to determine the implementation of a contract (interface). If the contract is tagged with aspects it will create a proxy at runtime which holds the aspects. The service locator returns the proxy object that was created by the ProxyBuilder. The builder uses Reflection.Emit to generate a type at runtime that implements the contract. If the method on the contract does not contain any aspects it will end up in a simple call into the proxied instance. If there is any aspect present it will call the aspect based on the aspect declaration. Aspecs are added to the contract with attributes. Those attributes have a type associated with them that represents the aspec. Aspects have to  implement a certain contract to be usable at runtime. The attribute will ensure that the type implements the interface. This way the designer of the contract defines the aspects the contract implementation needs and the implementer can focus on the contract functionality. Ok enough talked for now! Where is the source? You can find it on Github, it's all Apache 2 licensed, but the source code misses the license headers. Which I will correct asap. I also uploaded it to nuget. As I told it is in a really early stage, it is working in the cases I tested so far. But the API is likely to change. I hope I can make the most changes non breaking, but be aware that it is not a final and stable API. If you have any ideas, feature requests or bug reports feel free to add an issue on Github. If you would like to discuss about the framework itself: post a comment here or contact me via one of the social networks below. There will be a lot more posts about the framework in the near future, with a lot of code and detail how stuff was done. If you want to see some samples I created a small console project that shows the basic sutff.