PostSharp 6.10 / / Post­Sharp Documentation / API Reference / Post­Sharp.​Reflection Namespace / Reflection­Search Class / Reflection­Search Methods / Reflection­Search.​Has­Custom­Attribute Method

ReflectionSearch.HasCustomAttribute Method

Determines whether a declaration has a custom attribute of a given type, including those who have been added indirectly, for instance through MulticastAttribute.

Namespace:  PostSharp.Reflection
Assembly:  PostSharp (in PostSharp.dll) Version: (
public static bool HasCustomAttribute(
	Object target,
	Type type,
	bool inherit = false


Type: System.Object
Element of code (Type, MethodInfo, ...) whose custom attributes are requested.
Type: System.Type
The type of custom attributes.
inherit (Optional)
Type: System.Boolean
true to consider custom attributes derived from type, false to consider only custom attributes strictly of type type.

Return Value

Type: Boolean
True if type has a custom attribute of type type, otherwise false.
See Also