IsDurable
Gets a value indicating whether the reference may be stored in an object that outlives the run that produced it, without keeping a version of the compilation in memory for as long as it is held.
Declaration
bool IsDurable { get; }Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Non-durable references (when IsDurable is false) are bound to a specific compilation
context. They are faster to resolve because they have direct access to the underlying symbol, but they
prevent that compilation from being garbage-collected as long as the reference is held in memory.
References returned by ToRef() are always non-durable.
Durable references (when IsDurable is true) may be held for as long as the object that
holds them lives. Call ToDurable() or ToDurableRef<T>(T) to obtain one,
and prefer the IDurableRef or IDurableRef<T> type over this property when the
requirement can be expressed in a signature.
The representation of a durable reference depends on the kind of compilation. At design time, the analysis process is long-lived and receives a new compilation after each modification of the source code. A durable reference then stores only a string identifier and holds no other object, and resolving it costs a lookup in the symbol table. A batch compilation processes a single compilation, which lives until the build ends. A durable reference then stores the reference it was created from, and computes its identifier only when the identifier is requested, for instance during serialization.
A reference that is stored for longer than a single pipeline run must be durable. The design-time pipeline keeps the objects that fabrics and aspects leave behind across many compilations, so a non-durable reference held by one of them keeps a whole version of the project in memory for as long as the solution is open.