Enum ConstraintPolicy
- Namespace
- CStructSharp
- Assembly
- CStructSharp.dll
Chooses whether a read evaluates the @expect and @supports constraints of its layout. It is the
Constraints and Constraints setting of one read.
public enum ConstraintPolicy
Fields
Enforce = 0Every constraint of the read is evaluated: a broken one throws, or is collected when ConstraintViolations is set. The default.
Skip = 1No constraint of the read is evaluated and none is collected, so a value that breaks a condition is read as any other value. It cannot be combined with ConstraintViolations (that option asks for the conditions to be evaluated): a read that sets both fails with ArgumentException when it starts.
Remarks
Skip is for a read of a layout that is parsed at a second site which does not want its header rules (a
lenient scan, a forensic read of damaged data). It evaluates no condition of the read, so it also skips a condition that
later code may rely on (a bound checked before it is used as a shift or an index); the reader then meets the bad value
itself and fails, or not, as the layout without constraints would. Matches takes no read settings and always
evaluates its conditions.