Skip to content

Commit

Permalink
Restore buggy Equals behaviour on SingletonNode since some UI code re…
Browse files Browse the repository at this point in the history
…lied on the bug
  • Loading branch information
James A Sutherland authored and jas88 committed Nov 2, 2023
1 parent cab6671 commit 1f042d9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Rdmp.Core/Providers/Nodes/SingletonNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Rdmp.Core.Providers.Nodes;
/// <see cref="Node"/> of which there can only ever be one in the RDMP object hierarchy e.g. <see cref="AllCohortsNode"/>. By convention
/// these classes should normally start with the prefix "All"
/// </summary>
public abstract class SingletonNode : Node, IEquatable<SingletonNode>
public abstract class SingletonNode : Node
{
private readonly string _caption;

Expand All @@ -26,9 +26,8 @@ protected SingletonNode(string caption)

public bool Equals(SingletonNode other) => string.Equals(_caption, other._caption);

public override bool Equals(object obj) => obj?.GetType() == typeof(SingletonNode) &&
typeof(SingletonNode) == GetType() &&
MemberwiseEqualityComparer<SingletonNode>.ByProperties.Equals(this, obj as SingletonNode);
public override bool Equals(object obj) => obj is SingletonNode sn &&
Equals(sn);

public override int GetHashCode() => _caption.GetHashCode();
}

0 comments on commit 1f042d9

Please sign in to comment.