This is the online documentation for PostSharp 5.0.
Download PDF or CHM. Go to v4.3 or v5.0

Adding Aspects to Code

An aspect has no effect until it is applied to some element of code. PostSharp provides multiple ways to add aspects to your code.

In this chapter



Adding Aspects Declaratively Using Attributes

This section shows how to add aspects to code using custom attributes and explains how you can target several declarations with a single line of code

Adding Aspects Using XML

This section shows how to add aspects without modifying your source code, by using an external configuration file.

Adding Aspects Programmatically using IAspectProvider

This section describes how to add aspects programmatically (by writing code that is executed at build-time) and overcome limitations of declarative approaches.