How It Works

A 100%-compatible extension to C# and VB

Four steps to pattern-centric code


Install PostSharp Tools for Visual Studio

When you click on the Install link, you are actually just installing our user interface: PostSharp Tools for Visual Studio. The real work begins when you add PostSharp to a project.


Add custom attributes to your code

Whether you prefer to use the UI or your keyboard, you end up adding custom attributes to your code. The presence of these custom attributes in your tell the compiler what to do. And PostSharp does it for you.


Add PostSharp to your project

PostSharp is deployed as a NuGet package. During installation, PostSharp edits your project file and inserts itself in the build process. Therefore, there is no friction with build servers.


Build your project

PostSharp post-processes the output of the C# or VB compiler. It opens the intermediate assembly, adds the behaviors required by the aspects, then produces a new assembly.

Which patterns can you automate?

Building automation for your own patterns

Automate pattern implementation

Some patterns are so repetitive that their implementation can be fully automated. With PostSharp Aspect Framework, patterns can be encapsulated into special kinds of custom attributes named aspects.

Unlike standard custom attributes, aspects describe how PostSharp should transform the code to which they are applied. For instance, you can ask to add a try/catch block and to handle exceptions.

read more

Automate pattern validation

Other patterns require manual code, but you still want some rules and conventions to be respected. For instance, you can require that all Singletons are implemented the same way.

With PostSharp Architecture Framework, you can implement validation logic into special kinds of custom attributes called constraints. Constraints include code that is executed at build time and can emit errors and warnings.

read more