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.
Inheritance
Namespace: PostSharp.Patterns.Contracts
Assembly: PostSharp.Patterns.Common.dll
Syntax
public class StrictRangeAttribute : RangeAttribute, ILocationLevelAspect, IValidableAnnotation, IAspectRemarks
Null values are accepted and do not throw an exception.
A floating-point or decimal value is accepted when it is between the values of its type that are adjacent to the bounds, inclusive. The bounds themselves are rejected. A double bound is first converted to decimal, with 15 significant digits, to compute the decimal bound.
The error message is identified by StrictRangeErrorMessage.
The error message can use the additional arguments {4} and {5} to refer to the bounds.
Constructors
| Name | Description |
|---|---|
| StrictRangeAttribute(double, double) | Initializes a new instance of the StrictRangeAttribute class with given floating-point bounds. |
| StrictRangeAttribute(long, long) | Initializes a new instance of the StrictRangeAttribute class with given integer bounds. |
| StrictRangeAttribute(ulong, ulong) | Initializes a new instance of the StrictRangeAttribute class with given ulong bounds. |
Methods
| Name | Description |
|---|---|
| CreateException(object, string, LocationKind, LocationValidationContext) | |
| GetErrorMessage() | Gets the unformatted error message as defined by the instance. |