Skip to content

Metadata parser

Raymond Chen edited this page Jul 23, 2019 · 3 revisions

The xlang::meta::reader namespace (abbreviated xmr in this document) provides types for parsing and navigating metadata files. The types match the file format as outlined in XSPEC02: Metadata Representation and more fully documented in ECMA-335 Partition II.

Consequently, an understanding of ECMA-335 is required in order to use the data types in the xlang::meta::reader. This document attempts to capture the aspects of the ECMA-335 file format relevant to interpreting metadata files, but in case of conflict, the documents referenced above are authoritative.

Although metadata files follow the format defined in ECMA-335, they are limited to a subset of the available functionality, as described in XSPEC02. We will attempt to call out such constraints as they arise.

A metadata file consists of a large number of tables, each of which consists of a number of rows and columns. The number and meanings of the columns are established by the schema, whereas the number of rows is dependent upon the contents of the metadata file.

Types

The main table in the metadata file is the TypeDef table, which lists all the types defined by the file. Each type's definition may require information from the TypeDef or other tables, and it is by following links to this additional information that code can understand the contents of a type.

Closely related to the TypeDef is the TypeRef, which is a reference to a type. A TypeRef must be used to reference a type in another metadata file, but it is permissible (and indeed common) to use a TypeRef to reference a type defined within the same metadata file.

A parameterized type (known in ECMA-335 as a generic type) is a template for constructing types. For example, Windows.Foundation.Collections.IMap<K, V> is a parameterized type. Formally, the "name" of a parameterized type is the name without the type parameters. ECMA-335 permits but does not require a backquote and number to be appended to the name, where the number is the number of type parameters. In the preceding example, the formal name would be Windows.Foundation.Collections.IMap`2. Providing values for the type parameters of a parameterized type is known as instantiation.

XSPEC02 permits parameterized types only for delegates and interfaces. Other types, such as runtime classes and enumerations, may not be parameterized.

Also closely related to the TypeDef is the TypeSpec, which describes a type created from other types:

  • An array, such as Windows.UI.Color[].
  • An instantiation of a parameterized type, such as Windows.Foundation.Collections.IMap<String, Int32>.

Attributes

Attributes are used to express information not represented in the core ECMA-335 specification. For example,

  • Versioning information is recorded in a VersionAttribute or ContractVersionAttribute.
  • The static methods of a runtime class are recorded in StaticAttributes.
  • The constructors of a runtime class are recorded in ActivatableAttributes.

Usage notes

You must #include <windows.h> before including meta_reader.h.

Clone this wiki locally