Skip to content

Commit

Permalink
🐛 Add missing Equals/GetHashCode in DevQuery Property 😶‍🌫️
Browse files Browse the repository at this point in the history
  • Loading branch information
hexawyz committed Sep 19, 2024
1 parent eaf15d1 commit f9991a5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/DeviceTools/DeviceTools.Core/Property.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;
using DeviceTools.FilterExpressions;

Expand Down Expand Up @@ -34,6 +33,22 @@ public bool TryGetName(out string? name) =>
public bool TryGetName(out string? name) =>
#endif
Properties.TryGetName(_key, out name);

#if !NETSTANDARD2_0
public override int GetHashCode() => HashCode.Combine(Type, _key);
#else
public override int GetHashCode()
{
int hashCode = -553669671;
hashCode = hashCode * -1521134295 + Type.GetHashCode();
hashCode = hashCode * -1521134295 + _key.GetHashCode();
return hashCode;
}
#endif

public override bool Equals(object? obj) => obj is Property p && Equals(p);

private bool Equals(Property other) => Type == other.Type && _key == other._key;
}

public abstract class Property<TValue> : Property
Expand Down

0 comments on commit f9991a5

Please sign in to comment.