Metalama 1.0 / / Metalama Documentation / Aspect API / Metalama.​Framework.​Code / IRef<T>

Interface IRef<T>

Represents a reference to a declaration that 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>
    where T : class, ICompilationElement
Type Parameters
Name Description
T

The type of the target object of the declaration.

Methods

Name Description
GetTarget(ICompilation, ReferenceResolutionOptions)

Gets the target of the reference for a given compilation. To get the reference for the current execution context, use the GetTarget<T>(IRef<T>, ReferenceResolutionOptions) extension method.

ToSerializableId()

Returns a string that uniquely identifies the declaration represented by the current reference. This identifier can then be resolved using Metalama.Framework.Code.IDeclarationFactory.GetDeclarationFromId(Metalama.Framework.Code.SerializableDeclarationId), even in a different process or with a different version of Metalama than the one that created the id.

Extension Methods

RefExtensions.GetTarget<T>(IRef<T>, ReferenceResolutionOptions)
SymbolExtensions.GetSymbol(IRef<ICompilationElement>, Compilation, Boolean)