MetalamaAPI documentationAspect APIMetalama.​Framework.​EligibilityEligibility­Extensions
Open sandboxFocus

EligibilityExtensions Class

Extension methods for IEligibilityBuilder.

Inheritance
System.Object
EligibilityExtensions
Namespace: Metalama.Framework.Eligibility
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public static class EligibilityExtensions : Object

Methods

Name Description
AddRules<T>(IEligibilityBuilder<T>, Action<IEligibilityBuilder<T>>)

Adds rules to the given IEligibilityBuilder by operating directly on the IEligibilityBuilder.

Convert<T>(IEligibilityBuilder<T>)

Gets an object that allows to convert the given IEligibilityBuilder into an IEligibilityBuilder for a more specific type.

DeclaringMember(IEligibilityBuilder<IParameter>)

Gets an IEligibilityBuilder for the declaring method or property of the parameter validated by the given IEligibilityBuilder.

DeclaringType<T>(IEligibilityBuilder<T>)

Gets an IEligibilityBuilder for the declaring type of the member validated by the given IEligibilityBuilder.

ExceptForInheritance<T>(IEligibilityBuilder<T>)

Gets an IEligibilityBuilder for the same declaration as the given IEligibilityBuilder but that is not applicable when the aspect is inheritable and is applied to a declaration that can be inherited or overridden.

ExceptForScenarios<T>(IEligibilityBuilder<T>, EligibleScenarios)

Gets an IEligibilityBuilder for the same declaration as the given IEligibilityBuilder but that is not applicable to specified EligibleScenarios.

ForScenarios<T>(IEligibilityBuilder<T>, EligibleScenarios)

Gets an IEligibilityBuilder for the same declaration as the given IEligibilityBuilder but that is applicable only to specified EligibleScenarios.

If<T>(IEligibilityBuilder<T>, Predicate<T>)

Adds a rule to the given IEligibilityBuilder, but only if the validate object satisfies a given predicate. Otherwise, the rule is ignored.

IsAdviceEligible(IDeclaration, AdviceKind)

Determines whether the given declaration is an eligible target for a specified kind of advice.

IsAspectEligible(IDeclaration, Type, EligibleScenarios)

Determines whether the given declaration is an eligible target for a specified aspect type given as a reflection Type(IEligibilityBuilder<IHasType>).

IsAspectEligible<T>(IDeclaration, EligibleScenarios)

Determines whether the given declaration is an eligible target for a specified aspect type given as a type parameter.

IsContractAdviceEligible(IDeclaration, ContractDirection)

Determines whether the given declaration is an eligible target for an AddContract advice for a given ContractDirection.

MustBe(IEligibilityBuilder<IType>, IType, ConversionKind)

Requires the target type to be convertible to a given type (specified as an IType).

MustBe(IEligibilityBuilder<IType>, Type, ConversionKind)

Requires the target type to be convertible to a given type (specified as a reflection System.Type).

MustBe<T>(IEligibilityBuilder<IType>, ConversionKind)

Requires the target type to be convertible to a given type (specified as a type parameter).

MustBeExplicitlyDeclared(IEligibilityBuilder<IDeclaration>)

Requires the declaration to be explicitly declared in source code.

MustBeOfAnyType<T>(IEligibilityBuilder<T>, Type[])

Requires the validated object to be of one of the specified types. Note that this validates the object itself, not the declaration that it represents. For instance, if the object is an IParameter and the types parameter is set to string, this method will fail with an exception no conversion exists from IParameter to string.

MustBeOfType<T>(IEligibilityBuilder<T>, Type)

Requires the validated object to be of a certain type of metadata object, e.g. an IField or IMethod. To check the type of a field, property or parameter, use code like builder.Type().MustBe(typeof(string)); instead.

MustBeReadable(IEligibilityBuilder<IFieldOrPropertyOrIndexer>)

Requires the target field, property or indexer to be writable.

MustBeReadable(IEligibilityBuilder<IParameter>)

Requires the parameter to be readable, i.e. not out.

MustBeRef(IEligibilityBuilder<IParameter>)

Requires the parameter to be ref.

MustBeReturnParameter(IEligibilityBuilder<IParameter>)

Requires the parameter to be the return parameter.

MustBeRunTimeOnly(IEligibilityBuilder<INamedType>)

