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>
A concrete implementation of IDescribedObject<T> that encapsulates an object and its human-readable description.
EligibilityExtensions
Extension methods for IEligibilityBuilder that provide a fluent API for defining aspect eligibility rules.
EligibilityRuleFactory
Factory methods for creating instances of the IEligibilityRule<T> interface, including predefined rules for standard advice kinds and methods for creating custom rules.
Structs
EligibilityExtensions.Converter<T>
A helper type that allows converting an IEligibilityBuilder<T> to an IEligibilityBuilder<T> for a more specific type, with different conversion semantics.
Interfaces
IDescribedObject<T>
Encapsulates an arbitrary object (typically a declaration) along with its optional human-readable description, used when generating eligibility error messages.
IEligibilityBuilder
The non-generic base interface for IEligibilityBuilder<T>.
IEligibilityBuilder<T>
The argument of BuildEligibility(IEligibilityBuilder<T>). Allows aspect implementations to define eligibility requirements using extension methods from EligibilityExtensions.
IEligibilityRule<T>
Encapsulates a predicate determining the eligibility of an object (typically a declaration or a type) across different scenarios.
IEligible<T>
An interface that allows aspects to specify to which declarations they can be applied, ensuring predictable behavior and preventing confusing build errors or incorrect code generation patterns.
Enums
EligibleScenarios
A flags enumeration of scenarios in which an aspect can be used, controlling whether aspects are eligible for direct application, inheritance, or live templates. Values can be combined using bitwise operators.