Machinations

Public Member Functions | Properties | List of all members
ContractAnnotationAttribute Class Reference

Describes dependency between method input and output. More...

Inheritance diagram for ContractAnnotationAttribute:

## Public Member Functions

| ContractAnnotationAttribute ([NotNull] string contract)
| ContractAnnotationAttribute ([NotNull] string contract, bool forceFullStates)

## Properties

string | Contract`[get]`
bool | ForceFullStates`[get]`

## Detailed Description

Describes dependency between method input and output.

<syntax>

Function Definition Table syntax:

- FDT ::= FDTRow [;FDTRow]*
- FDTRow ::= Input => Output | Output <= Input
- Input ::= ParameterName: Value [, Input]*
- Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}
- Value ::= true | false | null | notnull | canbenull

If method has single input parameter, it's name could be omitted.
Using `halt` (or `void`/`nothing`, which is the same) for method output means that the methos doesn't return normally.
`canbenull` annotation is only applicable for output parameters.
You can use multiple `[ContractAnnotation]` for each FDT row, or use single attribute with rows separated by semicolon.
</syntax> <examples>

- `[ContractAnnotation("=> halt")] public void TerminationMethod()`
- `[ContractAnnotation("halt &lt;= condition: false")] public void Assert(bool condition, string text) // regular assertion method`
- `[ContractAnnotation("s:null => true")] public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()`
- `// A method that returns null if the parameter is null, // and not null if the parameter is not null [ContractAnnotation("null => null; notnull => notnull")] public object Transform(object data)`
- `[ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] public bool TryParse(string s, out Person result)`

</examples>

## Constructor & Destructor Documentation

## ◆ ContractAnnotationAttribute() [1/2]

ContractAnnotationAttribute.ContractAnnotationAttribute | ( | [NotNull] string | contract | ) |

## ◆ ContractAnnotationAttribute() [2/2]

ContractAnnotationAttribute.ContractAnnotationAttribute | ( | [NotNull] string | contract,
|  | bool | forceFullStates
| ) |  |

## Property Documentation

## ◆ Contract

string ContractAnnotationAttribute.Contract

get

## ◆ ForceFullStates

bool ContractAnnotationAttribute.ForceFullStates

get

The documentation for this class was generated from the following file:

- Properties/Annotations.cs