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 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 <= condition: false")] public void Assert(bool condition, string text) // Regular Assertion method
-
[ContractAnnotation("s:null => true")] public bool IsNullOrEmpty(string s) // String.IsNullOrEmpty
-
[ContractAnnotation("null => null; notnull => notnull")] public object Transform(object data) // Method which returns null if parameter is null, and not null if parameter is not null
-
[ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] public bool TryParse(string s, out Person result)
</examples>