Windows 元数据(WinMD)文件Windows Metadata (WinMD) files

Windows 运行时(WinRT) Api 在计算机可读的元数据文件(扩展名为 .winmd (也称为 Windows 元数据)中进行了介绍。Windows Runtime (WinRT) APIs are described in machine-readable metadata files with the extension .winmd (also known as Windows Metadata). 这些元数据文件由工具和语言投影用于启用语言投影。These metadata files are used by tools and language projections in order to enable language projection.

一般说明General notes

Windows 包含所有系统提供的 WinRT Api 的元数据。Windows includes metadata for all system-provided WinRT APIs. Windows 提供 Api,以帮助对在运行时需要此元数据的命名空间和类型进行解析。Windows provides APIs to aid language projections in the resolution of namespaces and types that need this metadata at runtime. Windows SDK 提供单个文件中系统元数据的副本,以供在编译时需要此元数据的语言投影使用。The Windows SDK provides a copy of the system metadata in a single file for use by language projections that need this metadata at compile time.

第三方可以开发自己的 WinRT Api,这些 Api 可参与语言投影,如系统提供的 Api 执行的操作。Third-parties may develop their own WinRT APIs that can participate in language projection like the system provided APIs do. 与系统 Api 一样,第三方 WinRT Api 必须提供元数据。Third-party WinRT APIs must provide metadata just like system APIs do. 用于命名空间和类型解析的 Windows Api 适用于第三方元数据,就像它们对系统元数据执行的操作一样。Windows APIs for namespace and type resolution work on third-party metadata like they do for system metadata.

WinMD 文件中的所有公共类型都必须是 WinRT 类型,并且必须具有 tdWindowsRuntime 标志(有关要遵循的类型标志的详细信息)。All public types in a WinMD file must be WinRT types, and must carry the tdWindowsRuntime flag (details on type flags to follow). WinMD 文件可能包含非 WinRT 类型的元数据。WinMD files may include metadata for non-WinRT types. WinMD 文件中的任何非 WinRT 类型都不能是公共的。Any non-WinRT types in a WinMD file must not be public. 非 WinRT 类型的语义是实现定义的,并超出了本文档的范围。Semantics for non-WinRT types are implementation-defined, and outside the scope of this document.

WinRT 类型上的所有公共接口成员(方法、属性和事件)都必须是 WinRT 接口成员。All public interface members (methods, properties, and events) on WinRT types must be WinRT interface members. WinRT 类型可能包含非 WinRT 接口成员的元数据。WinRT types may include metadata for non-WinRT interface members. 任何非 WinRT 接口成员都不能是公共的。Any non-WinRT interface members may not be public. 非 WinRT 接口成员的语义是实现定义的,并超出了本文档的范围。Semantics for non-WinRT interface members are implementation-defined and outside the scope of this document.

WinMD 文件WinMD files

WinMD 文件格式WinMD file format

WinMD 文件使用与公共语言运行时(CLR)程序集相同的物理文件格式,如 ECMA-335 规范所定义。WinMD files use the same physical file format as Common Language Runtime (CLR) assemblies, as defined by the ECMA-335 specification. 但是,虽然物理文件格式相同,但对于 WinMD 文件和 CLR 程序集,数据的有效组合规则是不同的。However, while the physical file format is the same, the rules for valid combinations of data are different for WinMD files and CLR assemblies. 本文档列出了 WinMD 文件与 CLR 程序集之间的增量。This document lists the deltas between WinMD files and CLR assemblies.

系统提供的 WinMD 文件是纯粹的元数据。System-provided WinMD files are pure metadata. 第三方 WinMD 文件可能包含代码。Third-party WinMD files may contain code. 特别是,托管 WinMD 文件包含 Microsoft 中间语言(MSIL)代码,就像传统的 CLR 程序集一样。In particular, managed WinMD files include Microsoft Intermediate Language (MSIL) code, just like traditional CLR assemblies do.

每个 WinMD 文件都包含零个或多个 WinRT 类型的定义。Every WinMD file contains the definitions of zero or more WinRT types. 空 WinMD 文件在技术上是有效的。Empty WinMD files are technically valid.

对于 WinMD 中列出的 PEKind 或计算机体系结构,没有任何特定的 WinRT 限制。There are no specific WinRT restrictions on the PEKind or machine architecture listed in a WinMD.

WinMD 版本字符串必须包含 "Windows 运行时 1.2"。The WinMD version string must contain "Windows Runtime 1.2".

WinMD 文件名WinMD file name

WinMD 文件的名称(不含扩展名)必须与 WinMD 文件中程序集表的名称列不区分大小写。The name (without extension) of a WinMD file must be a case-insensitive match to the name column of the assembly table inside the WinMD file. 例如,"Foo. winmd" 文件必须在程序集表的 "名称" 列中包含 "Foo"。For example, the "Foo.Bar.winmd" file must have "Foo.Bar" in the name column of the assembly table. 因为文件系统不区分大小写,所以文件名的大小写可能与 "程序集表名称" 列的值不同。Because the file system is case-insensitive, the case of the file name may differ from the assembly table name column value.

给定 WinMD 文件中的所有 WinRT 类型必须位于与 WinMD 文件名称匹配的命名空间和程序集表名称列的值之间。All of the WinRT types in a given WinMD file must be under a namespace that matches the name of the WinMD file and the assembly table name column value. 因为文件系统不区分大小写,所以文件名的大小写可能与给定 WinMD 文件中所有 WinRT 类型的命名空间不同。Because the file system is case-insensitive, the case of the file name may differ from the namespace of all the WinRT types in a given WinMD file. 给定 WinMD 中所有 WinRT 类型的命名空间必须与程序集表名称列值完全匹配(即,区分)。The namespace of all the WinRT types in a given WinMD must match the assembly table name column value exactly (that is, case-sensitively). 例如,程序集表的 "名称" 列中包含 "Foo. Bar" 的文件中的所有类型必须位于 "Foo. Bar" 命名空间中。For example, all of the types in the file with "Foo.Bar" in the assembly table's name column must be in the "Foo.Bar" namespace. 类型可以是此命名空间的直接子级(例如,MyType),也可以是此命名空间的子命名空间中的子命名空间(例如,Baz.png. MyType)。The types may be either direct children of this namespace (for example, Foo.Bar.MyType), or in sub-namespaces of this namespace (for example, Foo.Bar.Baz.MyType). 文件的名称必须为 "Foo",但在—为 "foo" 和 "FOO" 时可能会有所不同。栏.还允许将 WINMD 作为此元数据文件的文件名。The name of the file must be "Foo.Bar.winmd", but may vary in case—that is, "foo.bar.winmd" and "FOO.BAR.WINMD" would also be permitted as file names for this metadata file.

WinMD 组合WinMD composition

系统中所有类型的元数据分散在多个 winmd 文件中。The metadata for all the types in the system is spread across multiple .winmd files. AppX 包可以包括零个或多个用于描述应用程序包中包含的第三方 WinRT 组件的 winmd 文件。An AppX package can include zero or more .winmd files describing third-party WinRT components that are included in the application package.

在系统提供的所有 winmd 文件中或在给定应用中包含时,必须将每个 WinRT 类型的元数据存储在 WinMD 文件中,该文件的名称与类型的命名空间匹配。Across all the .winmd files provided by the system, or included with a given app, every WinRT type's metadata must be stored in the WinMD file, with the longest name matching the namespace of the type. 作为给定命名空间的直接子级的所有类型都必须位于同一个文件中。All types that are direct children of a given namespace must be located in the same file. 例如,如果 AppX 包中包括 Foo. winmd 和 Foo. winmd 文件,则 MyType 类型必须位于 Baz.png 文件中,因为这是包中的类型的命名空间匹配文件名的最大名称文件(该文件)。For example, if an AppX package includes Foo.winmd and Foo.Bar.winmd files, then the Foo.Bar.Baz.MyType type must be located in the Foo.Bar.winmd file, since that is the file with the longest namespace-matching filename for the type in the package.

TypeDef 重定向TypeDef redirection

系统提供的元数据文件不会直接引用 Typedef。Metadata files provided by the system never reference TypeDefs directly. 即使在引用相同元数据文件中定义的类型时,系统元数据文件也始终引用 TypeRef,后者又引用 TypeDef。Even when referencing a type that's defined in the same metadata file, system metadata files always reference a TypeRef that in turn references the TypeDef. 这样做是为了支持 CLR 类型重定向(例如,将IVector 投影为IList )。This is done in order to support CLR type redirection (projecting IVector as IList, for example).

第三方元数据文件可能直接使用 TypeDef,或者可以通过 TypeRef 重定向所有类型引用,这一点类似于系统元数据文件的用途。Third-party metadata files may use TypeDef directly, or may redirect all type references through a TypeRef similar to how system metadata files do.

类型系统编码Type system encoding

此文档中来自 mscorlib 程序集的系统命名空间中的所有类型都用作标记。All types in this document from the System namespace from the mscorlib assembly are used as markers by WinRT. 这些类型用于指示有关类型的信息,不应进行解析。These types are used to indicate information about types, and should never be resolved. 这包括(但不限于) System.object、System.multicastdelegate、system.string、system.object、system.string 和 system.string (但不限于)。This includes (but is not limited to) System.Object, System.Guid, System.ValueType, System.Enum, System.MulticastDelegate, and System.Attribute. 请注意,选择这些名称是为了与 CLR 兼容。Note that these names were chosen for compatibility with CLR. CLR 对这些类型的定义是其类型系统的一部分,与 WinRT 无关。CLR's definition of these types is part of their type system, and has nothing to do with WinRT.

请注意,此处所述的许多构造C#使用语法。Note that many of the constructs described here use C# syntax. 这只是因为使用C#语法来表示某些公共语言基础结构(CLI)元数据构造是非常方便的。This is simply because it is convenient to represent certain Common Language Infrastructure (CLI) metadata constructs using C# syntax. 实际的构造是纯 CLI 元数据构造。The actual constructs are pure CLI metadata constructs.

命名空间Namespace

WinRT 将类型的命名空间和本地名称编码为一个句点分隔的字符串。WinRT encodes a type's namespace and local name in a single period-delimited string. 例如,在此代码段中定义的类型为 "ISimpleInterface"。For example, the type defined in this snippet of code is "Windows.Foundation.ISimpleInterface".

namespace Windows {
    namespace Foundation {
        interface ISimpleInterface {
            HRESULT Method1(int paramOne);
        };
    };
};

对于空间优化,CLI 元数据中的 TypeDef 表为类型名称和命名空间名称提供了单独的列。For space optimization, the TypeDef table in CLI metadata provides separate columns for type name and namespace name. 但在 API 级别,TypeDef 属性只公开类型名称。However, at the API level, the TypeDef property exposes only the type name.

基本类型Fundamental types

除 Guid 之外的所有 WinRT 基本类型都具有显式常数值,可在 CLI 元数据 blob 和其他类型引用中使用。All the WinRT fundamental types except Guid have explicit constant values for use in CLI Metadata blobs and other type references. CLI 规范的第2部分23.1.16 介绍了这些常量值。These constant values are described in Partition 2, Section 23.1.16 of the CLI specification.

WinRT 类型WinRT type CLI 元素类型名称CLI element type name CLI 元素类型值CLI element type value
Int16Int16 ELEMENT_TYPE_I2ELEMENT_TYPE_I2 0x060x06
Int32Int32 ELEMENT_TYPE_I4ELEMENT_TYPE_I4 0x080x08
Int64Int64 ELEMENT_TYPE_I8ELEMENT_TYPE_I8 0x0a0x0a
UInt8UInt8 ELEMENT_TYPE_U1ELEMENT_TYPE_U1 0x050x05
UInt16UInt16 ELEMENT_TYPE_U2ELEMENT_TYPE_U2 0x070x07
UInt32UInt32 ELEMENT_TYPE_U4ELEMENT_TYPE_U4 0x090x09
UInt64UInt64 ELEMENT_TYPE_U8ELEMENT_TYPE_U8 0x0b0x0b
SingleSingle ELEMENT_TYPE_R4ELEMENT_TYPE_R4 0x0c0x0c
DoubleDouble ELEMENT_TYPE_R8ELEMENT_TYPE_R8 0x0d0x0d
Char16Char16 ELEMENT_TYPE_CHARELEMENT_TYPE_CHAR 0x030x03
布尔Boolean ELEMENT_TYPE_BOOLELEMENT_TYPE_BOOL 0x020x02
StringString ELEMENT_TYPE_STRINGELEMENT_TYPE_STRING 0x0e0x0e

由于它没有显式 ELEMENT_TYPE_ * 常量值,因此 Guid 在元数据中表示为从 mscorlib 程序集的 Guid.empty 到 Guid.empty 类型。Since it has no explicit ELEMENT_TYPE_* constant value for them, Guids are represented in metadata as TypeRef to the System.Guid type from the mscorlib assembly.

枚举Enums

枚举在 TypeDef 表(ECMA 22.37)中表示为一行,列设置如下。Enums are represented as a row in the TypeDef table (ECMA II.22.37) with the columns set as follows.

  • 随意.Flags. 设置为公共 |密封 |tdWindowsRuntime (0x4101).Set to Public | Sealed | tdWindowsRuntime (0x4101).
  • “名称”。Name. 包含类型名称的字符串堆中的索引。An index into the string heap that contains the name of the type.
  • 命名空间。Namespace. 包含类型的命名空间的字符串堆中的索引。An index into the string heap that contains the namespace of the type.
  • 延续.Extends. 设置为在 mscorlib 程序集中引用 system.exception 类的 TypeRef。Set to a TypeRef that references the System.Enum class in the mscorlib assembly.
  • FieldList.FieldList. 字段表中的索引,用于标记此类型拥有的连续运行字段的第一个。An index into the Field table, marking the first of a contiguous run of fields owned by this type.
  • MethodList.MethodList. 必须为空。Must be empty.

枚举具有一个实例字段,该字段指定枚举的基础整数类型以及零个或多个静态字段;枚举类型定义的每个枚举值对应一个。An enum has a single instance field that specifies the underlying integer type for the enum, as well as zero or more static fields; one for each enum value defined by the enum type.

枚举的基础整数类型将显示为与该类型关联的字段表(ECMA 22.15)中的第一行(即上面指定的 FieldList 列中引用的行)。The underlying integer type of the enum appears as the first row in the Field table (ECMA II.22.15) associated with the type (i.e. the one referenced in the FieldList column specified above). 枚举类型的字段表中的列如下所示。The columns in the Field table for the enum type are as follows.

  • 标志:专用 |SpecialName |RTSpecialName (0x601)。Flags: Private | SpecialName | RTSpecialName (0x601).
  • Name:包含名称 "value__" 的字符串堆中的索引。Name: an index into the string heap that contains the name "value__".
  • 签名:包含 FieldSig blob (ECMA 23.2.4)的 blob 堆中的索引,其中类型设置为 ELEMENT_TYPE_I4 或 ELEMENT_TYPE_U4,因为 WinRT 枚举值必须是有符号或无符号32位整数。Signature: an index into the blob heap containing a FieldSig blob (ECMA II.23.2.4) where the Type is set to either ELEMENT_TYPE_I4 or ELEMENT_TYPE_U4, because WinRT enum values must be signed or unsigned 32 bit integers.

枚举值定义为枚举中的每个值提供字段定义。After the enum value definition comes a field definition for each of the values in the enumeration.

  • 标志:公共 |static |文本 |hasdefault (0x8056)。Flags: public | static | literal | hasdefault (0x8056).
  • Name:包含枚举值的名称的字符串堆中的索引。Name: an index into the string heap that contains the enum value's name.
  • 签名:包含类型设置为枚举类型的 TypeDef 的 FieldSig blob (ECMA 23.3.4)的 blob 堆中的索引。Signature: an index into the blob heap containing a FieldSig blob (ECMA II.23.3.4) with the Type set to the TypeDef of the enum type.

对于每个枚举值定义,常量表(ECMA 22.9)中都有相应的行,用于存储枚举值的整数值。For each Enum value definition, there is a corresponding row in the Constant table (ECMA II.22.9) to store the integer value for the enum value.

  • 类型。Type. 一个字节用于表示枚举的基础类型,ELEMENT_TYPE_I4 或 ELEMENT_TYPE_U4,后跟一个以 ECMA 规范为单位的字节填充零。One byte to represent the underlying type of the enum, either ELEMENT_TYPE_I4 or ELEMENT_TYPE_U4, followed by one byte padding zero as per the ECMA spec.
  • Parent:在字段表中保留关联的枚举值记录的索引。Parent: Index into the field table that holds the associated enum value record.
  • 值:包含枚举值的整数值的 blob 表的索引。Value: index into the blob table that holds the integer value for the enum value.

此外,必须将 FlagsAttribute 添加到具有基础 UInt32 类型的任何枚举的枚举 TypeDef 行。Additionally, the System.FlagsAttribute must be added to the enumeration TypeDef row for any enums with an underlying UInt32 type. 不能将 FlagsAttribute 添加到具有基础 Int32 类型的枚举的枚举 TypeDef 行。The FlagsAttribute must not be added to the enum TypeDef row for enums with an underlying Int32 type.

对于所有系统提供的枚举,必须将 VersionAttribute 添加到枚举 TypeDef 行。For all system provided enums, the VersionAttribute must be added to the enumeration TypeDef row. 或者,可以将 VersionAttribute 添加到任何静态字段行。Optionally, the VersionAttribute may be added to any of the static Field row. 如果存在,则任何枚举字段行上的 VersionAttribute 中的版本值都必须大于或等于枚举 TypeDef 行上 VersionAttribute 的值。If present, the version value from the VersionAttribute on any enum Field rows must be greater than or equal to the value from the VersionAttribute on the enum TypeDef row.

结构Structs

结构在 TypeDef 表(ECMA 22.37)中实现为一行,列设置如下。Structs are implemented as a row in the TypeDef table (ECMA II.22.37) with the columns set as follows.

  • 标志–公共 |密封 |顺序 |tdWindowsRuntime (0x4109).Flags – Public | Sealed | Sequential | tdWindowsRuntime (0x4109).
  • Name –包含类型名称的字符串堆中的索引。Name – an index into the string heap that contains the name of the type.
  • 命名空间–包含类型命名空间的字符串堆中的索引。Namespace – an index into the string heap that contains the namespace of the type.
  • "扩展" –设置为在 mscorlib 程序集中引用 System.object 类的 TypeRef。Extends – set to a TypeRef that references the System.ValueType class in the mscorlib assembly.
  • FieldList-字段表中的索引,用于标记此类型拥有的连续运行字段的第一个。FieldList – An index into the Field table, marking the first of a contiguous run of fields owned by this type.
  • MethodList –必须为空。MethodList – must be empty.

结构具有一个或多个字段表项。Structs have one or more Field table entries.

  • Flags: public。Flags: public.
  • Name:包含字段名称的字符串堆中的索引。Name: an index into the string heap that contains the field's name.
  • 签名:包含类型设置为字段类型的元数据标记的 FieldSig blob (ECMA 23.2.4)的 blob 堆中的索引。Signature: an index into the blob heap containing a FieldSig blob (ECMA II.23.2.4) with the Type set to the metadata token for the field type.
    • 结构字段必须是基本类型、枚举或其他结构。Struct fields must be fundamental types, enums, or other structs.

对于所有系统提供的结构,必须将 VersionAttribute 添加到结构 TypeDef 行。For all system-provided structs, the VersionAttribute must be added to the struct TypeDef row.

委派Delegates

委托在 TypeDef 表(ECMA 22.37)中实现为一行,列设置如下。Delegates are implemented as a row in the TypeDef table (ECMA II.22.37) with the columns set as follows.

  • Flags:设置为 Public |密封 |tdWindowsRuntime (0x4101).Flags: set to Public | Sealed | tdWindowsRuntime (0x4101).
  • Name –包含类型名称的字符串堆中的索引。Name – an index into the string heap that contains the name of the type.
  • 命名空间–包含类型命名空间的字符串堆中的索引。Namespace – an index into the string heap that contains the namespace of the type.
  • 扩展:设置为在 mscorlib 程序集中引用 System.multicastdelegate 类的 TypeRef。Extends: set to a TypeRef that references the System.MulticastDelegate class in the mscorlib assembly.
  • FieldList:必须为空。FieldList: must be empty.
  • MethodList: MethodDef 表(ECMA 22.26)的索引,用于标记此类型所拥有的方法的连续运行的第一个。MethodList: An index into the MethodDef table (ECMA II.22.26), marking the first of a contiguous run of methods owned by this type.

委托的 TypeDef 行必须具有 GuidAttribute。Delegates' TypeDef rows must have a GuidAttribute.

委托正好有两个 MethodDef 表项。Delegates have exactly two MethodDef table entries. 第一种定义构造函数。The first defines a constructor. 此构造函数是兼容性标记,这就是它使用非 WinRT 构造(如 native int)的原因,以及既不 in 也不 out的参数。This constructor is a compatibility marker, which is why it uses non-WinRT constructs such as native int, and parameters that are neither in nor out. WinRT 委托没有此类构造函数方法。WinRT Delegates have no such constructor method.

  • RVA:0(这是抽象构造)。RVA: 0 (this is an abstract construct).
  • ImplFlags:运行时(0x03)。ImplFlags: runtime (0x03).
  • 标志:专用 |hidebysig |specialname |RTSpecialName (0x1881)。Flags: private | hidebysig | specialname | RTSpecialName (0x1881).
  • 名称:字符串表中包含名称 ".ctor" 的索引。Name: an index into the string table containing the name ".ctor".
  • 签名: blob 堆中的一个索引,其中包含一个对象的 MethodDefSig blob (ECMA 23.2.1),该方法具有一个对象,并在参数中为 native int,没有返回值。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) for a method with an object and native int in parameters and no return value.
  • ParamList: Param 表(ECMA 22.33)的索引,其中包含与此方法关联的参数行运行中的第一个索引。ParamList: an index into the Param table (ECMA II.22.33) containing the first in a run of Param rows associated with this method. Param 表中的每一行都包含以下信息。Each row in the Param table contains the following information.
    • 对象参数Object parameter
      • 序列1Sequence 1
      • Name "object"Name "object"
      • Flags: none (0x00)Flags: none (0x00)
    • Native Int 参数Native Int parameter
      • 序列2Sequence 2
      • Name "method"Name "method"
      • Flags: none (0x00)Flags: none (0x00)

