I use Delphi 10.3.1 COMMUNITY version and can't look into generic tList while I debug the project.
I know the latest version of Delphi doesn't support the old-typed debug feature which allows to look into generic tList. So I used tList.List in the following code to evaluate the tList.
In tList<tRecord>.List
I can look into it but can't do it in tList<Integer>.List
.
type
tRecord = record
Field: Integer;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
_Record: tRecord;
_List1: TList<tRecord>;
_List2: TList<Integer>;
i: Integer;
begin
_List1 := TList<tRecord>.Create;
_List2 := TList<Integer>.Create;
for i := 0 to 4 do
begin
_Record.Field := i;
_List1.Add(_Record);
_List2.Add(i);
end;
Caption := IntToStr(_List1.List[0].Field) + IntToStr(_List2.List[0]);
_List1.Free;
_List2.Free;
end;
How can I look into tList<Integer>
during the debugging?
Usually it should be possible to see the lists contained array over the List
property. Internally there is only a field of type Pointer
unlike before 10.3 when it was of type TArray<T>
.
This is what I see when I put a breakpoint into the line where it assigns to Caption
and put those two entries into my watches:
Update: It looks like the Linker is responsible for the issue you are experiencing here. When you uncheck the option to "allow side effects and function calls" in the watch
the watch window will show this:
I have seen this behavior before when using generics that are only specified in the implementation part of the unit (FWIW when I tried to repro this the first time I did not put the code you posted into a VCL project but into a console dpr and that one does not have an implementation part so I did not see this behavior).
To force the linker to not to remove the symbol or the debugger to actually see it (because even if I disable inlining to force the GetList method to stay the watch window will tell me that it got removed) you can simply put some dummy type into the interface
part of this or any other unit.
type TDummy = TList<Integer>;
This will cause the debugger to see the symbol and see the values in the watches window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With