Edit

Share via


DebugView syntax (expression trees)

The DebugView property (available only when debugging) provides a string rendering of expression trees. Most of the syntax is fairly straightforward to understand; the special cases are described in the following sections.

Each example is followed by a comment block containing the DebugView.

ParameterExpression

ParameterExpression variable names are displayed with a "$" symbol at the beginning.

If a parameter does not have a name, it is assigned an automatically generated name, such as $var1 or $var2.

Examples

Dim numParam As ParameterExpression = Expression.Parameter(GetType(Integer), "num")
'
'    $num
'

Dim numParam As ParameterExpression = Expression.Parameter(GetType(Integer))
'
'    $var1
'

ConstantExpressions

For ConstantExpression objects that represent integer values, strings, and null, the value of the constant is displayed.

For some numeric types, a suffix is added to the value:

Type Keyword Suffix
System.UInt32 UInteger U
System.Int64 Long L
System.UInt64 ULong UL
System.Double Double D
System.Single Single F
System.Decimal Decimal M

Examples

Dim num as Integer = 10
Dim expr As ConstantExpression = Expression.Constant(num)
'
'    10
'

Dim num As Double = 10
Dim expr As ConstantExpression = Expression.Constant(num)
'
'    10D
'

BlockExpression

If the type of a BlockExpression object differs from the type of the last expression in the block, the type is displayed within angle brackets (< and >). Otherwise, the type of the BlockExpression object is not displayed.

Examples

Dim block As BlockExpression = Expression.Block(Expression.Constant("test"))
'
'    .Block() {
'        "test"
'    }
'

Dim block As BlockExpression = Expression.Block(
    GetType(Object),
    Expression.Constant("test")
)
'
'    .Block<System.Object>() {
'        "test"
'    }
'

LambdaExpression

LambdaExpression objects are displayed together with their delegate types.

If a lambda expression does not have a name, it is assigned an automatically generated name, such as #Lambda1 or #Lambda2.

Examples

Dim lambda As LambdaExpression = Expression.Lambda(Of Func(Of Integer))(
    Expression.Constant(1)
)
'
'    .Lambda #Lambda1<System.Func'1[System.Int32]>() {
'        1
'    }
'

Dim lambda As LambdaExpression = Expression.Lambda(Of Func(Of Integer))(
    Expression.Constant(1),
    "SampleLambda",
    Nothing
)
'
'    .Lambda #SampleLambda<System.Func'1[System.Int32]>() {
'        1
'    }
'

LabelExpression

If you specify a default value for the LabelExpression object, this value is displayed before the LabelTarget object.

The .Label token indicates the start of the label. The .LabelTarget token indicates the destination of the target to jump to.

If a label does not have a name, it is assigned an automatically generated name, such as #Label1 or #Label2.

Examples

Dim target As LabelTarget = Expression.Label(GetType(Integer), "SampleLabel")
Dim label1 As BlockExpression = Expression.Block(
    Expression.Goto(target, Expression.Constant(0)),
    Expression.Label(target, Expression.Constant(-1))
)
'
'    .Block() {
'        .Goto SampleLabel { 0 };
'        .Label
'            -1
'        .LabelTarget SampleLabel:
'    }
'

Dim target As LabelTarget = Expression.Label()
Dim block As BlockExpression = Expression.Block(
    Expression.Goto(target),
    Expression.Label(target)
)
'
'    .Block() {
'        .Goto #Label1 { };
'        .Label
'        .LabelTarget #Label1:
'    }
'

Checked Operators

Checked operators are displayed with the # symbol in front of the operator. For example, the checked addition operator is displayed as #+.

Examples

Dim expr As Expression = Expression.AddChecked(
    Expression.Constant(1),
    Expression.Constant(2)
)
'
'     1 #+ 2
'

Dim expr As Expression = Expression.ConvertChecked(
    Expression.Constant(10.0),
    GetType(Integer)
)
'
'    #(System.Int32)10D
'