Metalama / / API Documentation / Aspect API / 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.

Overview

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 IEligibilityBuilder~T~ <-- IEligible~T~ : uses EligibilityExtensions <-- IEligible~T~ : uses IEligibilityBuilder~T~ <-- EligibilityExtensions : populates IEligibilityBuilder~T~ *-- IEligibilityRule~T~

Namespace members

Classes

DescribedObject<T>

Encapsulates an object and a human-readable description.

DescribedObjectExtensions

Extension methods for IDescribedObject<T>.

EligibilityExtensions

Extension methods for IEligibilityBuilder.

EligibilityExtensions.Converter<T>

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

EligibilityRuleFactory

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

EligibleScenarios

Enumeration of scenarios in which an aspect can be used.

Interfaces

IDescribedObject<T>

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

IEligibilityBuilder

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

IEligibilityBuilder<T>

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

IEligibilityRule<T>

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

IEligible<T>

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