Assembly.GetCustomAttributes メソッド

定義

このアセンブリのカスタム属性を取得します。

オーバーロード

GetCustomAttributes(Boolean)

このアセンブリのすべてのカスタム属性を取得します。

GetCustomAttributes(Type, Boolean)

型を指定して、このアセンブリのカスタム属性を取得します。

GetCustomAttributes(Boolean)

このアセンブリのすべてのカスタム属性を取得します。

public:
 virtual cli::array <System::Object ^> ^ GetCustomAttributes(bool inherit);
public virtual object[] GetCustomAttributes (bool inherit);
abstract member GetCustomAttributes : bool -> obj[]
override this.GetCustomAttributes : bool -> obj[]
Public Overridable Function GetCustomAttributes (inherit As Boolean) As Object()

パラメーター

inherit
Boolean

Assembly 型のオブジェクトでは、この引数は無視されます。

戻り値

Object[]

このアセンブリのカスタム属性を格納する配列。

実装

注釈

このメソッドは、対応する ICustomAttributeProvider インターフェイス メソッドを実装します。 したがって、パラメーターは inherit 無視される場合でも指定する必要があります。

擬似属性は、属性が存在するときに設定する必要があるコア メタデータのビットを示します。 型のメタデータを拡張し、型と共に保存されるカスタム属性とは異なり、擬似属性は型のメタデータを変更してから破棄されます。 結果として得られる一部のビットには、既存のリフレクション API を使用してアクセスできません。

次の表は、リフレクションで使用できるビットのさまざまな擬似属性とアクセサーをまとめたものです。

Pseudo-Attribute メタデータ ビット リフレクション アクセサー
DllImportAttribute CorPInvokeMap

DLL 名
通常のメソッド/グローバル メソッド属性の PInvokeMap アクセサーはありません。

DLL 名のアクセサーはありません。
GuidAttribute 実際のカスタム属性として格納されます。 実際のカスタム属性としてアクセスされます。
ComImportAttribute CorTypeAttr.tdImport Type.Attributes.Import
SerializableAttribute CorTypeAttr.tdSerializable Type.Attributes.Serializable
NonSerializedAttribute CorFieldAttr.fdNotSerialized FieldInfo.Attributes.NotSerialized
MethodImplAttribute CorMethodImpl MethodInfo.GetMethodImplementationFlags()

ConstructorInfo.GetMethodImplementationFlags()
MarshalAsAttribute さまざまなビット。 アクセサーなし。
PreserveSigAttribute CorMethodImpl.miOLE MethodInfo.GetMethodImplementationFlags().OLE

ConstructorInfo.GetMethodImplementationFlags().OLE
InAttribute CorParamAttr.pdIn ParameterInfo.Attributes.In
OutAttribute CorParamAttr.pdOut ParameterInfo.Attributes.Out
StructLayoutAttribute CorTypeAttr.tdLayoutSequential

CorTypeAttr.tdExplicitLayout

CorTypeAttr.tdAnsiClass

CorTypeAttr.tdUnicodeClass

CorTypeAttr.tdAutoClass

クラスパッキング。
Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

アクセサーなし。
FieldOffsetAttribute フィールドオフセット。 アクセサーなし。
AssemblyLoadAttribute CorAssemblyFlags アクセサーまたは列挙子はありません。

適用対象

GetCustomAttributes(Type, Boolean)

型を指定して、このアセンブリのカスタム属性を取得します。

public:
 virtual cli::array <System::Object ^> ^ GetCustomAttributes(Type ^ attributeType, bool inherit);
public virtual object[] GetCustomAttributes (Type attributeType, bool inherit);
abstract member GetCustomAttributes : Type * bool -> obj[]
override this.GetCustomAttributes : Type * bool -> obj[]
Public Overridable Function GetCustomAttributes (attributeType As Type, inherit As Boolean) As Object()

パラメーター

attributeType
Type

カスタム属性を返す対象の型。

inherit
Boolean

Assembly 型のオブジェクトでは、この引数は無視されます。

戻り値

Object[]

このアセンブリの、attributeType で指定されたカスタム属性を格納している配列。

実装

例外

attributeTypenullです。

attributeType はランタイム型ではありません。

注釈

このメソッドは、対応する ICustomAttributeProvider インターフェイス メソッドを実装します。 したがって、パラメーターは inherit 無視されていても指定する必要があります。

擬似属性は、属性が存在する場合に設定する必要があるコア メタデータのビットを示します。 型のメタデータを拡張し、型と共に保存されるカスタム属性とは異なり、擬似属性は型のメタデータを変更してから破棄されます。 結果の一部のビットには、既存のリフレクション API を使用してアクセスできません。

次の表は、リフレクションで使用できるビットのさまざまな擬似属性とアクセサーをまとめたものです。

Pseudo-Attribute メタデータ ビット リフレクション アクセサー
DllImportAttribute CorPInvokeMap

DLL 名
通常のメソッド/グローバル メソッド属性の PInvokeMap アクセサーはありません。

DLL 名のアクセサーはありません。
GuidAttribute 実際のカスタム属性として格納されます。 実際のカスタム属性としてアクセスされます。
ComImportAttribute CorTypeAttr.tdImport Type.Attributes.Import
SerializableAttribute CorTypeAttr.tdSerializable Type.Attributes.Serializable
NonSerializedAttribute CorFieldAttr.fdNotSerialized FieldInfo.Attributes.NotSerialized
MethodImplAttribute CorMethodImpl MethodInfo.GetMethodImplementationFlags()

ConstructorInfo.GetMethodImplementationFlags()
MarshalAsAttribute さまざまなビット。 アクセサーなし。
PreserveSigAttribute CorMethodImpl.miOLE MethodInfo.GetMethodImplementationFlags().OLE

ConstructorInfo.GetMethodImplementationFlags().OLE
InAttribute CorParamAttr.pdIn ParameterInfo.Attributes.In
OutAttribute CorParamAttr.pdOut ParameterInfo.Attributes.Out
StructLayoutAttribute CorTypeAttr.tdLayoutSequential

CorTypeAttr.tdExplicitLayout

CorTypeAttr.tdAnsiClass

CorTypeAttr.tdUnicodeClass

CorTypeAttr.tdAutoClass

クラスのパッキング。
Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

アクセサーなし。
FieldOffsetAttribute フィールドオフセット。 アクセサーなし。
AssemblyLoadAttribute CorAssemblyFlags アクセサーまたは列挙子はありません。

適用対象