PostSharp 2023.0 / / Post­Sharp Documentation / API Reference / Post­Sharp.​Reflection Namespace / Reflection­Search Class / Reflection­Search Methods / Reflection­Search.​Get­Custom­Attributes­On­Target Method / Reflection­Search.​Get­Custom­Attributes­On­Target Method (Object)

ReflectionSearch.GetCustomAttributesOnTarget Method (Object)

Gets all custom attributes on a given element of code, including those who have been added indirectly, for instance through MulticastAttribute.

Namespace:  PostSharp.Reflection
Assembly:  PostSharp (in PostSharp.dll) Version: 2023.0.3.0 (2023.0.3.0)
public static CustomAttributeInstance[] GetCustomAttributesOnTarget(
	Object target


Type: System.Object
Element of code (Type, MethodInfo, ...) whose custom attributes are requested.

Return Value

Type: CustomAttributeInstance[]
The set of all custom attributes added, directly or indirectly, to target.

Note 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 Note
This feature is available only at build time.
See Also