From e757ce08a023850c0ff2d0abd2120e44954be6de Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 30 Apr 2022 10:35:21 +0100 Subject: [PATCH] Add argument null check (#42) --- X10D/src/Collections/DictionaryExtensions.cs | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/X10D/src/Collections/DictionaryExtensions.cs b/X10D/src/Collections/DictionaryExtensions.cs index 0c26126..c016654 100644 --- a/X10D/src/Collections/DictionaryExtensions.cs +++ b/X10D/src/Collections/DictionaryExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Web; namespace X10D.Collections; @@ -226,6 +226,11 @@ public static class DictionaryExtensions throw new ArgumentNullException(nameof(source)); } + if (selector is null) + { + throw new ArgumentNullException(nameof(selector)); + } + static string SanitizeValue(string? value) { if (value is null) @@ -268,6 +273,16 @@ public static class DictionaryExtensions throw new ArgumentNullException(nameof(source)); } + if (keySelector is null) + { + throw new ArgumentNullException(nameof(keySelector)); + } + + if (valueSelector is null) + { + throw new ArgumentNullException(nameof(valueSelector)); + } + static string SanitizeValue(string? value) { if (value is null) @@ -371,6 +386,11 @@ public static class DictionaryExtensions throw new ArgumentNullException(nameof(source)); } + if (keySelector is null) + { + throw new ArgumentNullException(nameof(keySelector)); + } + if (valueSelector is null) { throw new ArgumentNullException(nameof(valueSelector));