From 2bfc4e10c6079ec06ec97fe149194b5fabf1c3a6 Mon Sep 17 00:00:00 2001 From: Guillaume Faas <59444272+Tr00d@users.noreply.github.com> Date: Thu, 14 Sep 2023 09:43:48 +0200 Subject: [PATCH] refactor: implement GetHashCode for ParsingFailure (#512) --- Vonage.Common/Failures/ParsingFailure.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Vonage.Common/Failures/ParsingFailure.cs b/Vonage.Common/Failures/ParsingFailure.cs index 6f9e85700..2d3dc65cf 100644 --- a/Vonage.Common/Failures/ParsingFailure.cs +++ b/Vonage.Common/Failures/ParsingFailure.cs @@ -17,7 +17,7 @@ namespace Vonage.Common.Failures; /// public override bool Equals(object obj) => - obj is ParsingFailure failure && this.failures.SequenceEqual(failure.failures); + obj is ParsingFailure failure && this.GetHashCode().Equals(failure.GetHashCode()); /// /// Creates a ParsingFailure from a list of failures. @@ -30,6 +30,9 @@ public override bool Equals(object obj) => public string GetFailureMessage() => $"Parsing failed with the following errors: {string.Join(", ", this.failures.Select(failure => failure.GetFailureMessage()))}."; + /// + public override int GetHashCode() => this.GetFailureMessage().GetHashCode(); + /// public Exception ToException() => new VonageException(this.GetFailureMessage());