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
Syntax
[AspectConfigurationAttributeType]
[Serializer]
public abstract class Aspect : MulticastAttribute, IAspect, IAspectBuildSemantics, IValidableAnnotation
Remarks

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.


note

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

note

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

Constructors

Name Description
Aspect()

Properties

Name Description
AspectPriority

Gets or sets the weaving priority of the aspect.

SerializerType

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

UnsupportedTargetAction

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

Methods

Name Description
CompileTimeValidate(Object)

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

CreateAspectConfiguration()

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

GetAspectConfiguration(Object)

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
IValidableAnnotation.CompileTimeValidate(Object)

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