You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a tobjectlist in Delphi 11.2 ( it seems this goes back to 10.4) , causes an "Parameter count mismatch" exception message.
This does not happen in 10.2
Only way to fix this as I am dumb at RTTI and such was to modify this code to not pass any arguments.
This means I need to write some extra code to flip on "ownsobjects" after my JSON to object creation is made.
`class function TSerializeParse.IsGenerics(Cls: TRttiType): Boolean;
var
C: TClass;
Mtd: TRttiMethod;
Info: TGenericsInfo;
Gt: TGenericsType;
begin
Result := false;
C := Cls.AsInstance.MetaclassType;
if FGenericsCache.TryGetValue(C, Info) then
Exit(Info.IsGeneric);
if C.UnitName = GenericsUnit then
begin
Gt := GetGenericType(C);
if Gt in [gtList, gtObjectList] then
begin
Mtd := Cls.GetMethod('First');
if (Mtd <> Nil) and (Mtd.MethodKind = mkFunction) then
begin // TList<> or TObjectList<>
Info := TGenericsInfo.Create(C, True, Mtd.ReturnType);
if Gt = gtObjectList then
begin
{$IF CompilerVersion > 25} // 10.4 + breaks this
SetLength(Info.CreateArgs, 0); // for now, you must own your objects
// Info.CreateArgs[0] := True; // commented out since length is zero now
{$else}
SetLength(Info.CreateArgs, 1); // do things like always if below 10.4
Info.CreateArgs[0] := True;
{$endif}
end;
FGenericsCache.Add(C, Info);
Exit(True);
end
end;
end;
end;`
The text was updated successfully, but these errors were encountered:
Using a tobjectlist in Delphi 11.2 ( it seems this goes back to 10.4) , causes an "Parameter count mismatch" exception message.
This does not happen in 10.2
Only way to fix this as I am dumb at RTTI and such was to modify this code to not pass any arguments.
This means I need to write some extra code to flip on "ownsobjects" after my JSON to object creation is made.
`class function TSerializeParse.IsGenerics(Cls: TRttiType): Boolean;
var
C: TClass;
Mtd: TRttiMethod;
Info: TGenericsInfo;
Gt: TGenericsType;
begin
Result := false;
C := Cls.AsInstance.MetaclassType;
if FGenericsCache.TryGetValue(C, Info) then
Exit(Info.IsGeneric);
if C.UnitName = GenericsUnit then
begin
Gt := GetGenericType(C);
if Gt in [gtList, gtObjectList] then
begin
Mtd := Cls.GetMethod('First');
if (Mtd <> Nil) and (Mtd.MethodKind = mkFunction) then
begin // TList<> or TObjectList<>
Info := TGenericsInfo.Create(C, True, Mtd.ReturnType);
if Gt = gtObjectList then
begin
{$IF CompilerVersion > 25} // 10.4 + breaks this
SetLength(Info.CreateArgs, 0); // for now, you must own your objects
// Info.CreateArgs[0] := True; // commented out since length is zero now
{$else}
SetLength(Info.CreateArgs, 1); // do things like always if below 10.4
Info.CreateArgs[0] := True;
{$endif}
end;
FGenericsCache.Add(C, Info);
Exit(True);
end
end;
end;
end;`
The text was updated successfully, but these errors were encountered: