Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Reflection.​CustomAttributeExtensions

Assembly: System.Runtime

Inheritance: object → CustomAttributeExtensions

Contains static methods for retrieving custom attributes.

Methods

public static Attribute
GetCustomAttribute​(Assembly element, Type attributeType)
Retrieves a custom attribute of a specified type that is applied to a specified assembly.
Returns A custom attribute that matches <paramref name="attributeType" /> , or <see langword="null" /> if no such attribute is found.
element The assembly to inspect.
attributeType The type of attribute to search for.
public static Attribute
GetCustomAttribute​(MemberInfo element, Type attributeType)
Retrieves a custom attribute of a specified type that is applied to a specified member.
Returns A custom attribute that matches <paramref name="attributeType" /> , or <see langword="null" /> if no such attribute is found.
element The member to inspect.
attributeType The type of attribute to search for.
public static Attribute
GetCustomAttribute​(MemberInfo element, Type attributeType, bool inherit)
Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.
Returns A custom attribute that matches <paramref name="attributeType" /> , or <see langword="null" /> if no such attribute is found.
element The member to inspect.
attributeType The type of attribute to search for.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
public static Attribute
GetCustomAttribute​(Module element, Type attributeType)
Retrieves a custom attribute of a specified type that is applied to a specified module.
Returns A custom attribute that matches <paramref name="attributeType" /> , or <see langword="null" /> if no such attribute is found.
element The module to inspect.
attributeType The type of attribute to search for.
public static Attribute
GetCustomAttribute​(ParameterInfo element, Type attributeType)
Retrieves a custom attribute of a specified type that is applied to a specified parameter.
Returns A custom attribute that matches <paramref name="attributeType" /> , or <see langword="null" /> if no such attribute is found.
element The parameter to inspect.
attributeType The type of attribute to search for.
public static Attribute
GetCustomAttribute​(ParameterInfo element, Type attributeType, bool inherit)
Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.
Returns A custom attribute matching <paramref name="attributeType" /> , or <see langword="null" /> if no such attribute is found.
element The parameter to inspect.
attributeType The type of attribute to search for.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
GetCustomAttributes​(Assembly element)
Retrieves a collection of custom attributes that are applied to a specified assembly.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> , or an empty collection if no such attributes exist.
element The assembly to inspect.
GetCustomAttributes​(Assembly element, Type attributeType)
Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="attributeType" /> , or an empty collection if no such attributes exist.
element The assembly to inspect.
attributeType The type of attribute to search for.
GetCustomAttributes​(MemberInfo element)
Retrieves a collection of custom attributes that are applied to a specified member.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> , or an empty collection if no such attributes exist.
element The member to inspect.
GetCustomAttributes​(MemberInfo element, bool inherit)
Retrieves a collection of custom attributes that are applied to a specified member, and optionally inspects the ancestors of that member.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> that match the specified criteria, or an empty collection if no such attributes exist.
element The member to inspect.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
GetCustomAttributes​(MemberInfo element, Type attributeType)
Retrieves a collection of custom attributes of a specified type that are applied to a specified member.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="attributeType" /> , or an empty collection if no such attributes exist.
element The member to inspect.
attributeType The type of attribute to search for.
GetCustomAttributes​(MemberInfo element, Type attributeType, bool inherit)
Retrieves a collection of custom attributes of a specified type that are applied to a specified member, and optionally inspects the ancestors of that member.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="attributeType" /> , or an empty collection if no such attributes exist.
element The member to inspect.
attributeType The type of attribute to search for.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
GetCustomAttributes​(Module element)
Retrieves a collection of custom attributes that are applied to a specified module.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> , or an empty collection if no such attributes exist.
element The module to inspect.
GetCustomAttributes​(Module element, Type attributeType)
Retrieves a collection of custom attributes of a specified type that are applied to a specified module.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="attributeType" /> , or an empty collection if no such attributes exist.
element The module to inspect.
attributeType The type of attribute to search for.
GetCustomAttributes​(ParameterInfo element)
Retrieves a collection of custom attributes that are applied to a specified parameter.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> , or an empty collection if no such attributes exist.
element The parameter to inspect.
GetCustomAttributes​(ParameterInfo element, bool inherit)
Retrieves a collection of custom attributes that are applied to a specified parameter, and optionally inspects the ancestors of that parameter.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> , or an empty collection if no such attributes exist.
element The parameter to inspect.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
GetCustomAttributes​(ParameterInfo element, Type attributeType)
Retrieves a collection of custom attributes of a specified type that are applied to a specified parameter.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="attributeType" /> , or an empty collection if no such attributes exist.
element The parameter to inspect.
attributeType The type of attribute to search for.
GetCustomAttributes​(ParameterInfo element, Type attributeType, bool inherit)
Retrieves a collection of custom attributes of a specified type that are applied to a specified parameter, and optionally inspects the ancestors of that parameter.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="attributeType" /> , or an empty collection if no such attributes exist.
element The parameter to inspect.
attributeType The type of attribute to search for.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
GetCustomAttributes​(Assembly element)
Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="T" /> , or an empty collection if no such attributes exist.
element The assembly to inspect.
GetCustomAttributes​(MemberInfo element)
Retrieves a collection of custom attributes of a specified type that are applied to a specified member.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="T" /> , or an empty collection if no such attributes exist.
element The member to inspect.
GetCustomAttributes​(MemberInfo element, bool inherit)
Retrieves a collection of custom attributes of a specified type that are applied to a specified member, and optionally inspects the ancestors of that member.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="T" /> , or an empty collection if no such attributes exist.
element The member to inspect.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
GetCustomAttributes​(Module element)
Retrieves a collection of custom attributes of a specified type that are applied to a specified module.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="T" /> , or an empty collection if no such attributes exist.
element The module to inspect.
GetCustomAttributes​(ParameterInfo element)
Retrieves a collection of custom attributes of a specified type that are applied to a specified parameter.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="T" /> , or an empty collection if no such attributes exist.
element The parameter to inspect.
GetCustomAttributes​(ParameterInfo element, bool inherit)
Retrieves a collection of custom attributes of a specified type that are applied to a specified parameter, and optionally inspects the ancestors of that parameter.
Returns A collection of the custom attributes that are applied to <paramref name="element" /> and that match <paramref name="T" /> , or an empty collection if no such attributes exist.
element The parameter to inspect.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
public static T
GetCustomAttribute​(Assembly element)
Retrieves a custom attribute of a specified type that is applied to a specified assembly.
Returns A custom attribute that matches <paramref name="T" /> , or <see langword="null" /> if no such attribute is found.
element The assembly to inspect.
public static T
GetCustomAttribute​(MemberInfo element)
Retrieves a custom attribute of a specified type that is applied to a specified member.
Returns A custom attribute that matches <paramref name="T" /> , or <see langword="null" /> if no such attribute is found.
element The member to inspect.
public static T
GetCustomAttribute​(MemberInfo element, bool inherit)
Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.
Returns A custom attribute that matches <paramref name="T" /> , or <see langword="null" /> if no such attribute is found.
element The member to inspect.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
public static T
GetCustomAttribute​(Module element)
Retrieves a custom attribute of a specified type that is applied to a specified module.
Returns A custom attribute that matches <paramref name="T" /> , or <see langword="null" /> if no such attribute is found.
element The module to inspect.
public static T
GetCustomAttribute​(ParameterInfo element)
Retrieves a custom attribute of a specified type that is applied to a specified parameter.
Returns A custom attribute that matches <paramref name="T" /> , or <see langword="null" /> if no such attribute is found.
element The parameter to inspect.
public static T
GetCustomAttribute​(ParameterInfo element, bool inherit)
Retrieves a custom attribute of a specified type that is applied to a specified parameter, and optionally inspects the ancestors of that parameter.
Returns A custom attribute that matches <paramref name="T" /> , or <see langword="null" /> if no such attribute is found.
element The parameter to inspect.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
public static bool
IsDefined​(Assembly element, Type attributeType)
Indicates whether custom attributes of a specified type are applied to a specified assembly.
Returns <see langword="true" /> if an attribute of the specified type is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element The assembly to inspect.
attributeType The type of the attribute to search for.
public static bool
IsDefined​(MemberInfo element, Type attributeType)
Indicates whether custom attributes of a specified type are applied to a specified member.
Returns <see langword="true" /> if an attribute of the specified type is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element The member to inspect.
attributeType The type of attribute to search for.
public static bool
IsDefined​(MemberInfo element, Type attributeType, bool inherit)
Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors.
Returns <see langword="true" /> if an attribute of the specified type is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element The member to inspect.
attributeType The type of the attribute to search for.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
public static bool
IsDefined​(Module element, Type attributeType)
Indicates whether custom attributes of a specified type are applied to a specified module.
Returns <see langword="true" /> if an attribute of the specified type is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element The module to inspect.
attributeType The type of attribute to search for.
public static bool
IsDefined​(ParameterInfo element, Type attributeType)
Indicates whether custom attributes of a specified type are applied to a specified parameter.
Returns <see langword="true" /> if an attribute of the specified type is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element The parameter to inspect.
attributeType The type of attribute to search for.
public static bool
IsDefined​(ParameterInfo element, Type attributeType, bool inherit)
Indicates whether custom attributes of a specified type are applied to a specified parameter, and, optionally, applied to its ancestors.
Returns <see langword="true" /> if an attribute of the specified type is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element The parameter to inspect.
attributeType The type of attribute to search for.
inherit <see langword="true" /> to inspect the ancestors of <paramref name="element" /> ; otherwise, <see langword="false" /> .
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.