This project is read-only.

The Root Namespace

CCI Metadata

An assembly is basically a collection of types with associated metadata. It is organized in a hierarchy, based on namespace. For example, the System.dll type hierarchy looks like:
HelloIL_1.jpg
Every assembly must have a root namespace, which is indicated by “{ } -” in the figure, and is called the empty namespace. Despite the name, the empty namespace must contain the specialized <Module> type and can also contain other types, including application-defined types. All other namespaces in the assembly are descendents of the root namespace. For example, CSharp is a child of the Microsoft namespace, which is in turn a child of the root namespace. The number of additional namespaces depends on the particular assembly. Simple assemblies, such as HelloIL, often contain only a root namespace.

Even though all assemblies must have a root namespace, you must still explicitly add it to the Assembly object, as follows:
RootUnitNamespace rootUnitNamespace = new RootUnitNamespace();
assembly.UnitNamespaceRoot = rootUnitNamespace;
rootUnitNamespace.Unit = assembly;

The Microsoft.Cci.MutableCodeModel.RootUnitNamespace object represents the empty namespace. To configure the object, you must:
  • Specify which unit of metadata the root namespace belongs to by assigning the RootUnitNamespace object to the assembly’s UnitNamespaceRoot property.
  • Assign the assembly object to the RootUnitNamespace object’s Unit property.
Namespaces are always doubly-linked, to simplify navigation. This allows you, for example, to determine which assembly hosts a particular namespace, locate the assembly’s root namespace, and then “walk” the namespace tree to construct the assembly’s namespace hierarchy.

Last edited Dec 18, 2009 at 6:23 PM by Guy_Smith, version 3

Comments

No comments yet.