Open sandboxFocus

Method ToRef

ToRef()

Gets a reference that can be used to identify the current type across different compilation versions.

Declaration
IRef<IType> ToRef()
Returns
Type Description
IRef<IType>

A compile-time serializable reference to the current type.

Remarks

References are essential in Metalama because IType objects are bound to a specific ICompilation. As aspects execute, the compilation evolves through multiple immutable versions. References provide a stable way to track the same type across these versions.

To resolve a reference back to the type, use GetTarget<T>(IRef<T>) or GetTarget<T>(IRef<T>, ICompilation, IGenericContext?).

See Also