Encapsulates a string that uniquely identifies a declaration within a compilation and that is safe to persist in a file or serialize across processes.
Implements
Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public readonly struct SerializableDeclarationId : IEquatable<SerializableDeclarationId>Remarks
This struct provides a lightweight, string-based identifier for declarations that can be serialized to disk or transmitted across processes. Unlike IRef<T>, which maintains a reference to the declaration, this struct stores only the string identifier.
To obtain a SerializableDeclarationId, call ToSerializableId() or ToSerializableId(). To resolve the identifier back to a declaration, call Resolve(ICompilation) or GetDeclarationFromId(SerializableDeclarationId).
Limitation: The identifier may not be unique if the compilation contains several assemblies providing types with the same fully qualified name.
The identifier of a declaration of a file-local type, that is, of a type declared with the file modifier,
carries the metadata name of that type, because the namespace and the name alone do not tell two such types apart.
The compiler derives that metadata name from the path of the declaring file, so the identifier is identical on
every machine when the projects are built with the pathmap option, as a deterministic build does, and is
specific to the local path otherwise. This is the same condition under which the assembly that the compiler emits
is itself identical on every machine.
Constructors
| Name | Description |
|---|---|
| SerializableDeclarationId(string) | Initializes a new instance of the SerializableDeclarationId struct with the specified identifier string. |
Properties
| Name | Description |
|---|---|
| Id | Gets the string identifier for this declaration. |
Methods
| Name | Description |
|---|---|
| Equals(SerializableDeclarationId) | |
| Equals(object?) | |
| GetHashCode() | |
| Resolve(ICompilation) | Resolves this identifier to the corresponding IDeclaration in the specified compilation. |
| ToString() |
Operators
| Name | Description |
|---|---|
| operator ==(SerializableDeclarationId, SerializableDeclarationId) | Determines whether two SerializableDeclarationId instances are equal. |
| operator !=(SerializableDeclarationId, SerializableDeclarationId) | Determines whether two SerializableDeclarationId instances are not equal. |