Gotcha! The problem seems to be hidden in the statement I missed. I did not know this insightful trait.
It seems the compiler only considers the first declaration of the class to generate RTTI or not if you have a direct declaration like this ...
type
TMyClass = class;
...
...
{$METHODINFO ON}
TMyClass = class
private
fField: integer;
published
property Field: integer read fField write fField;
end;
{$METHODINFO OFF}
...
...
procedure TestRTTI;
begin
assert(assigned(GetPropInfo(TMyClass, 'Field')), 'WTF! No RTTI found!');
end;
... you will receive an approval error. So, to obtain RTTI rights, you need to include the {$ METHODINFO} directive for forward declaration, as shown here.
type
{$METHODINFO ON}
TMyClass = class;
{$METHODINFO OFF}
...
...
TMyClass = class
private
fField: integer;
published
property Field: integer read fField write fField;
end;
...
source
share