Open sandboxFocus

Class InvariantAttribute

Aspect that, when added to a parameterless void method, causes this method to be invoked after each property setter or method (but not property getters), except those annotated with DoNotCheckInvariantsAttribute. The target method must check any relevant condition and throw throw InvariantViolationException in case of violation.

Inheritance
InvariantAttribute
Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public sealed class InvariantAttribute : MethodAspect, IAspect<IMethod>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<IMethod>
Remarks

The aspect defines a protected method VerifyInvariants that calls all invariant methods defined in the object including in its base classes.

If the IsInvariantSuspensionSupported contract option is defined, the aspect also introduces the protected methods SuspendInvariants, which allows to suspend the verification of invariants, and AreInvariantsSuspended, which determines if the verification of invariants is currently suspended.

Constructors

Name Description
InvariantAttribute()

Methods

Name Description
BuildAspect(IAspectBuilder<IMethod>)

Initializes the aspect. The implementation must add advice, child aspects and validators using the builder parameter.

BuildEligibility(IEligibilityBuilder<IMethod>)

Configures the eligibility of the aspect or attribute. Implementations are not allowed to reference non-static members. Implementations must call the implementation of the base class if it exists.

See Also