Understanding AOP in .NET
Articles and Posts
I think it'd be good if we just start out with some basic MSDN articles and such regarding AOP and interception. Some of them may be older but the concepts will still apply to this day:
- 7 Approaches for AOP in .NET
Ayende covers a few ways of doing AOP in .NET using existing frameworks
- Decouple Components by Injecting Custom Services into Your Object's Interception Chain
Juval Lowy, in the March 2003 MSDN magazine, writes about using contexts for an object's execution scope and intercepting calls to and from that object.
- Aspect Oriented Programming (September 2005 Technical article)
Matthew Deiters describes aspect oriented programming and covers joinpoints, pointcuts, advice and mixins with regards to a simple example using VB.NET.
- AOP: Apsect Oriented Programming Enables Better Code Encapsulation and Reuse
Dharma Shukla, Simon Fell and Chris Sells write in the March 2002 MSDN Magazine with regards to the history to COM and AOP and then relate how it works in .NET. Rather dated article but the foundations still apply.
- AOP using System.Reflection.Emit
Roberto Loreto writes on CodeProject how to intercept method calls of an external type and generating method proxies by using Intermediate Language (IL) injection.
Just Read the Code
There are many AOP frameworks out there in the wild right now for .NET. To understand them pretty well, it's best if you just crack open the code and follow the unit tests. Most of these are no longer active. Let's cover some of the AOP frameworks out there:
- PostSharp
- NKalore (No longer active)
- Gripper LOOM.NET
- Rapier LOOM.NET
- AOP.NET (No longer active)
- Aspect# (No longer active)
- AspectDNG
Conclusion
For those willing and able to go ahead and learn about AOP, it's actually quite interesting. it's also quite a challenge especially when dealing with IL emitting. Go ahead and look at the source code and samples and give some of it a try. Next time we pick up, I'll be talking about AOP in the Enterprise and Spring.NET. Until next time...