Saturday 29 August 2009

Understanding Metadata

  • In addition to emitting IL, every compiler targeting the CLR is required to emit full metadata into every managed module.
  • The metadata is a set of data tables that describe what is defined in the module, such as types and their members.
  • It also has tables indicating what the managed module references, such as imported types and their members.
  • Metadata is a superset of older technologies such as Type Libraries and Interface Definition Language (IDL) files. Its embedded in the same exe/dll which means that's its impossible to separate IL and Metadata.
  • It has many other benefits like:
    • Header and library files are not needed anymore as it contains all type information. Compilers can read metadata directly from managed modules.
    • It allows IntelliSense in Visual studio to work.
    • CLRs code verification process ensures that the code is "safe" using metadata.
    • It helps in recreating objects state across processes or machines as the object's fields can be serialized and de-serialized in memory and sent across.
    • It allows garbage collector to track the life time of objects because of the type and object information it contains.

No comments: