From ba57d988e3213b7481e9f3f819aaf3b61ade7f19 Mon Sep 17 00:00:00 2001 From: mohammadhadi2031 Date: Fri, 6 Oct 2023 13:33:18 +0330 Subject: [PATCH] chore: use HashCode class to generate hash code instead of XOR values --- src/Domain/Common/ValueObject.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Domain/Common/ValueObject.cs b/src/Domain/Common/ValueObject.cs index 7e60a7181..935e5e447 100644 --- a/src/Domain/Common/ValueObject.cs +++ b/src/Domain/Common/ValueObject.cs @@ -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(); } }