Search code examples
c#visual-studio-2013visual-studio-addins

Expression2.MakeObjectID doesn't return a value- how can I obtain the new object id?


The Expression2.MakeObjectID method creates a debug object ID, just like right-clicking a value in the debugger and selecting 'Make Object ID.'

I would like to be able to get that ID (such as 1#, 2#, 3#) for the expression and display it. Expression2.Name, .Type and .Value do not return the ID. Debugger5.ExecuteStatement(expression.Name) prints the expression's value and ID to the command window but I don't know how to read from that window, and I'd rather not write in it. There has to be a way to evaluate a statement and have it return the result instead of printing it to a window.

Does anyone know what steps I might take next?


Solution

  • Aha! Debugger.GetExpression and Debugger5.GetExpression act differently.

    If I reobtain the same expression using Debugger5, the {1#} is appended to the Expression.Value.