Skip to content

Use of Simple vs. Fully Qualified Type Names in C.2 and C.3 #1375

@RexJaeschke

Description

@RexJaeschke

In §C.2 and §C.3, in most cases, library types referenced within type declarations are not qualified with their namespace names. For example:

namespace System
{
    public abstract class Array : IList, ICollection, IEnumerable
    {}
}

where all three interfaces are in namespace System.Collections. (This presumes some sort of implicit/hidden using support.)

However, in other cases (probably in C.3 only), we explicitly qualify some of them. For example:

namespace System.Diagnostics.CodeAnalysis
{
    [System.AttributeUsage(System.AttributeTargets.Field |
      System.AttributeTargets.Parameter | System.AttributeTargets.Property,
      Inherited=false)]
    public sealed class AllowNullAttribute : Attribute
    {}
}

namespace System.Threading.Tasks
{
    public class Task
    {
        public System.Runtime.CompilerServices.TaskAwaiter GetAwaiter();
    }

    public class Task<TResult> : Task
    {
        public new System.Runtime.CompilerServices.TaskAwaiter<T> GetAwaiter();
    }

    public readonly struct ValueTask : System.IEquatable<ValueTask>
    {
        public System.Runtime.CompilerServices.ValueTaskAwaiter GetAwaiter();
    }
}

In §C.5, “Library Type Abbreviations,” we say

The following library types are referenced in this specification. The full names of those types, including the global namespace qualifier are listed below. Throughout this specification, these types appear as either the fully qualified name; with the global namespace qualifier omitted; or as a simple unqualified type name, with the namespace omitted as well. For example, the type ICollection, when used in this specification, always means the type global::System.Collections.Generic.ICollection.

Although this allows both simple and fully qualified names to be used in the spec, for consistency, I propose the following:

  1. We remove all explicit namespace qualifiers from within type declarations in C.2 and C.3.
  2. At the beginning of C.2 and C.3, we add the following (normative) text:

Many of the following type declarations refer to other library types. Such references are simple unqualified type names whose fully qualified names can be found in §C.5.

Note that the CLI spec does not include fully qualified names on the C# signatures, just on the ILAsm ones.

Metadata

Metadata

Assignees

Labels

type: clarityWhile not technically incorrect, the Standard is potentially confusing

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions