PostSharpIntroductionHow to Learn Post­SharpArchitecture Role: Selecting and Creating Aspects
Open sandboxFocusImprove this doc

Architecture Role: Selecting and Creating Aspects

The first step in the process of adopting PostSharp is typically to understand what the product can do for you and why you should use (or not use) its features. This activity is typically part of the architecture role.

As you will see, PostSharp offers a set of pre-built aspects implementing some of the most common patterns. As an architect, you will need to understand what these aspects can do for you and how they could fit and simplify your architecture.

However, standard patterns are only the top of the iceberg. To cover your specific needs, PostSharp includes construction kits that allow you to build your own pattern automation, namely the PostSharp Aspect Framework and the PostSharp Architecture Framework. Determining the need for custom aspects or architecture validation rules is typically also a part of the architecture role.

In a typical team, only a few people must be able to create custom aspects or architecture rules. These people must have a deeper understanding of PostSharp than the developers who will only use existing aspects and rules. This is why this skill set is included in the current section.


When writing this section, we realized that the current documentation has some serious weaknesses regarding conceptual and architectural materials. This is why we are also referring to other resources hosted on our web site.


Understanding the principles behind PostSharp will give you a foundation to build on. All patterns and techniques used by PostSharp relate back to this foundation.

Topic Articles
About PostSharp Why Use PostSharp
How Does PostSharp Work
Requirements and Compatibility
More About Design Pattern Automation Article: Design Pattern Automation
More About Aspect-Oriented Programming Aspect-Oriented Programming in Microsoft .NET
White Paper: Producing High-Quality Software with Aspect-Oriented Programming

Selecting pre-built pattern implementations

PostSharp offers a number of different pre-built patterns. The following documentation will outline how to use each of the available patterns.

Topic Articles
General patterns Contracts
Parent/Child, Visitor and Disposable
User interface patterns Understanding the NotifyPropertyChanged Aspect
Understanding the Recordable Aspect
Multithreading White Paper: Threading Models for Object-Oriented Programming
Dispatching a Method to the UI Thread
Dispatching a Method to Background
Diagnostics Logging

Creating automation for custom patterns

PostSharp's built-in patterns won't cover all scenarios in your codebase that can benefit from AOP. Learn how to build custom patterns using the same foundational components as are used for the built-in patterns.

Topic Articles
Aspects Developing Custom Aspects
Architecture Validation Validating Architecture