Open sandboxFocusImprove this doc

Namespace Metalama.Framework.Eligibility

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

Conceptual Documentation

Refer to Defining the eligibility of aspects.

Overview

Your aspect should implement the IEligible<T> interface, which contains 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 also have the option to provide your own implementation of the IEligibilityRule<T> interface.

For more details and examples, refer to 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

DescribedObjectExtensions

Extension methods for IDescribedObject<T>.

DescribedObject<T>

Encapsulates an object and a human-readable description.

EligibilityExtensions

Extension methods for IEligibilityBuilder.

EligibilityRuleFactory

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

Structs

EligibilityExtensions.Converter<T>

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

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.

Enums

EligibleScenarios

Enumeration of scenarios in which an aspect can be used.