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(ICompilation, ReferenceResolutionOptions), given an compilation, or using the GetTarget<T>(IRef<T>, ReferenceResolutionOptions) extension method for the compilation of the current context.
Namespace: Metalama.Framework.Code
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public interface IRef<out T> : IEquatable<IRef<ICompilationElement>> where T : class, ICompilationElement
Type Parameters
Name | Description |
---|---|
T | The type of the target object of the declaration or type. |
Methods
Name | Description |
---|---|
As<TOut>() | |
Equals(IRef<ICompilationElement>?, bool) | |
GetTarget(ICompilation, ReferenceResolutionOptions) | Gets the target of the reference for a given compilation, or throws an exception if the reference cannot be resolved. To get the reference for the current execution context, use the GetTarget<T>(IRef<T>, ReferenceResolutionOptions) extension method. |
GetTargetOrNull(ICompilation, ReferenceResolutionOptions) | Gets the target of the reference for a given compilation, or returns |
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. |