mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
throw exception on null argument of IReadOnlyList<T>.FirstOrDefault()
This commit is contained in:
parent
c80e59cf8d
commit
2ceab1dc56
1 changed files with 5 additions and 4 deletions
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue