PostSharp - Post Compiler for .NET - Policy Injection and AOP Applications
by David Hayden ( Microsoft MVP C# ), Filed: .NET Tools
Ever since Enterprise Library came out with a Policy Injection Application Block I have been intrigued with Policy Injection and Aspect-Oriented Programming ( AOP ) Features. I love the idea of removing all the cross-cutting concerns ( logging, caching, validation, etc. ) from my code to make it much more readable and understandable. The cross-cutting concerns can then be added as attributes or configuration metadata so I can focus on the business logic while maintaining my code, etc.
One of the issues with the current Policy Injection Application Block is that is uses a relatively heavy Remoting Proxy Interception Strategy engaged during runtime that would not be ideal for performance sensitive applications.
A way to get around this is to look at a tool like PostSharp which will inject the policies, etc. into the IL during compile time and increase performance. One drawback to this, of course, is that to remove the policies you need to recompile as opposed to perhaps just changing a configuration file in the case of the Policy Injection Application Block. Obviously this wouldn't be an issue if you don't need that level of control.
Anyway, I definitely want to play with PostSharp and there is a proof-of-concept project specific to Enteprise Library, called PostSharp4EntLib, which apparently gets you away from the need to use Remoting Proxies.
As an FYI, The example I just uploaded on PnPGuidance showing the Web Client Software Factory and Enterprise Library 3.1 has use of the Policy Injection Application Block for validation and caching. You may want to look at the sample if Policy Injection is new to you and you have interest:
Web Client Software Factory Sample - Validation, Data Access, Policy Injection, Model-View-Presenter
Cool stuff.
Source: David Hayden ( Microsoft MVP C# )
Filed: .NET Tools