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>)

Defines the aspect implementation by adding advice, child aspects, and validators to the target declaration.

BuildEligibility(IEligibilityBuilder<IMethod>)

Configures the eligibility of the aspect or attribute by defining rules that determine which declarations the aspect can be applied to.

Extension Methods

See Also