From 7ae9e86e1d9e21711c8a7f169a006f3919dc4a0c Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Mon, 7 Jun 2021 14:43:53 -0400 Subject: [PATCH] fix: Fixed an issue where the SequenceComparer & the UndefinedVersionComparer were not handling null values properly --- ICD.Common.Utils/Comparers/SequenceComparer.cs | 7 ++++--- ICD.Common.Utils/Comparers/UndefinedVersionComparer.cs | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ICD.Common.Utils/Comparers/SequenceComparer.cs b/ICD.Common.Utils/Comparers/SequenceComparer.cs index aac843a..d402d63 100644 --- a/ICD.Common.Utils/Comparers/SequenceComparer.cs +++ b/ICD.Common.Utils/Comparers/SequenceComparer.cs @@ -29,11 +29,12 @@ namespace ICD.Common.Utils.Comparers public int Compare(IEnumerable x, IEnumerable y) { + if (x == null && y == null) + return 0; if (x == null) - throw new ArgumentNullException("x"); - + return -1; if (y == null) - throw new ArgumentNullException("y"); + return 1; using (IEnumerator firstPos = x.GetEnumerator()) { diff --git a/ICD.Common.Utils/Comparers/UndefinedVersionComparer.cs b/ICD.Common.Utils/Comparers/UndefinedVersionComparer.cs index 1476d51..e00b0a1 100644 --- a/ICD.Common.Utils/Comparers/UndefinedVersionComparer.cs +++ b/ICD.Common.Utils/Comparers/UndefinedVersionComparer.cs @@ -19,6 +19,13 @@ namespace ICD.Common.Utils.Comparers public int Compare(Version x, Version y) { + if (x == null && y == null) + return 0; + if (x == null) + return -1; + if (y == null) + return 1; + return x.ClearUndefined() .CompareTo(y.ClearUndefined()); }