Sequence of objects in locals

Hi,
Should it be possible to display sequences returned from methods in the debugger ?

For example with this code

namespace ListConsoleApplication;

uses
System.Collections.Generic,
System.Linq;

type

Employee = public class
public
property Id:Integer;
end;

Program = class
public
class method Main(args: array of String): Int32;
begin
var objs := ProduceList;
if(assigned(objs))then
begin

  end;
end;

class method ProduceList:sequence of Employee;
begin
  var items := new List<Employee>;
  items.Add(new Employee(Id:=1));
  items.Add(new Employee(Id:=2));
  items.Add(new Employee(Id:=3));
  exit items;
end;

end;

If I set a breakpoint on the line after the ProduceList call, it doesnt show the rows assigned in locals.

If I change the method to List then it does.

Cheers,
John

well, a sequence (a) could be infinitely long and (b) might. it be safe to re-execute without side effects (think database query), so the debugged cant just show it. calling ToList in the sequence should evaluate ok…

Yes but could I have the option to expand it like in visual studio ?

What would happen if you expand an infinite sequence?

I think my machine would have hung before i even got the chance to expand. It should be up to the person debugging.

I was in the middle of debugging some database calls and I just wanted to see what was returned. To do that I have to stop the debugging session change the code and repeat.

Ok, but what’s wring with just doing a .ToList?

It interrupts the flow of my debugging session.

FWIW, I didn’t mean to change the code, I meant to eval .ToList in a watch…

But anyways, I’ll log an issue and let you and Carlo fight it out :wink:

Thanks, logged as bugs://81876

Oh. How would I do that. I know I can add watch from the selection but how do I add my own code ?

just do “add watch” and add a custom expression…

It just comes up with a popup that asks for the name48%20PM

yes?

I hit add watch and it doesnt seem to do anything

Hmm, for me it adds a Watch to the Watches pane… :woman_shrugging:t3:

Is name the name of the expression or the expression itself ? It does appear to do anything, I already had a watch on the sequence

well. add ToList, obviously. So of your sequence (lets say a local var) is called mySequence, you’d add a watch for “mySequence.ToList()”?

Could you rename “name” to something like “expression” ?TaskResultConsoleApplication.zip (134.6 KB)

with the attached I get

not sure i follow…?

  1. The employees.ToList doesnt appear to work, see diagram
  2. In the UI could you rename “name” to “expression”