Jump to content
Stefan Glienke

Creating sub nodes with debugger visualizer

Recommended Posts

I know how to write a debugger visualizer and how to use the IOTADebuggerVisualizerValueReplacer.

 

What I want to achieve is creating sub nodes with values like you get when you have a dynamic array, a record or an object.

However the mentioned interface only provides a method to produce a string which is printed but no way to produce some kind of sub structure.

 

I also know about IOTADebuggerVisualizerExternalViewer as being used for TStrings where you can click on the magnifier icon to open up another window but that is not what I would like to have.

 

I am looking for a way to dynamically create sub entries for some type which seems to be beyond the capabilities of the ToolsAPI.

But we have some people that know a bit about the internals of the IDE any maybe someone is able to find a way to achieve this.

 

To illustrate this.

 

uses
  System.Generics.Collections,
  Spring.Collections;
procedure Main;
var
  arr: TArray<Integer>;
  listA: TList<Integer>;
  listB: IList<Integer>;
begin
  arr := [1, 2, 3];
  listA := TList<Integer>.Create;
  listA.AddRange(arr);
  listB := TCollections.CreateList<Integer>(arr);
end;

I get this in the local variables view (this is from 10.4.2 where visualizers for TList<T> and alike were added):

 

image.thumb.png.7c5123f4573c9e413c50e8adfae027f5.png

 

When the debugger sees a dynamic array type it shows the elements as sub nodes - thus you can "cheat" the watches:

 

image.thumb.png.96a279c6efab5fd1c996f4288af634a2.png

 

So what I would like to see is the expand icon on my listB and then the elements in the list in sub nodes just like in dynamic array.

Share this post


Link to post

Never tried it myself, but I suspect that you just need to return a string with specific format. Such as "(3, 5, 7)" to show value as array with child elements. Or like "(PropA: 3; PropB: 5)" to show as object with child properties. I may be wrong, of course.

 

Do you looked at the source code of TDebuggerListHelperVisualizer.GetReplacementValue?

 

 

Share this post


Link to post
Posted (edited)

Also, I've noticed that the strings are different in code editor drop-down and in local variables view:

 

image.thumb.png.e1a5744bebdb68f3da67b121f3d35d06.png

 

String in code editor drop-down seems to be more complete (like it should be returned from GetReplacementValue). While the string in local variables view seems to be already processed by IDE.

 

 

Edited by balabuev

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×