第二个 MethodDef 项定义调用方法。The second MethodDef entry defines the Invoke method.

  • RVA:0(这是抽象构造)RVA: 0 (this is an abstract construct)
  • ImplFlags:运行时(0x03)ImplFlags: runtime (0x03)
  • 标志:公共 |Virtual |HideBySig |specialname (0x08C6)Flags: public | Virtual | HideBySig | specialname (0x08C6)
  • 名称:字符串表中包含名称 "Invoke" 的索引Name: an index into the string table containing the name "Invoke"
  • 签名:包含委托的参数类型和返回类型的 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the parameter types and return type of the delegate. 如果委托已参数化,则 MethodDefSig blob 应通过 GENERICINST 编码类型引用每个委托类型参数(按照 ECMA II. 23.2.12)。If the delegate is parameterized, the MethodDefSig blob should reference each of the delegates type parameters via GENERICINST encoded Type (as per ECMA II.23.2.12). 要遵循的参数化委托的详细信息。Details on parameterized delegates to follow.
  • ParamList: Param 表(ECMA 22.33)的索引,其中包含与此方法关联的参数行运行中的第一个索引。ParamList: an index into the Param table (ECMA II.22.33) containing the first in a run of Param rows associated with this method. Param 表中的每一行都将包含以下信息。Each row in the Param table will contain the following information.
    • 标志–输入或输出,适用于参数Flags – in or out as appropriate for the parameter
    • 序列–参数的序列顺序。Sequence – sequence order of the parameter. 为方法的返回值保留零Zero is reserved for the return value of the method
    • 名称–对于包含所有系统提供的委托的参数名称的字符串堆中的索引,必须将 VersionAttribute 添加到该委托的 TypeDef 行。Name – index into the string heap containing the name of the parameter For all system provided delegates, the VersionAttribute must be added to the delegate's TypeDef row.

