An IRef that may be stored in an object outliving the run that produced it, without keeping a version
of the compilation in memory for as long as it is held. Its IsDurable property is always
true.
Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
[InternalImplement]
public interface IDurableRef : IRef, IEquatable<IRef>Remarks
Use this type in the signature of anything that stores a reference for longer than a single pipeline run: a field of a fabric, a field of an inheritable aspect, or a parameter of an API that keeps what it is given. The compiler then enforces what would otherwise only be a comment, because an ordinary IRef<T> obtained from ToRef() holds the compilation and cannot be converted implicitly.
Call ToDurableRef<T>(T) on a declaration or a type to obtain one, or ToDurable() when a reference is already at hand. Resolving a durable reference may cost an identifier lookup, which is why references are not durable by default.
The representation of such a reference is not part of this contract and depends on the kind of compilation. At design time, where compilations succeed one another, the reference stores a string identifier. During a batch compilation, which processes a single compilation, the reference stores the reference it was created from. Both representations satisfy this contract, which is that the reference may be held for as long as its holder lives. See IsDurable.