Tostis 0 Posted August 25, 2022 I can't understand how I can inspect variable content when debugger is stopped due to breakpoint. Local variable window shows testvar but I cannot see the content of FSampleField and FInnerField.FOtherField. Am I doing something wrong? unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; type IInner = interface procedure setOtherField(b: integer); end; type TInner = class(TInterfacedObject, IInner) private var FOtherField: integer; procedure setOtherField(b: integer); end; type ITest = interface procedure setSampleField(a: string); procedure setInnerField(b: IInner); end; type TTest = class(TInterfacedObject, ITest) private var FSampleField: string; private var FInnerField: IInner; procedure setSampleField(a: string); procedure setInnerField(b: IInner); end; implementation {$R *.dfm} procedure TTest.setSampleField(a: string); begin FSampleField:= a; end; procedure TTest.setInnerField(b: IInner); begin FInnerField:= b; end; procedure TInner.setOtherField(b: Integer); begin FOtherField:= b; end; procedure TForm1.Button1Click(Sender: TObject); begin var testInnerVar: IInner:= TInner.Create(); testInnerVar.setOtherField(55); var testvar: ITest:= TTest.Create(); testvar.setSampleField('avalue'); testvar.setInnerField(testInnerVar); end; end. Share this post Link to post
ULIK 16 Posted August 25, 2022 That's because testvar is of type ITest and not TTest that contains the member fields. Share this post Link to post
Tostis 0 Posted August 25, 2022 So if I want to debug propertly I should give up on using interface reference counting and destroy all objects by myself? Share this post Link to post
Fr0sT.Brutal 900 Posted August 25, 2022 5 minutes ago, Tostis said: So if I want to debug propertly I should give up on using interface reference counting and destroy all objects by myself? Welcome to the house of interface pain. Hint: you can evaluate intf's methods Share this post Link to post
Tostis 0 Posted August 25, 2022 Evaluating expression into watch list is not so useful. It isn't feasible to watch collections of intefaces containing interfaces ecc... Can you give some best pratices for debugging code? Should I avoid interfaces? Are there plugin for RAD that can help me? Share this post Link to post
Uwe Raabe 2057 Posted August 25, 2022 54 minutes ago, Tostis said: I should give up on using interface reference counting and destroy all objects by myself? Are you trying to say, you are using interfaces only to avoid being responsible for destroying your object instances? Share this post Link to post
Fr0sT.Brutal 900 Posted August 25, 2022 25 minutes ago, Tostis said: Evaluating expression into watch list is not so useful. It isn't feasible to watch collections of intefaces containing interfaces ecc... Can you give some best pratices for debugging code? Should I avoid interfaces? Are there plugin for RAD that can help me? You can write your own debugger visualizer Share this post Link to post
Tostis 0 Posted August 25, 2022 17 minutes ago, Uwe Raabe said: Are you trying to say, you are using interfaces only to avoid being responsible for destroying your object instances? I'm using interfaces because I have various implementations of the same class, too. Share this post Link to post
Tostis 0 Posted August 25, 2022 16 minutes ago, Fr0sT.Brutal said: You can write your own debugger visualizer I'll evaluate how does it take before starting to develop my own debugger. Share this post Link to post