参数化委托Parameterized delegates

参数化委托具有以下附加要求。Parameterized delegates have the following additional requirements.

  • 参数化委托的名称追加了反撇号和一个数字,该数字表示参数化委托具有的类型参数的数目。The name of a parameterized delegate is appended with a backtick and a number representing the number of type parameters the parameterized delegate has. 例如,EventHandler 类型存储在名为 EventHandler`1 的元数据中。For example, the Windows.Foundation.EventHandler type is stored in metadata with the name Windows.Foundation.EventHandler`1.
  • 参数化委托对于每个类型参数都有一行,每个类型参数的列都设置如下。Parameterized delegates have one row in the GenericParam table (ECMA II.22.20) for every type parameter with the columns set as follows.
    • Number:从零开始的泛型参数的索引,按从左到右的顺序编号。Number: the index of the generic parameter, numbered left-to-right, starting at zero.
    • Flags: None。Flags: None.
    • 所有者:对包含接口的行的 TypeDef 表中的索引。Owner: Index into the TypeDef table for the row containing the interface.
    • 名称:包含泛型参数名称的字符串堆中的索引。Name: Index into the string heap containing the name of the generic parameter.

TypeSpec 表(ECMA 23.2.14)用于定义参数化委托的实例。The TypeSpec table (ECMA II.23.2.14) is used to define instances of parameterized delegates. 然后,可以在方法签名中使用这些 TypeSpecs,类似于 TypeRefs。These TypeSpecs can then be used in method signatures similarly to TypeRefs.

