Variables

XSharper has concept of a variable: an object with case-insensitive name attached to it.

Variable name may contain spaces and special characters. It cannot, however, start with space, number, single/double/backquote, minus, plus, ~ or %. It can be an empty string though.

To set a variable:

<set name="x" value="Hello" />

Empty variable names are allowed:

<set name="" value="Value of empty" />

Variable with names that start with % used to access environment variables:

<set name="%ENV%" value='New value' />

To make the XML more readable, two syntaxes below are equivalent:

<set name="x">Hello</set>
<set x="Hello" / >

To unset a variable, skip the value attribute:

<set name="x" />

An attempt to access a unset variable produces an exception.