Expression evaluator implementation strategy
Applies to: Visual Studio Visual 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.
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 is 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 must 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 Display locals for more details.