Metalama 1.0 / / Metalama Documentation / Aspect API Documentation / Metalama.​Framework.​Eligibility

Namespace Metalama.Framework.Eligibility

This is namespace allows you to define how your aspects can be used.

Conceptual Documentation

See Defining the Eligibility of Aspects.


Your aspect implements the IEligible<T> interface, which has a single method BuildEligibility. This method receives an IEligibilityBuilder<T>. Typically, you would use the extension methods of this interface defined in the EligibilityExtensions class to specify the eligibility of your aspect. These extension methods add predefined implementations of the IEligibilityRule<T> interface to the IEligibilityBuilder<T>. However, you can also provide your own implementation of the IEligibilityRule<T> interface.

For details and examples, see Defining the Eligibility of Aspects.

Class diagram

classDiagram class YourAspect { } class IEligible~T~ { BuildEligibility(IEligibilityBuilder~T~) } class IEligibilityBuilder~T~ { AddRule(IEligibilityRule~T~) } class EligibilityExtensions { DeclaringType()$ Parameter()$ ReturnType()$ Type()$ ExceptForInheritance()$ ExceptForScenarios()$ MustBe()$ MustBeXXX()$ MustSatisfy()$ MustSatisfyAll()$ MustSatisfyAny()$ } class IEligibilityRule~T~ { GetEligibity() GetIneligibilityJustification() } YourAspect <|-- IEligible~T~ : implements IEligible~T~ --> IEligibilityBuilder~T~ : uses IEligible~T~ --> EligibilityExtensions : uses EligibilityExtensions --> IEligibilityBuilder~T~ : populates IEligibilityBuilder~T~ *-- IEligibilityRule~T~

Namespace members



Encapsulates an object and a human-readable description.


Extension methods for IDescribedObject<T>.


Extension methods for IEligibilityBuilder.


A helper type that allows to convert an IEligibilityBuilder<T> for a type to an IEligibilityBuilder<T> of another type.


Creates instances of the IEligibilityRule<T> interface, which can then be used by the VerifyEligibility(IEligibilityRule<TAspectTarget>) method.


Enumeration of scenarios in which an aspect can be used.



Encapsulates an arbitrary object and its optional human-readable description. Implemented by DescribedObject<T>.


The non-generic base interface for IEligibilityBuilder<T>.


The argument of BuildEligibility(IEligibilityBuilder<T>). Allows the implementation to add requirements using methods of EligibilityExtensions.


Encapsulates a predicate determining the eligibility of an object (typically a declaration or a type).


An interface that allows aspect to specify to which declarations they are allowed to be applied.