fix: Fixed an issue where the SequenceComparer & the UndefinedVersionComparer were not handling null values properly

This commit is contained in:
Austin Noska
2021-06-07 14:43:53 -04:00
parent e6dec641f3
commit 7ae9e86e1d
2 changed files with 11 additions and 3 deletions

View File

@@ -29,11 +29,12 @@ namespace ICD.Common.Utils.Comparers
public int Compare(IEnumerable<T> x, IEnumerable<T> 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<T> firstPos = x.GetEnumerator())
{

View File

@@ -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());
}