Skip to content

Commit 441577f

Browse files
authored
Handle properties with only different parameter types in Pass80UnstripMethods::GetOrCreateProperty (#91)
1 parent 876e0f0 commit 441577f

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

Il2CppInterop.Generator/Passes/Pass80UnstripMethods.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ private static PropertyDefinition GetOrCreateProperty(MethodDefinition unityMeth
130130
unityMethod.DeclaringType.Properties.Single(
131131
it => it.SetMethod == unityMethod || it.GetMethod == unityMethod);
132132
var newProperty = newMethod.DeclaringType.Properties.SingleOrDefault(it =>
133-
it.Name == unityProperty.Name && it.Parameters.Count == unityProperty.Parameters.Count);
133+
it.Name == unityProperty.Name && it.Parameters.Count == unityProperty.Parameters.Count &&
134+
it.Parameters.SequenceEqual(unityProperty.Parameters, new TypeComparer()));
134135
if (newProperty == null)
135136
{
136137
newProperty = new PropertyDefinition(unityProperty.Name, PropertyAttributes.None,
@@ -228,4 +229,23 @@ private static PropertyDefinition GetOrCreateProperty(MethodDefinition unityMeth
228229

229230
return newType;
230231
}
232+
233+
//Stolen from: https://github.com/kremnev8/Il2CppInterop/blob/2c4a31f95f8aa6afe910aca0f8044efb80259d20/Il2CppInterop.Generator/Passes/Pass11ComputeTypeSpecifics.cs#L223
234+
internal sealed class TypeComparer : IEqualityComparer<ParameterDefinition>
235+
{
236+
public bool Equals(ParameterDefinition x, ParameterDefinition y)
237+
{
238+
if (x == null)
239+
return y == null;
240+
if (y == null)
241+
return false;
242+
243+
return x.ParameterType.FullName.Equals(y.ParameterType.FullName);
244+
}
245+
246+
public int GetHashCode(ParameterDefinition obj)
247+
{
248+
return obj.ParameterType.FullName.GetHashCode();
249+
}
250+
}
231251
}

0 commit comments

Comments
 (0)