Understanding QInjection

Validation API allows you to define a Validation Syntax, in other word a set of rules used to decide if the Lambda Expression is valid or not.

Internally the validation engine of QInjcetion builds the AST (Abstract Syntax Tree) of the lambda expression and it walks throught it by validating each node and branch. An AST is composed by Node and Branches. So declaring the syntax of a lambda expression
means to define the "structure" of the Tree in term of Nodes and Branches:

You define the list of Nodes accepted

You define for each Node which Branch it can use (e.g. "IndetifierName on LeftBranch of a BinaryExpression").

Moreover, for each Node you can define restrictions in term of names, operators and so on ... accepted in input.

A Validation Syntax then is composed by three main elements:

A set of supported AST Nodes (VS-Nodes)

A set of supported AST Branches, the links between Nodes (VS-Branches)

A set of Restrictions over each Node (VS-Restrictions)

The Validation API allows you to define these three sets <VS-Nodes, VS-Branches, VS-Restrictions> in order to evaluate them on the lambda expression.
Using <VS-Nodes, VS-Branches> you can builds all the combinations of supported AST.
Using <VS-Restrictions> you can decide if a Node is valid or not.

The Validation Engine of QInjection takes in inputs four entities <Lambda-Expression, VS-Nodes, VS-Branches, VS-Restrictions> and it applies the following algorithm:

It calculates the AST associated to the <Lambda-Expression>.

It checks if the AST associated to the <Lambda-Expression> is one of this one that you can build using <VS-Nodes, VS-Branches>.

It checks if each Node of the AST associated to the <Lambda-Expression> satisfies the <VS-Restrictions>.