界面Interfaces

接口在 TypeDef 表(ECMA 22.37)中实现为一行,列设置如下。Interfaces are implemented as a row in the TypeDef table (ECMA II.22.37) with the columns set as follows.

  • 标记:Flags:
    • interface |公共 |abstract |tdWindowsRuntime (0x40A1)或interface | public | abstract | tdWindowsRuntime (0x40A1), or
    • interface |NotPublic |abstract |tdWindowsRuntime (0x40A0)interface | NotPublic| abstract | tdWindowsRuntime (0x40A0)
  • 名称:字符串表中包含接口名称的索引。Name: an index into the string table containing the interface name.
  • 命名空间–包含类型命名空间的字符串堆中的索引。Namespace – an index into the string heap that contains the namespace of the type.
  • 扩展: null。Extends: null.
  • FieldList:必须为空。FieldList: must be empty.
  • MethodList: MethodDef 表的索引,用于标记此类型所拥有的方法的连续运行的第一个。MethodList: An index into the MethodDef table, marking the first of a contiguous run of methods owned by this type. 在当前节的子节中详细介绍了 MethodDef 表的内容。Specifics on the contents of the MethodDef table are detailed in the subsections of the current section.

接口的 TypeDef 行必须具有 GuidAttribute 以及 VersionAttribute。Interfaces' TypeDef rows must have a GuidAttribute as well as a VersionAttribute.

具有私有可见性的任何 WinRT 接口都必须具有单个 ExclusiveToAttribute。Any WinRT interface with private visibility must have a single ExclusiveToAttribute. 具有公共可见性的任何 WinRT 接口都不能有 ExclusiveToAttribute。Any WinRT interface with public visibility must not have an ExclusiveToAttribute. 如果存在,则 ExclusiveToAttribute 必须引用运行时类。If present, the ExclusiveToAttribute must reference a runtime class.

接口所需的接口由 InterfaceImpl 表中的行(ECMA 22.23)表示,列设置如下。Required interfaces for an interface are represented by rows in the InterfaceImpl table (ECMA II.22.23) with the columns set as follows.

  • 类:包含接口的行的 TypeDef 表中的索引。Class: an index into the TypeDef table for the row containing the interface.
  • Interface: TypeDef、TypeRef 或 TypeSpec 表中的一个索引,用于指定所需的接口。Interface: an index into the TypeDef, TypeRef or TypeSpec table that specifies the required interface. 请注意,在系统提供的元数据文件中,即使所需的接口是在同一个元数据文件中定义的,也不会使用 TypeDef。Note, in system provided metadata files, this will never be a TypeDef even if the required interface is defined in the same metadata file. 有关更多详细信息,请参阅 "TypeDef 重定向" 部分。See the TypeDef Redirection section for further details.

参数化接口Parameterized interfaces

参数化接口:以下附加要求。Parameterized interfaces the following additional requirements.

