PostSharp.ILAdding Aspects to CodeAdding Aspects Declaratively Using AttributesAdding Aspects to a Single Declaration Using Attributes
Open sandboxFocusImprove this doc

Adding Aspects to a Single Declaration Using Attributes

Aspects in PostSharp are plain custom attributes. You can apply them to any element of code as usual.

In the following example, the Trace aspect is applied to two methods.

public class CustomerService
{
    [Trace]
    public Custom GetCustomer( int customerId )
    {
        // Details skipped.
    }

    [Trace]
    public void MergeCustomers( Customer customer1, Customer customer2 );
    {
        // Details skipped.
    }
}