Open sandboxFocus

Class ContractTemplates

Provides default implementations for the code templates used by code contract aspects (derived from ContractBaseAttribute). This class can be derived and templates can be overridden. To register the new template implementations, use the Templates contract options.

Inheritance
ContractTemplates
Namespace: Metalama.Patterns.Contracts
Assembly: Metalama.Patterns.Contracts.dll
Syntax
public class ContractTemplates : ITemplateProvider, ICompileTimeSerializable

Constructors

Name Description
ContractTemplates()

Properties

Name Description
TargetDisplayName

Gets a human-readable name of the target declaration.

TargetParameterName

Gets the name of the target parameter.

Methods

Name Description
OnCreditCardContractViolated(dynamic?, ContractContext)

Template used by the CreditCardAttribute contract.

OnEmailAddressContractViolated(dynamic?, ContractContext)

Template used by the EmailAttribute contract.

OnGreaterThanOrEqualToContractViolated(dynamic?, object, ContractContext)

Template used by the GreaterThanAttribute contract.

OnInvalidEnumValue(dynamic?, ContractContext)

Template used by the EnumDataTypeAttribute contract.

OnLessThanOrEqualToContractViolated(dynamic?, object, ContractContext)

Template used by the LessThanAttribute contract.

OnNotEmptyContractViolated(dynamic?, ContractContext)

Template used by the NotEmptyAttribute contract.

OnNotNullContractViolated(dynamic?, ContractContext)

Template used by the NotNullAttribute contract.

OnPhoneContractViolated(dynamic?, ContractContext)

Template used by the PhoneAttribute contract.

OnRangeContractViolated(dynamic?, NumericRange, ContractContext)

Template used by the RangeAttribute contract.

OnRegularExpressionContractViolated(dynamic?, dynamic?, ContractContext)

Template used by the JetBrains.Annotations.RegexPatternAttribute contract.

OnRequiredContractViolated(dynamic?, ContractContext)

Template used by the RequiredAttribute contract when the value is null.

OnRequiredContractViolatedBecauseOfEmptyString(dynamic, ContractContext)

Template used by the RequiredAttribute contract when the value is an empty string.

OnStrictRangeContractViolated(dynamic?, NumericRange, ContractContext)

Template used by the StrictRangeAttribute contract.

OnStrictlyGreaterThanContractViolated(dynamic?, object, ContractContext)

Template used by the StrictlyGreaterThanAttribute contract.

OnStrictlyLessThanContractViolated(dynamic?, object, ContractContext)

Template used by the StrictlyLessThanAttribute contract.

OnStringLengthContractViolated(dynamic?, int, int, ContractContext)

Template used by the StringLengthAttribute contract when both the lower and the upper bounds are specified.

OnStringMaxLengthContractViolated(dynamic?, int, ContractContext)

Template used by the StringLengthAttribute contract when only the upper bound is specified.

OnStringMinLengthContractViolated(dynamic?, int, ContractContext)

Template used by the StringLengthAttribute contract when only the lower bound is specified.

OnUrlContractViolated(dynamic?, ContractContext)

Template used by the UrlAttribute contract.

Extension Methods

See Also