Expression Evaluator Implementation Strategy

Note

This article applies to Visual Studio 2015. 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, please see CLR Expression Evaluators and Managed Expression Evaluator Sample.

One approach to rapidly creating an expression evaluator (EE) is to first implement the minimum code necessary to display local variables in the Locals window. It is useful to realize that each line in the Locals window displays the name, type, and value of a local variable, and that all three are represented by an IDebugProperty2 object. The name, type, and value of a local variable can be obtained from an IDebugProperty2 object by calling its GetPropertyInfo method. For more information about how to display local variables in the Locals window, see Displaying Locals.

Discussion

A possible implementation sequence starts with implementing IDebugExpressionEvaluator. The Parse and the GetMethodProperty methods need to be implemented to display locals. Calling IDebugExpressionEvaluator::GetMethodProperty returns an IDebugProperty2 object that represents a method: that is, an IDebugMethodField object. Methods themselves are not displayed in the Locals window.

The EnumChildren method should be implemented next. The debug engine (DE) calls this method to get a list of local variables and arguments by passing IDebugProperty2::EnumChildren a guidFilter argument of guidFilterLocalsPlusArgs. IDebugProperty2::EnumChildren calls EnumArguments and EnumLocals, combining the results in a single enumeration. See Displaying Locals for more details.

See Also

Implementing an Expression Evaluator
Displaying Locals