consider this simple code
{$APPTYPE CONSOLE}
uses
Rtti,
SysUtils;
type
{$M+}
TFoo = class
strict private
class var Field1 : Integer;
field2 : Integer;
private
field3 : Integer;
class var Field4 : Integer;
end;
Var
ctx : TRttiContext;
f : TRttiField;
begin
try
ctx:=TRttiContext.Create;
for f in ctx.GetType(TFoo).GetFields do
Writeln(f.Name);
Writeln('Done');
readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
When you run this, only the field3
is listed. it seems which the RTTI does not support fields which are strict private
or class var
, So the questions are Is possible access a strict private field of a delphi class using Rtti or another method?
and I read the documentation of the RTTI.TRttiType.GetFields method but does mention these restrictions, Exist any paper or article which mentions such limitations?