Open sandboxFocus

Class 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.

Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
public class StrictRangeAttribute : RangeAttribute, ILocationLevelAspect, IValidableAnnotation, IAspect
Remarks

Null values are accepted and do not throw an exception.

Floating-point values are tested to be strictly within the given bounds with a tolerance value. The tolerance value is equal to the distance of the value closest to the bounds according to the precision of the respective floating-point numerical data type.

Error message is identified by StrictRangeErrorMessage.

Error message can use additional arguments {4} and {5} to refer to the bounds.

Constructors

Name Description
StrictRangeAttribute(double, double)

Initializes a new StrictRangeAttribute with given floating-point bounds.

StrictRangeAttribute(long, long)

Initializes a new StrictRangeAttribute with given integer bounds.

StrictRangeAttribute(ulong, ulong)

Initializes a new StrictRangeAttribute with given ulong bounds.

Methods

Name Description
CreateException(object, string, LocationKind, LocationValidationContext)
GetErrorMessage()

Gets unformatted error message as defined by the instance.