MetalamaAPI documentationPatterns APIMetalama.​Patterns.​ContractsInvariant­Attribute
Open sandboxFocus

InvariantAttribute Class

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
System.Object
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>)
BuildEligibility(IEligibilityBuilder<IMethod>)

See Also