Skip to content

Commit

Permalink
C# Fix deserialization of delegates that are 0-parameter overloads
Browse files Browse the repository at this point in the history
Co-authored-by: Raul Santos <raulsntos@gmail.com>
  • Loading branch information
mattdiener and raulsntos committed Jun 30, 2023
1 parent 4642448 commit 783facf
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions modules/mono/glue/GodotSharp/GodotSharp/Core/DelegateUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,24 +500,17 @@ private static bool TryDeserializeMethodInfo(BinaryReader reader,
Type? returnType = hasReturn ? DeserializeType(reader) : typeof(void);

int parametersCount = reader.ReadInt32();
var parameterTypes = parametersCount == 0 ? Type.EmptyTypes : new Type[parametersCount];

if (parametersCount > 0)
for (int i = 0; i < parametersCount; i++)
{
var parameterTypes = new Type[parametersCount];

for (int i = 0; i < parametersCount; i++)
{
Type? parameterType = DeserializeType(reader);
if (parameterType == null)
return false;
parameterTypes[i] = parameterType;
}

methodInfo = declaringType.GetMethod(methodName, (BindingFlags)flags, null, parameterTypes, null);
return methodInfo != null && methodInfo.ReturnType == returnType;
Type? parameterType = DeserializeType(reader);
if (parameterType == null)
return false;
parameterTypes[i] = parameterType;
}

methodInfo = declaringType.GetMethod(methodName, (BindingFlags)flags);
methodInfo = declaringType.GetMethod(methodName, (BindingFlags)flags, null, parameterTypes, null);
return methodInfo != null && methodInfo.ReturnType == returnType;
}

Expand Down

0 comments on commit 783facf

Please sign in to comment.