ECMA-334: 16.3 Extern alias directives
| C# Language Specification |
| © 2006 ECMA International |
16.3 Extern alias directives
An extern-alias-directive introduces an identifier that serves as an alias for an externally defined namespace. The specification of the aliased namespace is external to the source code of the program.
- extern-alias-directives:
- extern-alias-directive
- extern-alias-directives extern-alias-directive
- extern-alias-directive:
extern aliasidentifier;
The scope of an extern-alias-directive extends over the using-directives, global-attributes and namespace-member-declarations of its immediately containing compilation-unit or namespace-body. An extern-alias-directive contributes its name to the alias declaration space of the containing compilation unit or namespace body (§10.3) and not to the declaration space of the containing namespace.
Within a compilation unit or namespace body that contains an extern-alias-directive, the identifier
introduced by the extern-alias-directive can be used to reference the aliased namespace. It is a compile-time
error for the identifier to be the word global.
Within C# source code, a type is declared a member of a single namespace. However, a namespace
hierarchy referenced by an extern alias may contain types that are also members of other namespaces. For
example, if A and B are extern aliases, the names A::X, B::C.Y and global::D.Z may, depending on
the external specification supported by the particular compiler, all refer to the same type.
The alias introduced by an extern-alias-directive is very similar to the alias introduced by a using-alias-directive. See §16.4.1 for more detailed discussion of extern-alias-directives and using-alias-directives.
Like get and set in property accessors, alias is not a keyword (§9.4.3). The word alias only has special
meaning when it immediately follows the extern keyword in an extern-alias-directive. [Example: In fact an extern alias could use the identifier alias as its name:
extern alias alias;
end example]