Represents a reference to an IDeclaration or IType, which is valid across different compilation versions (i.e. ICompilation) and, when serialized, across projects and processes. References can be resolved using GetTarget<T>(IRef<T>, ICompilation, IGenericContext?). All objects implementing this interface also implement the stronly-typed IRef<T>.
Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IRef : IEquatable<IRef>
Remarks
Use RefEqualityComparer<T> to compare instances of IRef.
Properties
Name | Description |
---|---|
IsDurable | Gets a value indicating whether the reference can be kept in memory without keeping a reference to the state of the project. Most references are bound to a specific state of the project. They are faster to resolve but prevent that specific project state to be garbage-collected. Durable references are slower to resolve but not cause a memory leak if they stay in memory for a long time. |
Methods
Name | Description |
---|---|
As<TOut>() | Changes the reference type. This method can be used in two scenarios: instead of a C# cast with durable references (see IsDurable), or between IField and IProperty when a field is overridden into a property (see OverridingProperty and OriginalField). |
Equals(IRef?, RefComparison) | |
GetHashCode(RefComparison) | |
GetTargetInterface(ICompilation, Type?, IGenericContext?, bool) | Gets the target of the reference for a given compilation, and specify the type of the interface to be returned. Normally, the extension methods GetTarget<T>(IRef<T>, ICompilation, IGenericContext?) or GetTargetOrNull<T>(IRef<T>, ICompilation, IGenericContext?) should be used instead of this one. |
ToSerializableId() | Returns a string that uniquely identifies the declaration represented by the current reference. This identifier can then be resolved using GetDeclarationFromId(SerializableDeclarationId), even in a different process or with a different version of Metalama than the one that created the id. |