Skip to content

Commit

Permalink
chore: use HashCode class to generate hash code instead of XOR values
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadHadi2031 authored and jasontaylordev committed Feb 15, 2024
1 parent 0e724e6 commit ba57d98
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Domain/Common/ValueObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ public override bool Equals(object? obj)

public override int GetHashCode()
{
return GetEqualityComponents()
.Select(x => x != null ? x.GetHashCode() : 0)
.Aggregate((x, y) => x ^ y);
var hash = new HashCode();

foreach (var component in GetEqualityComponents())
{
hash.Add(component);
}

return hash.ToHashCode();
}
}

0 comments on commit ba57d98

Please sign in to comment.