How can I get the properties of a class using RTTi?

How can I get the properties of a class using RTTi?

Could you please give an example?

Hi,
typeinfo returns a pointer. If you put an asm debugger on the next line you can view the content ti points to in Chrome.

var
ti: Pointer;
begin
ti := typeinfo(TForm1);
asm
debugger;
end;

My project doesn't compile when I declare this typeinfo class.

Please @TMS could help me, I have my project stopped, I need to get the properties of a class via RTTI, is there any complete example of how to get the attributes, methods, properties.

Another detail, the TDictionary class of the Unit Generics.Collection does not work when I declare in my project, an error occurs in the Generics.Collection class

var
  PropList  : TTypeMemberPropertyDynArray;
begin
  PropList := GetPropList(WebButton1);
  for p in PropList do
  begin
    console.log(p.TypeInfo.Name);
  end;
end;

This TTypeMemberPropertyDynArray class belongs to which Unit?

The context I get like this?

var
Context: TRttiContext;
Type: TRttiType;
begin
Context := TRttiContext.Create;
Type := Context.GetType(TECompany);

Delphi doesn't want to recognize the TTypeMemberPropertyDynArray class of the TypInfo unit, it is considering Delphi's native TypInfo class and not WebCore's

Unit: TypInfo

pas2js supports regular RTTI not Delphi extended RTTI.
The code is to be used as I provided it in my answer.

I can only get properties from an object, can't I from a type TClass?

Do you have a complete example to get the information of Properties, Attributes, Methods from a class and not from an instantiated object?

This class of mine doesn't list my properties

TEMPRESA = class
private
PERSON_FID: Integer;
FCPF_CNPJ_MATRIZ: String;
FANTASIA_MATRIZ: String;
FID: Int64;
FID_MATRIZ: Integer;
FCPF_CNPJ_PERSON: String;
FANTASIA_PERSON: String;
public
property ID: Int64 read FID write FID;
property ID_PESSOA: Integer read FID_PESSOA write FID_PESSOA;
property FANTASIA_PESSOA: String read FFANTASIA_PESSOA write FFANTASIA_PESSOA;
property CPF_CNPJ_PESSOA: String read FCPF_CNPJ_PESSOA write FCPF_CNPJ_PESSOA;
property ID_MATRIZ: Integer read FID_MATRIZ write FID_MATRIZ;
property FANTASIA_MATRIZ: String read FFANTASIA_MATRIZ write FFANTASIA_MATRIZ;
property CPF_CNPJ_MATRIZ: String read FCPF_CNPJ_MATRIZ write FCPF_CNPJ_MATRIZ;
end;

This shows what is currently possible with pas2js RTL for custom classes

uses
  rtti;

type
  TMyClass = class
  private
    FMyProp: integer;
  published
    property MyProp: Integer read FMyProp write FMyProp;
  end;

procedure TForm1.WebButton1Click(Sender: TObject);
var
  ctx: TRTTIContext;
  rt: TRTTIType;
  pa: TRttiPropertyArray;
  pr: TRttiProperty;

begin
  ctx := TRTTIContext.Create;
  rt := ctx.GetType(TMyClass);

  pa := rt.GetProperties;

  for pr in pa do
  begin
    console.log(pr.Name);
  end;
  ctx.Free;
end;