Open sandboxFocus

Class CopyCustomAttributesAttribute

Custom attribute that, when applied on an aspect class, requires custom attributes present on the aspect class to be copied to the target of this class. When applied on an introduced member (see IntroduceMemberAttribute), this custom attribute requires custom attributes present on the aspect member to be copied to the introduced member.

Inheritance
CopyCustomAttributesAttribute
Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp.dll
Syntax
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Event)]
public sealed class CopyCustomAttributesAttribute : Advice
Remarks

A typical use is to keep, on a property introduced by an aspect, a custom attribute that another framework requires, such as a dependency injection attribute.

A custom attribute whose type is internal cannot be copied to a declaration of another assembly: PostSharp emits a build error. Make the attribute type public, or exclude it from Types.

Constructors

Name Description
CopyCustomAttributesAttribute(Type)

Initializes a new instance of the CopyCustomAttributesAttribute class that requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.

CopyCustomAttributesAttribute(params Type[])

Initializes a new instance of the CopyCustomAttributesAttribute class that requires custom attributes present on the aspect class or aspect class member to be copied to the aspect target or to the introduced member, respectively.

Properties

Name Description
OverrideAction

Gets or sets the action to take when a custom attribute of the same type is already present on the target declaration.

Types

Gets the list of custom attribute types to be copied.

See Also