PostSharpAPI ReferencePost­Sharp.​ReflectionReflection­SearchGet­Custom­Attributes­Of­Type
Open sandboxFocus

ReflectionSearch.GetCustomAttributesOfType Method

GetCustomAttributesOfType(Type)

Gets all custom attributes of a given type in the assembly being currently processed.

Declaration
public static CustomAttributeInstance[] GetCustomAttributesOfType(Type customAttributeType)
Parameters
Type Name Description
System.Type customAttributeType

System.Type of the custom attribute.

Returns
Type Description
CustomAttributeInstance[]

The set of all custom attributes of type customAttributeType defined in the assembly being currently processed.

Remarks

note

This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

note

This feature is available only at build time.

GetCustomAttributesOfType(Type, ReflectionSearchOptions)

Gets all custom attributes of a given type in the assembly being currently processed and specifies additional options.

Declaration
public static CustomAttributeInstance[] GetCustomAttributesOfType(Type customAttributeType, ReflectionSearchOptions options)
Parameters
Type Name Description
System.Type customAttributeType

System.Type of the custom attribute.

ReflectionSearchOptions options

Either IncludeDerivedTypes or None.

Returns
Type Description
CustomAttributeInstance[]

The set of all custom attributes of type customAttributeType (or any type derived from customAttributeType, if the option IncludeDerivedTypes is true) defined in the assembly being currently processed.

Remarks

note

This method returns custom attributes from the internal annotation repository of PostSharp. This repository contains more than only custom attributes added in source code. For instance, if you use MulticastAttribute to add a custom attribute to several elements of code in a single line of code, this method will return one custom attribute instance for every target of the MulticastAttribute .

note

This feature is available only at build time.