Requires the target type to be run-time, as opposed to compile-time or run-time-or-compile-time.

MustBeStatic(IEligibilityBuilder<IMemberOrNamedType>)

Requires the target member or type to be static.

MustBeWritable(IEligibilityBuilder<IFieldOrPropertyOrIndexer>)

Requires the target property or indexer to be writable.

MustBeWritable(IEligibilityBuilder<IParameter>)

Requires the target parameter to be writable, i.e. ref or out.

MustHaveAccessibility(IEligibilityBuilder<IMemberOrNamedType>, Accessibility, Accessibility[])

Requires the target member to have exactly one of the given accessibilities.

MustHaveAspectOfType(IEligibilityBuilder<IDeclaration>, Type)

Requires the target declaration to have an aspect of a given type.

MustNotBeAbstract(IEligibilityBuilder<IMemberOrNamedType>)

Forbids the target member or type from being abstract.

MustNotBeExtern(IEligibilityBuilder<IMethod>)

Forbids the target method from being extern.

MustNotBeInterface(IEligibilityBuilder<INamedType>)

Forbids the target type from being an interface.

MustNotBePartial(IEligibilityBuilder<IMethod>)

Requires the target method to not be partial.

MustNotBePrimaryConstructor(IEligibilityBuilder<IConstructor>)

Forbids the target constructor from being a primary constructor.

MustNotBePrimaryConstructorOfNonRecordType(IEligibilityBuilder<IConstructor>)

Forbids the target constructor from being a primary constructor of a class or a struct (C# 12.0).

MustNotBeRecordCopyConstructor(IEligibilityBuilder<IConstructor>)

Forbids the target constructor from being the copy constructor of a record.

MustNotBeRef(IEligibilityBuilder<IFieldOrPropertyOrIndexer>)

Forbids the field, property or indexer from being ref or ref readonly.

MustNotBeRef(IEligibilityBuilder<IMethod>)

Forbids the method from returning a ref.

MustNotBeRef(IEligibilityBuilder<INamedType>)

Forbids the type from being ref struct.

MustNotBeReturnParameter(IEligibilityBuilder<IParameter>)

Forbids the parameter from being the return parameter.

MustNotBeStatic(IEligibilityBuilder<IMemberOrNamedType>)

Forbids the target member or type from being static.

MustNotBeVoid(IEligibilityBuilder<IParameter>)

Requires the parameter not to be void.

MustNotHaveAspectOfType(IEligibilityBuilder<IDeclaration>, Type)

Forbids the target declaration from having an aspect of a given type.

MustNotHaveRefOrOutParameter(IEligibilityBuilder<IMethod>)

Requires the target method not to have ref or out parameters.

MustSatisfy<T>(IEligibilityBuilder<T>, Predicate<T>, Func<IDescribedObject<T>, FormattableString>)

Adds a condition to the given IEligibilityBuilder, where the condition must be satisfied by the declaration in order to be eligible for the aspect. The new rule is given as a System.Predicate<>.

MustSatisfyAll<T>(IEligibilityBuilder<T>, Action<IEligibilityBuilder<T>>[])

Adds a group of conditions to the given IEligibilityBuilder, where all conditions must be satisfied by the declaration in order to be eligible for the aspect.

MustSatisfyAny<T>(IEligibilityBuilder<T>, Action<IEligibilityBuilder<T>>[])

Adds a group of conditions to the given IEligibilityBuilder, where at least one condition must be satisfied by the declaration in order to be eligible for the aspect.

Parameter(IEligibilityBuilder<IHasParameters>, Int32)

Gets an IEligibilityBuilder for a parameter of the method validated by the given IEligibilityBuilder, identified by index.

Parameter(IEligibilityBuilder<IHasParameters>, String)

Gets an IEligibilityBuilder for a parameter of the method validated by the given IEligibilityBuilder, identified by name.

ReturnParameter(IEligibilityBuilder<IMethod>)
ReturnType(IEligibilityBuilder<IMethod>)

Gets an IEligibilityBuilder for the return type of the method validated by the given IEligibilityBuilder.

Type(IEligibilityBuilder<IHasType>)

Gets an IEligibilityBuilder for the type of the declaration validated by the given IEligibilityBuilder.

See Also