Writing a common language runtime 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

Important

In Visual Studio 2015, this way of implementing expression evaluators is deprecated. For information about implementing CLR expression evaluators, see CLR expression evaluators and Managed expression evaluator sample.

The expression evaluator (EE) is the part of a debug engine (DE) that handles the syntax and semantics of the programming language that produced the code being debugged. Expressions must be evaluated within the context of a programming language. For example, in some languages, the expression "A+B" means "the sum of A and B." In other languages, the same expression might mean "A or B." Thus, a separate EE must be written for each programming language that generates object code to be debugged in the Visual Studio IDE.

Some aspects of the Visual Studio debug package must interpret the code in the context of the programming language. For example, when execution halts at a breakpoint, any expressions that the user has typed into a Watch window must be evaluated and displayed. The user can change the value of a local variable by typing an expression into a Watch window or into the Immediate window.

In this section

Common language runtime and expression evaluation Explains that when you are integrating proprietary programming language into the Visual Studio IDE, writing an EE capable of evaluating expressions within the context of the proprietary language allows you to compile to a Microsoft intermediate language (MSIL) without writing a debug engine.

Expression evaluator architecture Discusses how to implement the required EE interfaces and call the common language runtime symbol provider (SP) and binder interfaces.

Register an expression evaluator Notes that the EE must register itself as a class factory with both the common language runtime and Visual Studio runtime environments.

Implement an expression evaluator Describes how the process of evaluating an expression includes the debug engine (DE), the symbol provider (SP), the binder object, and the expression evaluator (EE).

Display locals Describes how, when execution pauses, the debug package calls the DE to get a list of local variables and arguments.

Evaluate a watch window expression Documents how the Visual Studio debug package calls the DE to determine the current value of each expression in its watch list.

Change the value of a local Explains that in changing the value of a local, each line of the Locals window has an associated object that provides the name, type, and current value of a local.

Implement type visualizers and custom viewers Explains which interface needs to be implemented by which component to support type visualizers and custom viewers.

See also

Visual Studio debugger extensibility