Open sandboxFocus

Class ReflectionSearch

Provides static methods that give broader access to assembly metadata than the System.Reflection namespace. These methods are available only at build time.

Inheritance
ReflectionSearch
Namespace: PostSharp.Reflection
Assembly: PostSharp.dll
Syntax
public static class ReflectionSearch
Remarks

Use these methods in build-time code, such as the ValidateCode(object, Assembly) method of an architectural constraint or the CompileTimeValidate method of an aspect, to find the code that uses a declaration, the types derived from a type, or the custom attributes added to a declaration, including those added by multicasting.

note

This feature is available only at build time.

Methods

Name Description
GetCustomAttributesOfType(Type)

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

GetCustomAttributesOfType(Type, ReflectionSearchOptions)

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

GetCustomAttributesOnTarget(object)

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

GetCustomAttributesOnTarget(object, ReflectionSearchOptions)

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

GetCustomAttributesOnTarget<T>(object, ReflectionSearchOptions)

Gets all custom attributes of a given type on a given element of code, including those that have been added indirectly, for instance through MulticastAttribute and specifies additional options.

GetDeclarationsUsedByMethod(MethodBase)

Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor.

GetDeclarationsUsedByMethod(MethodBase, ReflectionSearchOptions)

Gets all declarations (Type, FieldInfo, MethodInfo or ConstructorInfo) used by the body of a given method or constructor and specifies additional options.

GetDerivedTypes(Type)

Gets the set of types derived from a given class or implementing a given interface.

GetDerivedTypes(Type, ReflectionSearchOptions)

Gets the set of types derived from a given class or implementing a given interface, and specifies additional options.

GetMembersOfType(Type)

Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type.

GetMembersOfType(Type, ReflectionSearchOptions)

Gets all members (FieldInfo, PropertyInfo, or ParameterInfo) of the assembly being processed of a given type and specifies additional options.

GetMethodsUsingDeclaration(MemberInfo)

Gets the set of methods and constructors whose body references a given declaration (Type, FieldInfo, MethodInfo or ConstructorInfo).

GetMethodsUsingDeclaration(MemberInfo, ReflectionSearchOptions)

Gets the set of methods and constructors whose body references a given declaration (Type, FieldInfo, MethodInfo or ConstructorInfo).

HasCustomAttribute(object, Type, bool)

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

See Also