Skip to content

Commit

Permalink
Handle properties with only different parameter types in Pass80Unstri…
Browse files Browse the repository at this point in the history
…pMethods::GetOrCreateProperty (#91)
  • Loading branch information
krulci authored Jul 26, 2023
1 parent 876e0f0 commit 441577f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Il2CppInterop.Generator/Passes/Pass80UnstripMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ private static PropertyDefinition GetOrCreateProperty(MethodDefinition unityMeth
unityMethod.DeclaringType.Properties.Single(
it => it.SetMethod == unityMethod || it.GetMethod == unityMethod);
var newProperty = newMethod.DeclaringType.Properties.SingleOrDefault(it =>
it.Name == unityProperty.Name && it.Parameters.Count == unityProperty.Parameters.Count);
it.Name == unityProperty.Name && it.Parameters.Count == unityProperty.Parameters.Count &&
it.Parameters.SequenceEqual(unityProperty.Parameters, new TypeComparer()));
if (newProperty == null)
{
newProperty = new PropertyDefinition(unityProperty.Name, PropertyAttributes.None,
Expand Down Expand Up @@ -228,4 +229,23 @@ private static PropertyDefinition GetOrCreateProperty(MethodDefinition unityMeth

return newType;
}

//Stolen from: https://github.com/kremnev8/Il2CppInterop/blob/2c4a31f95f8aa6afe910aca0f8044efb80259d20/Il2CppInterop.Generator/Passes/Pass11ComputeTypeSpecifics.cs#L223
internal sealed class TypeComparer : IEqualityComparer<ParameterDefinition>
{
public bool Equals(ParameterDefinition x, ParameterDefinition y)
{
if (x == null)
return y == null;
if (y == null)
return false;

return x.ParameterType.FullName.Equals(y.ParameterType.FullName);
}

public int GetHashCode(ParameterDefinition obj)
{
return obj.ParameterType.FullName.GetHashCode();
}
}
}

0 comments on commit 441577f

Please sign in to comment.