CxContract
Description
- Derived from
-
CxNode abstract
- Extended by
-
CxContractCompare sealed
CxContractInterval sealed
CxContractSimple sealed
Abstract base for classes that represent a value contract in form of a pre- or post-condition of a type member, specified in both user-readable and machine-readable form, embedded in the documentation:
/// <param name="a">[...] </param> /// <returns>[...] </returns> /// <value>[...] </value>
The syntax of a Code-X value contract is defined by the following Grammar:
root := contract ;
!contract := '[' (contract-simple | contract-compare | contract-interval)
']' ;
contract-compare := contract-compare-op contract-expr ;
contract-interval := contract-expr '..' contract-expr ;
contract-simple := 'not-empty' | 'not-null' | 'pow2+1' | 'pow2' ;
contract-compare-op := '>=' | '>' | '<=' | '<' ;
contract-expr := contract-expr-primary !> '-' contract-expr-primary ;
contract-expr-primary := contract-expr-literal | contract-expr-name ;
contract-expr-literal := '-'? dec-digit+ ;
contract-expr-name := 'global::'? (id .. '.') ;
The following external rules are used:
-
id: from CxCodeUnit -
dec-digit: from CxCodeUnit
To obtain a CxContract from source code, use the FromSource method.
Public / Constructors
FromSource
Parses the given Code-X value contract.
- ValidatingException
-
If the syntax of source in is invalid.