PostSharpAPI ReferencePost­Sharp.​AspectsInstance­Level­Aspect
Open sandboxFocus

InstanceLevelAspect Class

Base class for aspects applied on types, but having the same lifetime as instances of the type to which they are applied.

Namespace: PostSharp.Aspects
Assembly: PostSharp.dll
public abstract class InstanceLevelAspect : TypeLevelAspect, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IAspect

This class is provided for convenience. You get the same functionality by deriving your aspect class directly from TypeLevelAspect and implementing the interface IInstanceScopedAspect

See IInstanceScopedAspect for a discussion of instance-scoped 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 the object to which the current aspect has been applied.


Name Description

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


Creates a new instance of the aspect based on the current instance, serving as a prototype.


Method called after the an object enhanced by the current aspect has been cloned using MemberwiseClone(). The this parameter refers to the new aspect instance in the cloned object.


Initializes the aspect instance. This method is invoked when all system elements of the aspect (like member imports) have completed.

See Also