From ad2570188e454d657f59e790dfd52c70ab0de7ff Mon Sep 17 00:00:00 2001 From: Maciej Jedrzejewski Date: Tue, 18 Jun 2024 10:10:37 +0200 Subject: [PATCH] refactor: check type as well --- .../Fitnet.Common/Fitnet.Common.Core/ValueObject.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs b/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs index 1f798d74..041f4eb8 100644 --- a/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs +++ b/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs @@ -4,7 +4,8 @@ public abstract class ValueObject : IEquatable { protected abstract IEnumerable GetEqualityComponents(); - public bool Equals(ValueObject? other) => other is not null && IsSequenceEqual(other); + public bool Equals(ValueObject? other) => + other is not null && GetType() == other.GetType() && IsSequenceEqual(other); public override bool Equals(object? obj) {