Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TObjectList usage causes "Parameter count mismatch" with Delphi 10.4 and higher. #152

Open
jdredd87 opened this issue May 2, 2023 · 0 comments

Comments

@jdredd87
Copy link

jdredd87 commented May 2, 2023

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;`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant