Root class for all constraints based on MulticastAttribute. A constraint is a piece of validation logic executed at build time. Constraints are applied to elements of code (Assembly, Type, MethodInfo, ConstructorInfo, PropertyInfo, EventInfo, FieldInfo, ParameterInfo) typically using multicast custom attributes, and verified at build time for every assembly using this element of code.
Implements
Namespace: PostSharp.Constraints
Assembly: PostSharp.dll
Syntax
public abstract class Constraint : MulticastAttribute, IConstraintRemarks
Derive a custom constraint from ScalarConstraint to validate the target declaration itself, or from ReferentialConstraint to validate how other code uses it.
Override ValidateConstraint(object) to restrict the declarations to which the constraint can be applied. It is evaluated
only when the assembly that contains the target declaration is processed. When it returns false, the constraint
is not validated for this target.
Multicasting a constraint to many declarations creates one constraint instance per declaration, which increases build time.
Constructors
| Name | Description |
|---|---|
| Constraint() |
Methods
| Name | Description |
|---|---|
| ValidateConstraint(object) | Validates that the constraint has been applied to a valid element of code. When this
method returns |