C# Spec烧脑章节Namespace and type names
这一节太可怕了。冲冲冲。

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/basic-concepts#namespace-and-type-names
The meaning of a namespace_or_type_name is determined as follows:
If the namespace_or_type_name is a qualified_alias_member, the meaning is as specified in §13.8.1.
Otherwise, if the namespace_or_type_name is of the form
Ior of the formI<A₁, ..., Aₓ>:If
xis zero andIis the name of a namespace inN, then:Otherwise, if
Ncontains an accessible type having nameIandxtype parameters, then:Otherwise, if the location where the namespace_or_type_name occurs is enclosed by a namespace declaration for
N:If the location where the namespace_or_type_name occurs is enclosed by a namespace declaration for
Nand the namespace declaration contains an extern_alias_directive or using_alias_directive that associates the nameIwith a namespace or type, then the namespace_or_type_name is ambiguous and a compile-time error occurs.Otherwise, the namespace_or_type_name refers to the namespace named
IinN.If
xis zero and the location where the namespace_or_type_name occurs is enclosed by a namespace declaration forNand the namespace declaration contains an extern_alias_directive or using_alias_directive that associates the nameIwith a namespace or type, then the namespace_or_type_name is ambiguous and a compile-time error occurs.Otherwise, the namespace_or_type_name refers to the type constructed with the given type arguments.
If
xis zero and the namespace declaration contains an extern_alias_directive or using_alias_directive that associates the nameIwith an imported namespace or type, then the namespace_or_type_name refers to that namespace or type.Otherwise, if the namespaces imported by the using_namespace_directives of the namespace declaration contain exactly one type having name
Iandxtype parameters, then the namespace_or_type_name refers to that type constructed with the given type arguments.Otherwise, if the namespaces imported by the using_namespace_directives of the namespace declaration contain more than one type having name
Iandxtype parameters, then the namespace_or_type_name is ambiguous and an error occurs.If
xis zero and the declaration ofTincludes a type parameter with nameI, then the namespace_or_type_name refers to that type parameter.Otherwise, if the namespace_or_type_name appears within the body of the type declaration, and
Tor any of its base types contain a nested accessible type having nameIandxtype parameters, then the namespace_or_type_name refers to that type constructed with the given type arguments. If there is more than one such type, the type declared within the more derived type is selected.If
xis zero and the namespace_or_type_name appears within a generic method declaration (§14.6) but outside the attributes of its method-header, and if that declaration includes a type parameter (§14.2.3) with nameI, then the namespace_or_type_name refers to that type parameter.Otherwise, if the namespace_or_type_name appears within a type declaration, then for each instance type
T(§14.3.2), starting with the instance type of that type declaration and continuing with the instance type of each enclosing class or struct declaration (if any):Note: Non-type members (constants, fields, methods, properties, indexers, operators, instance constructors, finalizers, and static constructors) and type members with a different number of type parameters are ignored when determining the meaning of the namespace_or_type_name. end note
Otherwise, for each namespace
N, starting with the namespace in which the namespace_or_type_name occurs, continuing with each enclosing namespace (if any), and ending with the global namespace, the following steps are evaluated until an entity is located:Otherwise, the namespace_or_type_name is undefined and a compile-time error occurs.
Otherwise, the namespace_or_type_name is of the form
N.Ior of the formN.I<A₁, ..., Aₓ>.Nis first resolved as a namespace_or_type_name. If the resolution ofNis not successful, a compile-time error occurs. Otherwise,N.IorN.I<A₁, ..., Aₓ>is resolved as follows:If
xis zero andNrefers to a namespace andNcontains a nested namespace with nameI, then the namespace_or_type_name refers to that nested namespace.Otherwise, if
Nrefers to a namespace andNcontains an accessible type having nameIandxtype parameters, then the namespace_or_type_name refers to that type constructed with the given type arguments.Otherwise, if
Nrefers to a (possibly constructed) class or struct type andNor any of its base classes contain a nested accessible type having nameIandxtype parameters, then the namespace_or_type_name refers to that type constructed with the given type arguments. If there is more than one such type, the type declared within the more derived type is selected.Note: If the meaning of
N.Iis being determined as part of resolving the base class specification ofNthen the direct base class ofNis considered to be object (§14.2.4.2). end noteOtherwise,
N.Iis an invalid namespace_or_type_name, and a compile-time error occurs.

