即使给定的类是用正确的 {$METHODINFO} 指令声明的,GetPropInfo 是否有可能返回 nil。
type
...
...
{$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;