Open sandboxFocus

Method GetAnnotations

GetAnnotations<TAnnotation>()

Gets the list of annotations of a given type on the current declaration.

Declaration
public IEnumerable<TAnnotation> GetAnnotations<TAnnotation>() where TAnnotation : class, IAnnotation<T>
Returns
Type Description
IEnumerable<TAnnotation>

The list of annotations of type TAnnotation on the current declaration.

Type Parameters
Name Description
TAnnotation

The type of annotations to retrieve.

Remarks

Annotations are added by aspects via AddAnnotation<TDeclaration>(IAdviser<TDeclaration>, IAnnotation<TDeclaration>, bool) and can be used for inter-aspect communication within a project.

Only annotations added by aspects that have already executed are visible. Annotations from aspects ordered after the current one are not accessible.

Design-time limitation: At design time, Metalama performs partial compilations that only include the inheritance closure of modified files. Aspects targeting declarations outside this scope do not execute, so their annotations are unavailable.

See Also
AddAnnotation<TDeclaration>(IAdviser<TDeclaration>, IAnnotation<TDeclaration>, bool)