Open sandboxFocus

Method DeclaringType

DeclaringType<T>(IEligibilityBuilder<T>)

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

Declaration
public static IEligibilityBuilder<INamedType> DeclaringType<T>(this IEligibilityBuilder<T> eligibilityBuilder) where T : class, IMemberOrNamedType
Parameters
Type Name Description
IEligibilityBuilder<T> eligibilityBuilder

The parent eligibility builder.

Returns
Type Description
IEligibilityBuilder<INamedType>

An eligibility builder for the declaring type.

Type Parameters
Name Description
T

The type of member or named type being validated.

Remarks

Use this method to validate the type that contains a member. This is useful when an aspect on a member has requirements for the declaring type (e.g., the type must be static, or must not be an interface).

When validation fails on the declaring type, the error message will clearly indicate that it's the declaring type that doesn't meet the requirement, not the member itself.