参数化接口的名称追加了反撇号和一个数字,该数字表示参数化委托具有的类型参数的数目。The name of a parameterized interface is appended with a backtick and a number representing the number of type parameters the parameterized delegate has. 例如,IVector 类型存储在名为 IVector 的元数据中,名称为`1。For example, the Windows.Foundation.Collections.IVector type is stored in metadata with the name Windows.Foundation.Collections.IVector`1.

对于其列设置如下的每个类型形参,每个类型形参的 GenericParam 表中都有一行。Parameterized interfaces have one row in the GenericParam table (ECMA II.22.20) for every type parameter with the columns set as follows.

  • Number:从零开始的泛型参数的索引,按从左到右的顺序编号。Number: the index of the generic parameter, numbered left-to-right, starting at zero.
  • Flags: None。Flags: None.
  • 所有者:对包含接口的行的 TypeDef 表中的索引。Owner: Index into the TypeDef table for the row containing the interface.
  • 名称:包含泛型参数名称的字符串堆中的索引。Name: Index into the string heap containing the name of the generic parameter.

TypeSpec 表(ECMA 23.2.14)用于定义参数化接口的实例。The TypeSpec table (ECMA II.23.2.14) is used to define instances of parameterized interfaces. 然后,可以在方法签名和接口实现中使用这些 TypeSpecs,类似于 TypeRefs。These TypeSpecs can then be used in method signatures and interface implementations similarly to TypeRefs.

接口成员Interface members

数组参数Array parameters

对任何接口成员类型的数组参数进行编码时,从 MethodDefSig blob 和参数表中直接省略数组参数之前的数组长度参数。When encoding an Array parameter for any interface member type, the array length parameter that immediately precedes the array parameter is omitted from both the MethodDefSig blob as well from as the params table.

数组参数的方向直接在元数据中编码。The direction of the array parameter is directly encoded in metadata. 可以按如下方式推断数组长度参数的方向。The direction of the array length parameter may be inferred as follows.

  • 如果 array 参数是 in 参数,则数组长度参数还必须为 in 参数。If the array parameter is an in parameter, the array length parameter must also be an in parameter.
  • 如果 array 参数是 out 参数并且未携带 BYREF 标记,则数组长度为 in 参数。If the array parameter is an out parameter and is not carrying the BYREF marker, the array length is an in parameter.
  • 如果 array 参数是 out 参数并且带有 BYREF 标记,则数组长度为 out 参数。If the array parameter is an out parameter and carries the BYREF marker, the array length is an out parameter.

方法Methods

为了更好地为方法的预期预测以及 CLR 兼容性建模,必需的 HRESULT 返回值未在元数据中编码。In order to better model the expected projection of methods as well as CLR compatibility, the required HRESULT return value is not encoded in metadata. 相反,用作返回值的 out 参数编码为 methodDefSig 中的返回值。Rather, the out parameter to be used as the return value is encoded as the return value in the methodDefSig. 对于不将 out 参数声明为返回值的方法,methodDefSig 必须将返回类型声明为 void (按照 ECMA II. 23.2.11)。For methods that do not declare an out parameter to be used as the return value, the methodDefSig must declare the return type to be void (as per ECMA II.23.2.11).

接口上的每个方法都将表示为 MethodDef 表中的一行。Each method on an interface will be represented as a row in the MethodDef table. 每个 methoddef 行都包含以下信息。Each methoddef row will contain the following information.

  • RVA:0x00RVA: 0x00
  • ImplFlags:0x00ImplFlags: 0x00
  • 标志:公共 |Virtual |HideBySig |Abstract |NewSlot |实例(0x5c6)Flags: public | Virtual | HideBySig | Abstract | NewSlot | Instance (0x5c6)
  • 名称:字符串表中包含方法名称的索引Name: an index into the string table containing the name of the method
  • 签名:包含方法的参数类型和返回类型的 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the parameter types and return type of the method. 如果接口已参数化,则 MethodDefSig blob 应通过 GENERICINST 编码类型引用每个接口的类型参数(按照 ECMA II. 23.2.12)。If the interface is parameterized, the MethodDefSig blob should reference each of the interface's type parameters via GENERICINST encoded Type (as per ECMA II.23.2.12). 要遵循的参数化接口的详细信息。Details on parameterized interfaces to follow.
  • ParamList: Param 表(ECMA 22.33)的索引,其中包含与此方法关联的参数行运行中的第一个索引。ParamList: an index into the Param table (ECMA II.22.33) containing the first in a run of Param rows associated with this method.

方法的每个参数(加上指定的返回值)将在 Param 表中具有相应的行(ECMA 22.33)。Each parameter of the method (plus the return value if specified) will have a corresponding row in the Param table (ECMA II.22.33).

  • 标志– none、in 或 out,适用于参数。Flags – none, in or out as appropriate for the parameter.
    • 返回值始终为 noneReturn values are always none
    • 其他参数始终处于或传出Other parameters are always in or out
  • 序列–参数的序列顺序。Sequence – sequence order of the parameter.
    • 为方法的返回值保留零Zero is reserved for the return value of the method
  • 名称–到包含参数名称的字符串堆中的索引。Name – index into the string heap containing the name of the parameter.

每个方法都可以有选择地包含一个 OverloadAttribute,它具有唯一方法名称(在接口的范围内)。Each method may optionally have an OverloadAttribute that carries the unique method name (within the scope of the interface). 每个方法都可以有一个 Windows.foundation.metadata.defaultoverloadattribute,用于指示相同数量的重载方法(也称为 in 参数的数量)应以弱、动态类型化语言进行投影。Each method may optionally have a DefaultOverloadAttribute that indicates which overloaded method of the same arity (aka number of in parameters) should be projected in weakly, dynamically typed languages.

属性Properties

接口上的每个属性都定义为属性(ECMA 22.34)、System.windows.forms.integration.windowsformshost.propertymap (ECMA 22.35)、MethodSemantics (ECMA ii. 22.28)和 MethodDef (ECMA II. 22.26)表中的行。Each property on an interface is defined as rows in the Property (ECMA II.22.34), PropertyMap (ECMA II.22.35), MethodSemantics (ECMA II.22.28) and MethodDef (ECMA II.22.26) tables.

具有一个或多个属性的每个接口都将表示为包含以下信息的 System.windows.forms.integration.windowsformshost.propertymap 表中的单个行。Each interface with one or more properties will be represented as a single row in the PropertyMap table containing the following information.

  • Parent:包含属性的接口的 TypeDef 表中的索引。Parent: an index into the TypeDef table containing the interface that contains the properties.
  • PropertyList:属性表中的索引,其中包含与此类型关联的行中的第一个。PropertyList: an index into the Property table containing the first in a run of rows associated with this type.

