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.​Attribute
Assembly: System.Runtime
Inheritance: object → Attribute
Represents the base class for custom attributes.
Properties
public
object
TypeId
When implemented in a derived class, gets a unique identifier for this <see cref="T:System.Attribute" /> .
Methods
public
bool
Equals​(object obj)
Returns a value that indicates whether this instance is equal to a specified object.
Returns <see langword="true" /> if <paramref name="obj" /> and this instance are of the same type and have identical field values; otherwise, <see langword="false" /> .
obj
An <see cref="T:System.Object" /> to compare with this instance or <see langword="null" /> .
public static
Attribute
GetCustomAttribute​(Assembly element,
Type attributeType)
Retrieves a custom attribute applied to a specified assembly. Parameters specify the assembly and the type of the custom attribute to search for.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute
GetCustomAttribute​(Assembly element,
Type attributeType,
bool inherit)
Retrieves a custom attribute applied to an assembly. Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
Attribute
GetCustomAttribute​(MemberInfo element,
Type attributeType)
Retrieves a custom attribute applied to a member of a type. Parameters specify the member, and the type of the custom attribute to search for.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, or property member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute
GetCustomAttribute​(MemberInfo element,
Type attributeType,
bool inherit)
Retrieves a custom attribute applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, or property member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public static
Attribute
GetCustomAttribute​(Module element,
Type attributeType)
Retrieves a custom attribute applied to a module. Parameters specify the module, and the type of the custom attribute to search for.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute
GetCustomAttribute​(Module element,
Type attributeType,
bool inherit)
Retrieves a custom attribute applied to a module. Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
Attribute
GetCustomAttribute​(ParameterInfo element,
Type attributeType)
Retrieves a custom attribute applied to a method parameter. Parameters specify the method parameter, and the type of the custom attribute to search for.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute
GetCustomAttribute​(ParameterInfo element,
Type attributeType,
bool inherit)
Retrieves a custom attribute applied to a method parameter. Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.
Returns A reference to the single custom attribute of type <paramref name="attributeType" /> that is applied to <paramref name="element" /> , or <see langword="null" /> if there is no such attribute.
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public static
Attribute[]
GetCustomAttributes​(Assembly element)
Retrieves an array of the custom attributes applied to an assembly. A parameter specifies the assembly.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
public static
Attribute[]
GetCustomAttributes​(Assembly element,
bool inherit)
Retrieves an array of the custom attributes applied to an assembly. Parameters specify the assembly, and an ignored search option.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
Attribute[]
GetCustomAttributes​(Assembly element,
Type attributeType)
Retrieves an array of the custom attributes applied to an assembly. Parameters specify the assembly, and the type of the custom attribute to search for.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="attributeType" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute[]
GetCustomAttributes​(Assembly element,
Type attributeType,
bool inherit)
Retrieves an array of the custom attributes applied to an assembly. Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="attributeType" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
Attribute[]
GetCustomAttributes​(MemberInfo element)
Retrieves an array of the custom attributes applied to a member of a type. A parameter specifies the member.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, or property member of a class.
public static
Attribute[]
GetCustomAttributes​(MemberInfo element,
bool inherit)
Retrieves an array of the custom attributes applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, or property member of a class.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public static
Attribute[]
GetCustomAttributes​(MemberInfo element,
Type attributeType)
Retrieves an array of the custom attributes applied to a member of a type. Parameters specify the member, and the type of the custom attribute to search for.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="type" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, or property member of a class.
public static
Attribute[]
GetCustomAttributes​(MemberInfo element,
Type attributeType,
bool inherit)
Retrieves an array of the custom attributes applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="type" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, or property member of a class.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public static
Attribute[]
GetCustomAttributes​(Module element)
Retrieves an array of the custom attributes applied to a module. A parameter specifies the module.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
public static
Attribute[]
GetCustomAttributes​(Module element,
bool inherit)
Retrieves an array of the custom attributes applied to a module. Parameters specify the module, and an ignored search option.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
Attribute[]
GetCustomAttributes​(Module element,
Type attributeType)
Retrieves an array of the custom attributes applied to a module. Parameters specify the module, and the type of the custom attribute to search for.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="attributeType" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute[]
GetCustomAttributes​(Module element,
Type attributeType,
bool inherit)
Retrieves an array of the custom attributes applied to a module. Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="attributeType" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
Attribute[]
GetCustomAttributes​(ParameterInfo element)
Retrieves an array of the custom attributes applied to a method parameter. A parameter specifies the method parameter.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
public static
Attribute[]
GetCustomAttributes​(ParameterInfo element,
bool inherit)
Retrieves an array of the custom attributes applied to a method parameter. Parameters specify the method parameter, and whether to search ancestors of the method parameter.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public static
Attribute[]
GetCustomAttributes​(ParameterInfo element,
Type attributeType)
Retrieves an array of the custom attributes applied to a method parameter. Parameters specify the method parameter, and the type of the custom attribute to search for.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="attributeType" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
Attribute[]
GetCustomAttributes​(ParameterInfo element,
Type attributeType,
bool inherit)
Retrieves an array of the custom attributes applied to a method parameter. Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.
Returns An <see cref="T:System.Attribute" /> array that contains the custom attributes of type <paramref name="attributeType" /> applied to <paramref name="element" /> , or an empty array if no such custom attributes exist.
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public
int
GetHashCode​()
Returns the hash code for this instance.
Returns A 32-bit signed integer hash code.
public
bool
IsDefaultAttribute​()
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
Returns <see langword="true" /> if this instance is the default attribute for the class; otherwise, <see langword="false" /> .
public static
bool
IsDefined​(Assembly element,
Type attributeType)
Determines whether any custom attributes are applied to an assembly. Parameters specify the assembly, and the type of the custom attribute to search for.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
bool
IsDefined​(Assembly element,
Type attributeType,
bool inherit)
Determines whether any custom attributes are applied to an assembly. Parameters specify the assembly, the type of the custom attribute to search for, and an ignored search option.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.Assembly" /> class that describes a reusable collection of modules.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
bool
IsDefined​(MemberInfo element,
Type attributeType)
Determines whether any custom attributes are applied to a member of a type. Parameters specify the member, and the type of the custom attribute to search for.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, type, or property member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
bool
IsDefined​(MemberInfo element,
Type attributeType,
bool inherit)
Determines whether any custom attributes are applied to a member of a type. Parameters specify the member, the type of the custom attribute to search for, and whether to search ancestors of the member.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.MemberInfo" /> class that describes a constructor, event, field, method, type, or property member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public static
bool
IsDefined​(Module element,
Type attributeType)
Determines whether any custom attributes of a specified type are applied to a module. Parameters specify the module, and the type of the custom attribute to search for.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
bool
IsDefined​(Module element,
Type attributeType,
bool inherit)
Determines whether any custom attributes are applied to a module. Parameters specify the module, the type of the custom attribute to search for, and an ignored search option.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.Module" /> class that describes a portable executable file.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
This parameter is ignored, and does not affect the operation of this method.
public static
bool
IsDefined​(ParameterInfo element,
Type attributeType)
Determines whether any custom attributes are applied to a method parameter. Parameters specify the method parameter, and the type of the custom attribute to search for.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
public static
bool
IsDefined​(ParameterInfo element,
Type attributeType,
bool inherit)
Determines whether any custom attributes are applied to a method parameter. Parameters specify the method parameter, the type of the custom attribute to search for, and whether to search ancestors of the method parameter.
Returns <see langword="true" /> if a custom attribute of type <paramref name="attributeType" /> is applied to <paramref name="element" /> ; otherwise, <see langword="false" /> .
element
An object derived from the <see cref="T:System.Reflection.ParameterInfo" /> class that describes a parameter of a member of a class.
attributeType
The type, or a base type, of the custom attribute to search for.
inherit
If <see langword="true" /> , specifies to also search the ancestors of <paramref name="element" /> for custom attributes.
public
bool
Match​(object obj)
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
Returns <see langword="true" /> if this instance equals <paramref name="obj" /> ; otherwise, <see langword="false" /> .
obj
An <see cref="T:System.Object" /> to compare with this instance of <see cref="T:System.Attribute" /> .
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
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.