Expression evaluator

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Expression evaluators (EE) examine the syntax of a language to parse and evaluate variables and expressions at run time, allowing them to be viewed by the user when the IDE is in break mode.

Use expression evaluators

Expressions are created using the ParseText method, as follows:

  1. The debug engine (DE) implements the IDebugExpressionContext2 interface.

  2. The debug package gets an IDebugExpressionContext2 object from an IDebugStackFrame2 interface and then calls the IDebugStackFrame2::ParseText method on it to get an IDebugExpression2 object.

  3. The debug package calls the EvaluateSync method or the EvaluateAsync method to get the value of the expression. IDebugExpression2::EvaluateAsync is called from the Command/Immediate window. All other UI components call IDebugExpression2::EvaluateSync.

  4. The result of expression evaluation is an IDebugProperty2 object, which contains the name, type, and value of the result of the expression evaluation.

    During expression evaluation, the EE requires information from the symbol provider component. The symbol provider supplies the symbolic information used for identifying and understanding the parsed expression.

    When asynchronous expression evaluation completes, an asynchronous event is sent by the DE through the session debug manager (SDM) to notify the IDE that expression evaluation is complete. And, the result of the evaluation is then returned from the call to the IDebugExpression2::EvaluateSync method.

Implementation notes

The Visual Studio debug engines expect to talk with the expression evaluator using Common Language Runtime (CLR) interfaces. As a result, an expression evaluator that works with the Visual Studio debug engines must support the CLR (a complete list of all CLR debugging interfaces can be found in debugref.doc, which is part of the Windows Software Development Kit (SDK)).

See also