每个属性都将在属性表中表示为单个行,其中包含以下信息Each property will be represented as a single row in the Property table containing the following information

  • Flags: None。Flags: None.
  • 名称:包含属性名称的字符串堆中的索引。Name: an index into the string heap containing the name of the property.
  • 键入包含属性的类型信息的 blob 堆中的索引(包含 PropertySig blob (ECMA 23.2.5)的索引。Type: index into the blob heap containing a PropertySig blob (ECMA II.23.2.5) containing the type information for the property.

每个属性都将表示为 MethodDef 表中的一个或两个行。Each Property will be represented as one or two rows in the MethodDef table. 只读属性表示为具有 "get_" 前缀的单个方法,而读/写属性则表示为两个方法,一个具有 "get_",另一个具有 "put_" 前缀。Read-only properties are represented as a single method with the "get_" prefix, while read/write properties are represented as two methods, one with the "get_" and the other with the "put_" prefix. Get 方法的签名不采用任何参数,并返回该属性类型的值。The signature for the get method takes no parameters and returns a value of the property's type. Set 方法的签名使用该属性的类型的单个参数,而不会返回任何内容。The signature for the set method takes a single parameter of the property's type and doesn't return anything.

属性的 MethodDef 行包含以下各项。The MethodDef rows for the property contain the following.

  • RVA:0RVA: 0
  • ImplFlags: NoneImplFlags: None
  • 标志:公共 |virtual |HideBySig |newSlot |abstract |specialname (0xDC6)Flags: public | virtual | HideBySig | newSlot | abstract | specialname (0xDC6)
  • 名称:字符串表中的索引,其中包含适当的 "get_" 或 "put_"Name: an index into the string table containing "get_" or "put_" as appropriate
  • 签名:包含 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引,其中包含方法的参数类型和返回类型,如上文所述。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the parameter types and return type of the method as described above.
  • ParamList: Param 表(ECMA 22.33)的索引,其中包含与此方法关联的参数行运行中的第一个索引。ParamList: an index into the Param table (ECMA II.22.33) containing the first in a run of Param rows associated with this method. 参数表中的值是在上述方法中指定的。Values in the Param table are as specified under methods above.

属性的每个 MethodDef 行在 MethodSemantics 表中都有一个关联的行,其中包含以下信息。Each MethodDef row for the property will have an associated row in the MethodSemantics table containing the following information.

  • 语义:视需要为 Getter 或 Setter。Semantics: Getter or Setter as appropriate.
  • 方法:在包含 getter 或 setter 方法的 MethodDef 表中建立索引。Method: Index into the MethodDef table containing the the getter or setter method.
  • Association:在包含属性的属性表中建立索引。Association: Index into the Property table containing the property.

EventsEvents

接口上的每个事件定义为事件(ECMA 22.13)、EventMap (ECMA 22.12)、MethodSemantics (ECMA)和 MethodDef (ECMA II. 22.28)表中的行。Each event on an interface is defined as rows in the Event (ECMA II.22.13), EventMap (ECMA II.22.12), MethodSemantics (ECMA II.22.28), and MethodDef (ECMA II.22.26) tables.

包含一个或多个事件的每个接口都将在 EventMap 表中表示为单个行,其中包含以下信息。Each interface with one or more events will be represented as a single row in the EventMap table containing the following information.

  • Parent:包含属性的接口的 TypeDef 表中的索引。Parent: an index into the TypeDef table containing the interface that contains the properties.
  • EventList:事件表中的索引,其中包含与此类型关联的行中的第一个。EventList: an index into the Event table containing the first in a run of rows associated with this type.

每个事件都将表示为包含以下信息的事件表中的单个行。Each Event will be represented as a single row in the Event table containing the following information.

  • EventFlags: None。EventFlags: None.
  • 名称:包含属性名称的字符串堆中的索引。Name: an index into the string heap containing the name of the property.
  • 类型类型:一个 TypeDefOrRef,用于索引到包含事件委托类型的相应表中。EventType: a TypeDefOrRef that indexes into the appropriate table that contains the delegate type of the event.

每个事件都将在 MethodDef 表中表示为两行,一个包含用于添加事件侦听器的 "add_" 前缀,另一个包含用于删除事件侦听器的 "remove_" 前缀。Each Event will be represented as two rows in the MethodDef table, one with the "add_" prefix for adding event listeners, and one with the "remove_" prefix for removing event listeners. Add 方法采用委托实例,并返回表示事件注册的 EventRegistrationToken。The add method takes in a delegate instance and returns a Windows.Foundation.EventRegistrationToken that represents the event registration. Remove 方法使用 add 方法返回的 EventRegistrationToken 取消注册事件。The remove method takes the EventRegistrationToken returned by the add method to unregister the event.

事件的 MethodDef 行包含以下各项。The MethodDef rows for the event contains the following.

  • RVA:0RVA: 0
  • ImplFlags: NoneImplFlags: None
  • 标志:公共 |最终 |virtual |hidebysig |newslot |specialname (0x09e6)Flags: public | Final | virtual | hidebysig | newslot | specialname (0x09e6)
  • 名称:字符串表中的索引,其中包含适当的 "add_" 或 "remove_"。Name: an index into the string table containing "add_" or "remove_" as appropriate.
  • 签名:包含 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引,其中包含方法的参数和返回类型,如下所述。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the parameter and return types of the method as described below.
    • Add_ 方法采用委托类型的单个参数,并返回 EventRegistrationToken。Add_ method takes a single parameter of the delegate type and returns a Windows.Foundation.EventRegistrationToken.
    • Remove_ 方法采用单个 EventRegistrationToken 参数,并且不返回任何内容。Remove_ method takes a single Windows.Foundation.EventRegistrationToken parameter and returns nothing.
  • ParamList: Param 表中的索引(ECMA 22.33),其中包含与方法关联的参数行运行中的第一个索引。ParamList: an index into the Param table (ECMA II.22.33) containing the first in a run of Param rows associated with the method. 参数表中的值是在上述方法中指定的。Values in the Param table are as specified under methods above.

事件的两个 MethodDef 行在 MethodSemantics 表中都有一个关联的行,其中包含以下信息。Both MethodDef rows for the event will have an associated row in the MethodSemantics table containing the following information.

  • 语义:加载项或 RemoveOn。Semantics: AddOn or RemoveOn as appropriate.
  • 方法:对包含添加或删除侦听器方法的 MethodDef 表的索引。Method: Index into the MethodDef table containing the the add or remove listener method.
  • 关联:在包含事件的事件表中建立索引。Association: Index into the Event table containing the event.

运行时类Runtime classes

运行时类作为 TypeDef 表(ECMA 22.37)中的行实现,并按如下所示设置列。Runtime Classes are implemented as a row in the TypeDef table (ECMA II.22.37) with the columns set as follows.

  • Flags:所有运行时类必须携带公共、自动布局、类和 tdWindowsRuntime 标志。Flags: all runtime classes must carry the public, auto layout, class, and tdWindowsRuntime flags.
    • 仅限静态的类携带抽象标志。Static only classes carry the abstract flag. 所有其他类不会携带抽象标志。All other classes do not carry the abstract flag.
    • 不能组合的类携带密封标志。Non-composable classes carry the sealed flag. 可组合类不携带密封标志。Composable classes do not carry the sealed flag.
  • 名称:包含类名的字符串表中的索引。Name: an index into the string table containing the class name.
  • 命名空间–包含类型命名空间的字符串堆中的索引。Namespace – an index into the string heap that contains the namespace of the type.
  • 扩展:在 mscorlib 中引用可组合类或 System.object 的索引。Extends: an index into the TypeRef referencing either a composable class or System.Object in mscorlib.
  • FieldList:必须为空。FieldList: must be empty.
  • MethodList: MethodDef 表的索引,用于标记此类型所拥有的方法的连续运行的第一个。MethodList: An index into the MethodDef table, marking the first of a contiguous run of methods owned by this type. 下面详细介绍了 MethodDef 表的内容。Specifics on the contents of the MethodDef table are detailed below.

对于所有系统提供的类,必须将 VersionAttribute 添加到类的 TypeDef 行。For all system provided classes, the VersionAttribute must be added to the class's TypeDef row.

实现的接口Implemented interfaces

由运行时类实现的接口由 InterfaceImpl 表中的行(ECMA 22.23)表示,列设置如下。Interfaces implemented by runtime classes are represented by rows in the InterfaceImpl table (ECMA II.22.23) with the columns set as follows.

  • 类:包含类型的行的 TypeDef 表中的索引。Class: an index into the TypeDef table for the row containing the type.
  • 接口:用于指定实现的接口的 TypeDef、TypeRef 或 TypeSpec 表中的索引。Interface: an index into the TypeDef, TypeRef or TypeSpec table that specifies the implemented interface. 请注意,在系统提供的元数据文件中,即使所需的接口是在同一个元数据文件中定义的,也不会使用 TypeDef。Note, in system provided metadata files, this will never be a TypeDef even if the required interface is defined in the same metadata file. 有关更多详细信息,请参阅 "TypeDef 重定向" 部分。See the TypeDef Redirection section for further details.

运行时类必须仅指定其一个 InterfaceImpl 行的 DefaultAttribute。Runtime classes must specify the DefaultAttribute on exactly one of their InterfaceImpl rows.

运行时类可以对其任何 InterfaceImpl 行指定 OverridableAttribute 或 ProtectedAttribute。Runtime classes may specify the OverridableAttribute or ProtectedAttribute on any of their InterfaceImpl rows. 它们不能在同一行中同时指定 OverridableAttribute 和 ProtectedAttribute。They may not specify both OverridableAttribute and ProtectedAttribute on the same row.

可以选择将 VersionAttribute 添加到类的任何 interfaceImpl 行。Optionally, the VersionAttribute may be added to any of the class's interfaceImpl rows. 任何类的 interfaceImpl 行上的 VersionAttribute 中的版本值必须大于或等于类的 TypeDef 行上 VersionAttribute 中的值。The version value from the VersionAttribute on any class's interfaceImpl rows must be greater than or equal to the value from the VersionAttribute on the class's TypeDef row.

静态接口Static interfaces

运行时类有零个或多个 StaticAttribute 自定义特性。Runtime classes have zero or more StaticAttribute custom attributes. 指定多个 StaticAttribute 自定义特性是合法的,只要它们具有不同的指定参数即可。It is legal to specify more than one StaticAttribute custom attributes, so long as each has different specified parameters. 所有 StaticAttribute 都将显示为 CustomAttribute 表中的一行,其中包含以下信息。Any StaticAttribute will appear as a row in the CustomAttribute table with the following information.

  • Parent: StaticAttribute 关联的运行时类。Parent: The runtime class the StaticAttribute is associated with.
  • 类型:对 StaticAttribute 的 .ctor 的引用。Type: A reference to StaticAttribute's .ctor.
  • 值:一个自定义属性 blob,其中包含 System.object 静态接口参数和 Uint32 版本参数。Value: a custom attribute blob containing the System.Type static interface parameter and the Uint32 version parameter.

激活Activation

运行时类有零个或多个 ActivatableAttribute 自定义特性。Runtime classes have zero or more ActivatableAttribute custom attributes. 指定多个 ActivatableAttribute 自定义特性是合法的,只要它们具有不同的指定参数即可。It is legal to specify more than one ActivatableAttribute custom attributes, so long as each has different specified parameters. 所有 ActivatableAttributes 都将显示为 CustomAttribute 表中的一行,其中包含以下信息。Any ActivatableAttributes will appear as a row in the CustomAttribute table with the following information.

  • Parent: ActivatableAttribute 关联的运行时类。Parent: The runtime class the ActivatableAttribute is associated with.
  • 类型:对 ActivatableAttribute 的其中一个 ctor 的引用。Type: A reference to one of ActivatableAttribute's two .ctors.
    • 直接激活:仅采用 Uint32 版本参数的 .ctor。Direct Activation: the .ctor taking just the Uint32 version parameter.
    • 工厂激活:采用系统类型工厂接口参数和 Uint32 版本参数的 .ctor。Factory activation: the .ctor taking the System.Type factory interface parameter and the Uint32 version parameter.
  • 值:包含 System.web interface 参数(如果提供)和 Uint32 版本参数的自定义属性 blob。Value: a custom attribute blob containing the System.Type factory interface parameter (if provided) and the Uint32 version parameter.

组合 (Composition)Composition

运行时类有零个或多个 ComposableAttribute 自定义特性。Runtime classes have zero or more ComposableAttribute custom attributes. 指定多个 ComposableAttribute 自定义特性是合法的,只要它们具有不同的指定参数即可。It is legal to specify more than one ComposableAttribute custom attributes, so long as each has different specified parameters. 所有 ComposableAttribute 都将显示为 CustomAttribute 表中的一行,其中包含以下信息。Any ComposableAttribute will appear as a row in the CustomAttribute table with the following information.

  • Parent: ComposableAttribute 关联的运行时类。Parent: The runtime class the ComposableAttribute is associated with .
  • 类型:对 ComposableAttribute 的 .ctor 的引用。Type: A reference to ComposableAttribute's .ctor.
  • 值:一个自定义属性 blob,其中包含 System. Type 组合工厂接口接口参数、CompositionType 枚举值(公共或受保护)和 Uint32 版本参数。Value: a custom attribute blob containing the System.Type composition factory interface interface parameter, a CompositionType enum value (Public or Protected) and the Uint32 version parameter.

类方法Class methods

对于与类关联的每个接口上的每个方法,运行时类在 MethodDef 表中都有一行。A runtime class has a row in the MethodDef table for every method on every interface associated with the class. 这包括成员接口(普通、受保护和可重写)、静态接口、激活工厂接口和可组合的工厂接口。This includes member interfaces (normal, protected, and overridable), static interfaces, activation factory interfaces, and composable factory interfaces. 此外,支持直接激活的类还会在 MethodDef 表中包含一行来指示这一点。Additionally, a class that supports direct activation will also have a row in the MethodDef table to indicate this.

成员界面成员Member interface members

成员接口中的每个方法(包括受保护的和可重写的接口)由类的 MethodDef 表中的一行表示。Each method from a member interface (including protected and overridable interfaces) is represented by a row in the class's MethodDef table. 类的 methodDef 表包含来自原始声明接口的 MethodDef 信息的精确副本,包括参数表行和自定义属性,但以下情况例外。The class's methodDef table contains an exact copy of the MethodDef information from the original declaring interface, including Param table rows and custom attributes, with the following exceptions.

  • 运行时类可为成员接口上定义的方法指定替代名称。Runtime classes may specify alternative names for methods defined on member interfaces.
  • 运行时类的方法不会获得抽象标志。Methods on runtime classes do not get the Abstract flag.
  • 运行时类的方法获取运行时 MethodImpl 标志。Methods on runtime classes get the Runtime MethodImpl flag.
  • 不能重写的接口中的方法还获取最终标志。Methods from non-overridable interfaces additionally get the Final flag. 可重写接口中的方法不会获得最终标志。Methods from overridable interfaces do not get the Final flag.

成员接口中的类的 MethodDef 表中的每一行都连接回接口方法,该方法最初通过 MethodImpl 表(ECMA 22.27)中的一个条目定义了方法,其值如下所示。Each row in the MethodDef table of a class from a member interface is connected back to the interface method that originally defined the method via an entry in the MethodImpl table (ECMA II.22.27) with values as follows.

  • Class – TypeDef 表中的一个索引,该索引引用携带方法的类(请注意,此索引不受 TypeDef 重定向的限制)。Class – an index into the TypeDef table which references the class carrying the method (note, this index is not subject to TypeDef Redirection).
  • MethodBody – MethodDef 表中引用类方法的索引。MethodBody – An index into the MethodDef table which references the class method.
  • MethodDeclaration – MethodDef 或 MemberRef 表中引用最初声明的接口方法的索引。MethodDeclaration – an index into the MethodDef or MemberRef table which references the originally declared interface method.
静态接口成员Static interface members

静态接口中的每个方法都用类的 MethodDef 表中的行表示。Each method from a static interface is represented by a row in the class's MethodDef table. 类的 methodDef 表包含来自原始声明接口的 MethodDef 信息的精确副本,包括参数表行和自定义属性,但以下情况例外。The class's methodDef table contains an exact copy of the MethodDef information from the original declaring interface, including Param table rows and custom attributes, with the following exceptions.

  • 静态成员不会获得 Virtual、Abstract、NewSlot 和 Instance 标志。Static members do not get the Virtual, Abstract, NewSlot and Instance flags.
  • 静态成员确实会获得静态和类标志。Static members do get the Static and Class flags.
  • 运行时类上的静态方法获取运行时 MethodImpl 标志。Static Methods on runtime classes get the Runtime MethodImpl flag.
激活成员Activation members

支持直接的无参数激活的类具有类的 MethodDef 表中具有以下列值的构造函数行。Classes that support direct, parameterless activation have a constructor row in the class's MethodDef table with the following column values.

  • RVA:0x00RVA: 0x00
  • ImplFlags:运行时ImplFlags: Runtime
  • 标志:公共 |HideBySig |SpecialName |RTSpecialName |实例Flags: public | HideBySig | SpecialName | RTSpecialName | Instance
  • 名称:字符串表中包含 ".ctor" 的索引Name: an index into the string table containing ".ctor"
  • 签名:包含不包含参数并返回 null 的 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains no parameters and returns null
  • ParamList:必须为空ParamList: must be empty

支持工厂激活的类具有类的 MethodDef 表中的构造函数行,每个实现的工厂接口中的每个方法都具有以下列值。Classes that support factory activation have a constructor row in the class's MethodDef table for every method in every implemented factory interface with the following column values.

  • RVA:0x00RVA: 0x00
  • ImplFlags:运行时ImplFlags: Runtime
  • 标志:公共 |HideBySig |SpecialName |RTSpecialName |实例Flags: public | HideBySig | SpecialName | RTSpecialName | Instance
  • 名称:字符串表中包含 ".ctor" 的索引。Name: an index into the string table containing ".ctor".
  • 签名:包含包含输入参数并返回 null 的 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the input parameters and returns null.
  • ParamList:指向 Params 表的指针,其中每个参数对应一行,从最初声明工厂方法的 params 表完全复制。ParamList: pointer into the Params table with a row for every parameter, copied exactly from the params table for the originally declaring factory method.
构成成员Composition members

支持组合工厂激活的类具有类的 MethodDef 表中的构造函数行,每个实现的工厂接口中的每个方法都具有以下列值。Classes that support composition factory activation have a constructor row in the class's MethodDef table for every method in every implemented factory interface with the following column values.

  • RVA:0x00RVA: 0x00
  • ImplFlags:运行时ImplFlags: Runtime
  • 标志:公共 |HideBySig |SpecialName |RTSpecialName |实例Flags: public | HideBySig | SpecialName | RTSpecialName | Instance
  • 名称:字符串表中包含 ".ctor" 的索引。Name: an index into the string table containing ".ctor".
  • 签名:包含 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引,其中包含自定义输入参数,并返回 null。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the custom input parameters and returns null. 控制 IInspectable * [in] 参数和非委托 IInspectable * * [out] 参数不会反映在方法签名中。The controlling IInspectable* [in] parameter and the non-delegating IInspectable** [out] parameter are not reflected in the method signature.
  • ParamList:指向 Params 表中的指针,其中每个参数对应一行,但控制 IInspectable * [in] 参数和非委托 IInspectable * * [out] 参数,是从最初声明工厂方法的 Params 表完全复制的。ParamList: pointer into the Params table with a row for every parameter except the controlling IInspectable* [in] parameter and the non-delegating IInspectable** [out] parameter, copied exactly from the params table for the originally declaring factory method.

自定义属性Custom attributes

自定义属性有零个或多个构造函数方法,每个方法都有零个或多个参数类型限制为基本类型、枚举和 System.object 的参数。Custom attributes have zero or more constructor methods, each with zero or more parameters where the parameter type is limited to the fundamental types, enums, and System.Type. 自定义特性中的每个构造函数都在 MethodDef 中显示为一行,其中包含以下信息。Each constructor in the custom attribute appears as a row in the MethodDef with the following information.

  • RVA (又称相对虚拟地址): nullRVA (aka Relative Virtual Address): null
  • ImplFlags: NoneImplFlags: None
  • 标志:公共 |HideBySig |specalname |RTSpecialName (0x1886)Flags: public | HideBySig | specalname | RTSpecialName (0x1886)
  • 名称:字符串表中包含名称 ".ctor" 的索引。Name: an index into the string table containing the name ".ctor".
  • 签名:包含方法的参数类型和返回类型的 MethodDefSig blob (ECMA 23.2.1)的 blob 堆中的索引。Signature: an index into the blob heap containing a MethodDefSig blob (ECMA II.23.2.1) that contains the parameter types and return type of the method.
  • ParamList: Param 表(ECMA 22.33)的索引,其中包含与此方法关联的参数行运行中的第一个索引。ParamList: an index into the Param table (ECMA II.22.33) containing the first in a run of Param rows associated with this method.

元数据构造上的自定义属性将以行的形式存储在 CustomAttribute 表(ECMA 22.10)中,如下所示。Custom attributes on metadata constructs are stored as rows in the CustomAttribute table (ECMA II.22.10) with the columns set as follows.

  • Parent:自定义属性附加到的元数据表中的索引。Parent: index into the metadata table the custom attribute is attached to.
  • Type:对 MethodDef 或 MemberRef 表的索引,其中包含对属性类型的构造函数的引用。Type: index into the MethodDef or MemberRef table that contains a reference to the constructor of the attribute type.
  • 值:包含位置和命名特性参数的 blob 堆中的索引(ECMA 23.2)。Value: index into the blob heap that contains positional and named attribute parameters (ECMA II.23.2). 请注意,由于 WinRT 自定义属性不允许具有属性,因此自定义属性 blob 永远不会包含属性样式命名的参数。Note, since WinRT custom attributes are not allowed to have properties, the custom attribute blob will never contain PROPERTY style named arguments.