throw exception on null argument of IReadOnlyList<T>.FirstOrDefault()

This commit is contained in:
Collin M. Barrett 2019-07-03 10:44:57 -05:00
parent c80e59cf8d
commit 2ceab1dc56

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace FilterLists.Agent.Extensions
{
@ -6,9 +7,9 @@ public static class ReadOnlyListExtensions
{
public static T FirstOrDefault<T>(this IReadOnlyList<T> list)
{
if (list is null || list.Count == 0)
return default;
return list[0];
if (list is null)
throw new ArgumentNullException(nameof(list));
return list.Count == 0 ? default : list[0];
}
}
}