Hi,
We have implemented a custom language through a Visual Studio 2012 C# extension that we basically use to generate C++ code and build/run/debug like any C++ code (so no LanguageService was implemented, only a new content type was required). However, to be able to debug step by step in our language files, we insert a bunch of “#line” instructions throughout the generated cpp files to indicate the matching lines in the original file.
To allow our users to use the debugger features without necessarily knowing the cpp file generation process, we would like to apply some transformations to the expressions evaluated in the watch before sending those expressions to the C++ expression evaluator. For example, since we are always generating global c++ functions with a first parameter named thisPtr, we would like to transform an expression such as “m_myField” that is valid in our custom language into “thisPtr->m_myField” so that the C++ expression evaluator can evaluate it (since this form is valid in our generated cpp files). Another example is that our language doesn’t use the “->” operator and always uses the “.” operator instead (in a C# fashion), so an expression like “myRef.m_memberName” should be transformed into “myRef->m_memberName”.
We thought about a few potential approaches:
1- Register a custom ExpressionEvaluator that handles C++ expression evaluation. This does not seem to be possible. From what I understand, it appears that I need to provide a full stack of classes implementing the following interfaces in order to provide an expression evaluator (IDebugEngine2 / IDebugProcess3 / … / IDebugStackFrame2 / IDebugExpressionContext2 / IDebugExpression2) and then I doubt that I would be able to forward calls that I don’t want to handle to the built-in C++ evaluator.
2- Intercept the Visual Studio command AddWatch to apply a few transformations to the currently selected string before adding it to the Watch window. On top of the fact that this approach would not work when you edit manually the expression already in the watch, we cannot even implement it since there is no API to add an arbitrary string to the watch window.
Any of you can make one of our approaches work or suggest another solution (beside a new distinct watch window for our language…) ?
Thank you very much for your help