Open sandboxFocus

Class Aspect

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

Namespace: PostSharp.Aspects
Assembly: PostSharp.dll
Syntax
[AspectConfigurationAttributeType(typeof(AspectConfigurationAttribute))]
[Serializer(null)]
public abstract class Aspect : MulticastAttribute, IAspect, IAspectBuildSemantics, IValidableAnnotation
Remarks

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


note

This class does not provide any advice. You may derive your aspect class from a Developing Simple Aspects, or build a Developing Member-Level Aspects or a Developing Type- and Assembly-Level Aspects with advice methods.

Developing Member-Level Aspects Developing Type- and Assembly-Level 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 another aspect serializer (such as MsilAspectSerializer) 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 Type of the serializer. The serializer is a type derived from AspectSerializer. It is used to serialize the aspect instance at build time and to deserialize it at runtime.

UnsupportedTargetAction

Gets or sets 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 time 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.