Skip to content

Supported parameter types

JTRB edited this page Feb 18, 2021 · 17 revisions

Supported Parameter Types

This package supports a rich variety of built-in parameter types that are documented in the tables below. Please refer back to these tables for information about parameter types, their format, and any additional notes about each type. Examples of valid inputs for each parameter are marked with a ✔️, and examples of invalid input are marked with an ❌. To add parsers for custom parameter types to the parser, see the article on extending supported parameter types.

[1]  — Indicates that parentheses and brackets may be used interchangeably, and that values may be optionally separated by commas. Duplicate and leading/trailing commas are not allowed.

[2]  — All generic type parameters, such as T, must be assigned, and a parser for each generic type parameter must exist. Nested types, such as IEnumerable<IEnumerable<int>> are allowed.

Basic C# Types

All C# value types and strings are supported by default.

Parameter Type Format                     Examples                     Notes (if any)
char Any single character
  • ✔️ a
  • ✔️ b
  • ✔️ 1
  • abc
  • 123
string A quoted or unquoted string
  • ✔️ foo
  • ✔️ "hello world"
  • ✔️ "foo\" {bar} [baz]"
  • ✔️ ""
  • {foo}
  • foo[[
  • foo bar
Value may or may not be surrounded by single or double quotes. To include whitespace or to type an empty string, value must be quoted. Due to the nature of the left-recursing parser, special characters such as (, ), {, }, [, or ] (among others) may not be used in strings unless they are surrounded by quotes. See below for which characters are considered "special"
sbyte Any integer between -128 and 127 inclusive
  • ✔️ 50
  • ✔️ -22
  • ✔️ 127
  • 47.7
  • 1000
byte Any integer between 0 and 255 inclusive
  • ✔️ 50
  • ✔️ 255
  • -10
  • 47.7
  • 1000
short Any integer between -32768 and 32767 inclusive
  • ✔️ 50
  • ✔️ 32767
  • ✔️ -1500
  • 47.7
  • 1000000
ushort Any integer between 0 and 65535 inclusive
  • ✔️ 50
  • ✔️ 65535
  • -10
  • 47.7
  • 100000
int Any integer between -2147483648 and 2147483647 inclusive
  • ✔️ 50
  • ✔️ 32767
  • ✔️ -1500
  • 47.7
  • 10000000000
uint Any integer between 0 and 4294967295 inclusive
  • ✔️ 50
  • ✔️ 65535
  • -3
  • 47.7
long Any integer between -9223372036854775808 and 9223372036854775807 inclusive
  • ✔️ 281231
  • ✔️ 32767
  • ✔️ -15030
  • 47.7
ulong Any integer between 0 and 18446744073709551615 inclusive
  • ✔️ 50
  • ✔️ 65535
  • -3
  • 47.7
float A decimal value in the range ±1.5 x 10−45 to ±3.4 x 1038
  • ✔️ 10
  • ✔️ -71.1023
double A decimal value in the range ±5.0 × 10−324 to ±1.7 × 10308
  • ✔️ 10
  • ✔️ -71.1023
decimal A high-precision decimal value in the range ±1.0 x 10-28 to ±7.9228 x 1028
  • ✔️ 10
  • ✔️ -71.1023
bool A boolean value
  • ✔️ TRUE
  • ✔️ f
  • ✔️ 1
Value can be any one of the following (case-insensitive): {true, false, T, F, 1, 0}

Unity types

Parameter Type                     Format                                     Examples                 Notes (if any)
Vector2 (x y)[1]
  • ✔️ (5, 6)
  • ✔️ [10.5 -4]
  • ✔️ (0, 0)
  • (a, b)
  • (1 2 3)
Vector2Int (x y)[1]
  • ✔️ (5, 6)
  • ✔️ [10 -4]
  • ✔️ (0, 0)
  • (4.0, 1.2)
  • (1 2 3)
  • (foo, bar)
Vector3 (x y z=0.0)[1]
  • ✔️ (5, 6, 7)
  • ✔️ [10.5 -4]
  • (a, b)
  • (1 2 3 4)
Third argument, z, is optional and will be set to zero if unspecified.
Vector3Int (x y z=0)[1]
  • ✔️ (5, 6, 7)
  • ✔️ [10 -4]
  • (a, b)
  • (1 2 3 4)
  • (1.3 2.0 4.5)
Third argument, z, is optional and will be set to zero if unspecified.
Vector4 (x y z=0.0 w=0.0)[1]
  • ✔️ (5, 6, 7, 8)
  • ✔️ [10.5 -4 1.2]
  • ✔️ [10.5 -4]
  • (a, b, c)
  • (1 2 3 4 5)
  • (1)
Third and fourth arguments (z, w) are optional and will be set to zero if unspecified. For instance, (1 2) is equivalent to (1 2 0 0) and (1 2 3) is equivalent to (1 2 3 0).
Quaternion

(x y z w)[1]

(xDeg yDeg zDeg)[1]

  • ✔️ (0.2 0.5 0.0 0.1)
  • ✔️ [45, 90, 270]
  • (1 2 3 4 5)
  • (1)
Two versions of this parameter type may be provided. The first, (x y z w), relies on manipulating quaternion components and is not intuitive. The second, (xDeg yDeg zDeg), takes a rotation in degrees about the x-, y-, and z-axes and returns the result of Quaternion.Euler. Using the three argument version of Quaternion is recommended.
Color (r g b a=1.0)[1]
  • ✔️ (0.5 0.2 0.8 0.4)
  • ✔️ [0.3 0 0.1]
  • [0.2 0.4]
  • (a, b, c)
  • (1.3 0.2 -0.4 5.4)
If a (alpha) is not provided, will be set to 1.0. All components must be in the range [0.0, 1.0].
Color32 (r g b a=255)[1]
  • ✔️ (50 32 24)
  • ✔️ [0 0 255 75]
  • [50 100.4 50]
  • (-5 5 50 -200)
If a (alpha) is not provided, will be set to 255. All components must be integer values in the range [0, 255].

Generic Types and Collections [2]

Parameter Type                     Format                                  Examples              Notes (if any)
T?
Nullable<T>
T
  • ✔️ 5.0 (int?)
  • ✔️ (5.4 2 0.5) (Vector3?)
T must be a non-nullable value type (such as int or Vector3). T? uses the same formatting rules as T. For instance, if T is Vector3, uses the formatting rules for Vector3.
T[]
IEnumerable<T>
List<T>
IList<T>
IReadOnlyList<T>
ICollection<T>
IReadOnlyCollection<T>
[T0 T1 ... Tn][1]
  • ✔️ [1 2 3] (int[])
  • ✔️ (foo, bar, "foz baz") (string[])
T0, T1, …, Tn are instances of T and must obey the format rules of T. Empty collections may be designated using [] or ().
Queue<T> Same as T[]
  • ✔️ [1 2 3] (Queue<int>)
  • ✔️ (foo, bar, "foz baz") (Queue<string>)
Elements that are parsed first will be situated at the front of the queue. For instance, if [T0 T1 T2] was parsed, T0 would be the first element to be dequeued by calling Queue<T>.Dequeue()
Stack<T> Same as T[]
  • ✔️ [1 2 3] (Stack<int>)
  • ✔️ (foo, bar, "foz baz") (Stack<string>)
Elements that are parsed last will be situated at the top of the stack. For instance, if [T0 T1 T2] was parsed, T2 would be the first element to be popped by calling Stack<T>.Pop()
HashSet<T>
ISet<T>
{T0 T1 ... Tn}
  • ✔️ {1 2 3} (HashSet<int>)
  • ✔️ {foo, foo, bar, "foz baz"} (ISet<string>)
T0, T1, …, Tn are instances of T and must obey the format rules of T. Sets are surrounded by braces (e.g. { and }) and elements may optionally be separated by commas. Duplicate or leading and trailing commas are not allowed. Empty sets may be denoted by {}. Duplicate elements are flattened in the final result; for instance, {T0 T1 T1 T2} will produce a result equivalent to new HashSet<int>() {T0, T1, T2}
KeyValuePair<TKey,TValue> TKey: TValue
  • ✔️ "key": "value" (KeyValuePair<string,string>)
  • ✔️ 1: (2 3) (KeyValuePair<int, Vector2>)
TKey and TValue must obey the format rules of TKey and TValue, respectively. Keys and values must be separated by a colon.
Dictionary<TKey,TValue>
IDictionary<TKey,TValue>
IReadOnlyDictionary<TKey,TValue>
{K0: V0 K1: V1 ... Kn: Vn}
  • ✔️ {key1: value1 key2: value2} (Dictionary<string,string>)
  • ✔️ {0: "foo", 1: "bar"} (Dictionary<int,string>)
  • {0: "foo", 0: "bar"} (Dictionary<int,string>)
Dictionaries are surrounded by braces (e.g. { and }) and constitute an enumeration of key-value pairs. K0, K0, …, Kn are instances of TKey and must obey the format rules of TKey. V0, V0, …, Vn are instances of TValue and must obey the format rules of TValue. Key-value pairs may be optionally separated by commas. Duplicate or leading and trailing commas are invalid. Additionally, a single key may not appear more than once in a given dictionary. Empty dictionaries may be denoted by {}.
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)


ValueTuple<T0>
ValueTuple<T0, T1>
ValueTuple<T0, T1, T2>


Tuple<T0>
Tuple<T0, T1>
Tuple<T0, T1, T2>
(T0)
(T0 T1)
(T0 T1 T2)
...[1]
  • ✔️ (a 5.0) ((char,float))
  • ✔️ [5 "hello world"] (ValueTuple<int, string>)
  • ✔️ (foo, bar, TRUE) (Tuple<string, string, bool>)
A tuple containing n elements.