MetalamaAPI documentationPatterns APIMetalama.​Patterns.​Contracts
Open sandboxFocus

Metalama.Patterns.Contracts Namespace

Classes

ContractBaseAttribute

A base class for all contracts defined in this library.

ContractExtensions

ContractHelpers

Runtime helper methods for RangeAttribute.

ContractOptions

Options for all aspects of the Metalama.Patterns.Contracts namespace.

ContractTemplates

CreditCardAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid credit card number. If the target is a nullable type, If the target is a nullable type, null strings are accepted and do not throw an exception.

DoNotCheckInvariantsAttribute

Custom attribute that, when applied to a method, means that invariants should not be checked when this method completes.

EmailAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid email address. If the target is a nullable type, null strings are accepted and do not throw an exception.

EnumDataTypeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid member of an enumeration.

EnumDataTypeAttributeHelper

GreaterThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller than a given value.

InvariantAttribute

InvariantSuspensionCounter

InvariantViolationException

LessThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than a given value.

NegativeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value greater than zero.

NotEmptyAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned an empty value. The custom attributes can be added to locations of type System.String (where empty means zero characters), or ICollection, System.Collections.Generic.ICollection<>, System.Collections.Generic.IReadOnlyCollection<>, arrays or System.Collections.Immutable.ImmutableArray<> (where empty means zero items). Null references or default System.Collections.Immutable.ImmutableArray<> instances are accepted and do not throw an exception.

NotNullAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentNullException if the target is assigned a null value.

PhoneAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid phone number. If the target is a nullable type, null strings are accepted and do not throw an exception.

PositiveAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value smaller than zero.

PostconditionViolationException

The exception that is thrown when a postcondition contract was not fulfilled by a method.

RangeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is outside a given range.

RegularExpressionAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that does not match a given regular expression. If the target is a nullable type, null strings are accepted and do not throw an exception.

RegularExpressionBaseAttribute

The base class of contracts that are based on custom attributes.

RequiredAttribute

Custom attribute that, when added to a field, property or parameter, throws:

StrictlyGreaterThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is smaller than or equal to a given value.

StrictlyLessThanAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is greater than or equal to a given value.

StrictlyNegativeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value greater than or equal to zero.

StrictlyPositiveAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value smaller than or equal to zero.

StrictRangeAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentOutOfRangeException if the target is assigned a value that is not strictly within the given range.

StringLengthAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a string of invalid length. If the target is a nullable type, If the target is a nullable type, null strings are accepted and do not throw an exception.

SuspendInvariantsAttribute

UrlAttribute

Custom attribute that, when added to a field, property or parameter, throws an ArgumentException if the target is assigned a value that is not a valid URL starting with http://, https:// or ftp://. If the target is a nullable type, If the target is a nullable type, null strings are accepted and do not throw an exception.