PostSharp
[Framework]

The #1 aspect-oriented framework for .NET.

download
Free 45–days trial
  • Works with any code – not just to component interfaces.
  • Best run-time performance.
  • Full support for async code.
  • Validate coding guidelines with architecture validation.
  • Includes a Metalama license
PostSharp Framework

When code no longer fits
a single person's brain

Teach Compiler to Do More

Deliver more than guidelines – Design patterns are usually described using implementation guidelines, and sometimes these guidelines are fully algorithmic with no decision left to the developer. That’s exactly what machines are good at, so why not offload that work to the compiler?

Achieve economies of scale – With PostSharp, you write an aspect once, saving time and reducing source code each and every time it is applied to your codebase.

Improve the Architecture

Encapsulate patterns – Objects are a great encapsulation tool but they struggle at addressing functionalities that repeat throughout the application. Aspects are the right way to encapsulate .NET design patterns that need to be applied over and over again.

Reduce complexity – Move complexity to aspects and write business logic at a higher level of abstraction.

Write cleaner code – Fewer lines of code means a smaller surface for defects to occur. Code that is easier to read and understand is easier to modify and produces fewer defects.

Multiply Knowledge

Encapsulate experience – Experienced developers will use their unique knowledge to build aspects that are specific to your codebase. Deployed to the rest of the team, these aspects will allow anyone to consistently add complex functionality with ease.

Apply easily – Once created aspects are very easy to apply and use. Developers who will only use the aspects don’t require additional PostSharp training.

The most flexible .NET aspect framework

  • Rich building blocks – Aspects are not limited to working only with methods. Perform actions against event registrations, properties and other constructs.
  • Expressive combinations – Assemble the building blocks at compile time using the full power of C# and reflection.
  • Non-invasive – Add functionality where you want in your codebase without having to change any code.
  • Solid foundation – Custom aspects are built using the same infrastructure and code that the PostSharp built-in design patterns are.
PostSharp Framework

Exceptional performance

Exceptional Performance
  • Compile-time execution – Unlike other frameworks, PostSharp does most of the work at compile time, so application startup time remains great.
  • No reflection at run time – Strong typing and compile time execution eliminate the need for you to write reflection code for run-time execution.

Enforce good coding practices

Enforce Design Decisions

Reduce inconsistency – Validate developer-written code against established patterns and guidelines. Prevent developer distraction or inventiveness from creating defects or unwanted complexity.

Control object visibility – Sometimes internal and private keywords are not enough. Restrict which namespace, assembly or type can reference a member or implement an interface.

Save time during code reviews – Any rule that is automatically enforced does not need to be reviewed manually.

Get Faster Feedback

Compile-time errors –Don’t wait to get feedback from a code review. Fail at compilation time when code deviates from an established pattern or guideline.

Build server integration – Architecture rules are executed on the build server too, just as any part of PostSharp.

Errors or warnings – You can choose violations to result in warnings or errors – or warnings in Visual Studio and errors on the build server.

Validate your design at each build against standard and custom rules.

Validate Your Design

Don’t let the intention of your architecture fade in a forgotten document. Express design decisions in executable code and ensure that these patterns are followed with compile-time feedback.

  • Code level declaration

  • Compile time feedback

  • Customizable rules

Build your own code validation rules

  • Familiar API – Create validation for your specific design rules using the .NET reflection API that you already know.

  • Advanced Reflection – For more complicated scenarios, PostSharp offers an extended reflection API that includes the ability to Find All References, Find Derived Types, Visit Expression Trees and more

  • Visual Studio Integration – Errors and warnings emitted by custom rules will be displayed in the Visual Studio Error List, and you can navigate to the problem location by clicking on them.

Build Validation Rules