PostSharpAPI ReferencePost­Sharp.​AspectsAspect
Open sandboxFocus

Aspect Class

Base class for all aspects that are declared using multicast custom attributes (MulticastAttribute).

Namespace: PostSharp.Aspects
Assembly: PostSharp.dll
public abstract class Aspect : MulticastAttribute, IAspect, IAspectBuildSemantics, IValidableAnnotation

This class is not specific to any kind of declaration (method, field, type, ...). Considering deriving your aspect from TypeLevelAspect, MethodLevelAspect, LocationLevelAspect, or EventLevelAspect if it should be applied to a specific kind of declarations.


This class does not provide any advice. You may derive your aspect class from a Developing Simple Aspects , or build a Developing Composite Aspects .

Developing Composite Aspects


All classes implementing IAspect should typically be marked as serializable using the SerializableAttribute or PSerializableAttribute custom attribute . Fields that are only used at runtime (and unknown at compile-time) should be carefully marked with the NonSerializedAttribute or PNonSerializedAttribute custom attribute. When PostSharp is used on a platform that does not support aspect serialization (such as .NET Compact Framework, Silverlight, or Windows Phone), or when another aspect serializer is used, it is not necessary to mark the aspect class as serializable. For more information, see Understanding Aspect Serialization .

Understanding Aspect Serialization


Name Description


Name Description

Gets or sets the weaving priority of the aspect.


Gets or sets the Type of the serializer (a type derived from AspectSerializer) used to serialize the aspect instance at build time and deserialize it at runtime.


Specifies the action to take when the aspect is applied to an unsupported target element. This property affects only simple aspects, not composite aspects.


Name Description

Method invoked at build time to ensure that the aspect has been applied to the right target.


Method invoked at build time to create a concrete AspectConfiguration instance specifically for the current Aspect type.


Method invoked at build tome to get the imperative configuration of the current Aspect.

SetAspectConfiguration(AspectConfiguration, Object)

Method invoked at build time to set up an AspectConfiguration object according to the current Aspect instance and a specified target element of the current aspect.

Explicit Interface Implementations

Name Description

Method invoked at build time to ensure that the aspect has been applied to the right target.