Alternatives

You can search the web for hours and get totally confused looking for alternatives to PostSharp, or you can read this page. At SharpCrafters, we don't think PostSharp is the silver bullet. We put customer satisfaction first and want you to understand the pros and cons of competing technologies.

Containers (Dependency Injection)

Most dependency injection frameworks include some aspect-oriented features. While this support is suitable for simple technical requirements (such as tracing or exception handling) applying to application services, this approach will not scale to complex aspects, user interface objects, or domain objects.

Products: Spring.NET, Castle Windsor, Microsoft Unity.

Functional Programming

Functional programming (through anonymous methods and lambda expressions) may be the answer to specific problems such as automatic retry of failed transactions.

Code Generation

AOP and code generation are two non-competing approaches to metaprogramming. While code generation focuses on producing new source code based on an input artifact of higher level of abstraction (such as a model), aspect-oriented programming excells at weaving (interlacing) source code of two natures - business and technical.

Products: CodeSmith

MSIL Transformation

As PostSharp's popularity grew, we have made multiple attempts to use direct MSIL transformations to add new behaviors to programs. Since PostSharp is itself based on PostSharp SDK, the most advanced assembly transformation platform available, there is nothing you could do with an alternative solution that you could not do with PostSharp.

Products: Mono.Cecil, Microsoft.CCI, CCISharp.

Dynamic Languages

Most dynamic languages offer a meta-programming facility that lets you modify the structure and behavior of a program during its execution. You could use that meta- programming facility to modularize crosscutting concerns.

Comparing AOP-enabling technologies

Where can you apply aspects?

PostSharp
MSIL transformation
Transparent Proxy
Microsoft Unity
JIT-Emitted Proxy
Spring.NET, Castle Windsor
JIT-Emitted Subclass
Spring.NET, Castle Windsor
Methods implementing an interface Yes Yes Yes Yes
Virtual public methods Yes Only with MarshalByRefObject Yes
Non-virtual public methods Yes Only with MarshalByRefObject Yes
Virtual protected methods Yes Yes
All methods (including private, protected, static) Yes
External methods (defined in a different assembly) Yes
Constructors Yes
Fields Yes
Properties Yes
Events Yes

Other features

PostSharp
MSIL transformation
Transparent Proxy
Microsoft Unity
JIT-Emitted Proxy
Spring.NET, Castle Windsor
JIT-Emitted Subclass
Spring.NET, Castle Windsor
Modify aspects after build Yes Yes Yes
No impact on build time Yes Yes Yes
Use plain old constructors instead of factory methods Yes
Support for Silverlight & Compact Framework Yes