Open sandboxFocus

Struct SerializableTypeId

Encapsulates a string that uniquely identifies a type within a compilation (except in the situation where the compilation contains several assemblies providing types of the same name) and that is safe to persist in a file.

Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public readonly struct SerializableTypeId : IEquatable<SerializableTypeId>
Remarks

The identifier is composed of the Y: prefix, the type written in C# syntax, an optional ! marker, and an optional generic context introduced by |. The type is written with global::-qualified names, with the arguments of a generic type separated by a comma and no space, and with Nullable<T> written as T?.

The two nullability markers describe different things and are not alternatives. ? belongs to one type reference and means that this type reference is nullable, exactly as in C#. The ! at the end belongs to the whole identifier and means that the type was written in an annotated nullable context, so that every type reference without a ? is non-nullable rather than oblivious. A reference belongs to a single nullable context, that of the place it was written, which is why one marker suffices for all of its type references.

IdentifierType
Y:global::System.String! the non-nullable string.
Y:global::System.String?! the nullable string?.
Y:global::System.String the string of a context that is oblivious to nullability.
Y:global::System.Collections.Generic.List<global::System.String?>! a non-nullable List<string?>, the list itself carrying no ? and its argument carrying one.

An identifier that carries no marker therefore resolves to a type every type reference of which is oblivious to nullability, and not to a non-nullable one.

The marker is written whenever any type reference of the type proves the context annotated, and applies to every type the identifier names when it is resolved. Only a reference type and a type parameter prove anything: a value type is not annotated in an unannotated context any more than in an annotated one, because it can never be oblivious. A type with no reference type and no type parameter anywhere in it, such as KeyValuePair<int, int>, therefore carries no marker and needs none.

Constructors

Name Description
SerializableTypeId(string)

Properties

Name Description
Id

Methods

Name Description
Equals(SerializableTypeId)
Equals(object?)
GetHashCode()
Resolve(ICompilation)
Resolve(ICompilation, IReadOnlyDictionary<string, IType>?)
ToString()

Operators

Name Description
operator ==(SerializableTypeId, SerializableTypeId)
operator !=(SerializableTypeId, SerializableTypeId)