diff --git a/X10D/src/Collections/CollectionExtensions.cs b/X10D/src/Collections/CollectionExtensions.cs
index ae33488..152e7ba 100644
--- a/X10D/src/Collections/CollectionExtensions.cs
+++ b/X10D/src/Collections/CollectionExtensions.cs
@@ -16,10 +16,14 @@ public static class CollectionExtensions
///
public static void ClearAndDisposeAll(this ICollection source) where T : IDisposable
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(source);
+#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
+#endif
if (source.IsReadOnly)
{
@@ -51,10 +55,14 @@ public static class CollectionExtensions
///
public static async Task ClearAndDisposeAllAsync(this ICollection source) where T : IAsyncDisposable
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(source);
+#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
+#endif
if (source.IsReadOnly)
{
diff --git a/X10D/src/Collections/EnumerableExtensions.cs b/X10D/src/Collections/EnumerableExtensions.cs
index 4a2580a..78707e1 100644
--- a/X10D/src/Collections/EnumerableExtensions.cs
+++ b/X10D/src/Collections/EnumerableExtensions.cs
@@ -24,7 +24,7 @@ public static class EnumerableExtensions
[Pure]
public static int CountWhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0
+#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(predicate);
#else
@@ -58,7 +58,7 @@ public static class EnumerableExtensions
[Pure]
public static TSource FirstWhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0
+#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(predicate);
#else
@@ -91,7 +91,7 @@ public static class EnumerableExtensions
[Pure]
public static TSource? FirstWhereNotOrDefault(this IEnumerable source, Func predicate)
{
-#if NET6_0
+#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(predicate);
#else
@@ -127,6 +127,10 @@ public static class EnumerableExtensions
///
public static void For(this IEnumerable source, Action action)
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(source);
+ ArgumentNullException.ThrowIfNull(action);
+#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -136,6 +140,7 @@ public static class EnumerableExtensions
{
throw new ArgumentNullException(nameof(action));
}
+#endif
var index = 0;
foreach (T item in source)
@@ -161,6 +166,10 @@ public static class EnumerableExtensions
///
public static void ForEach(this IEnumerable source, Action action)
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(source);
+ ArgumentNullException.ThrowIfNull(action);
+#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -170,6 +179,7 @@ public static class EnumerableExtensions
{
throw new ArgumentNullException(nameof(action));
}
+#endif
foreach (T item in source)
{
@@ -186,10 +196,14 @@ public static class EnumerableExtensions
///
public static void DisposeAll(this IEnumerable source) where T : IDisposable
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(source);
+#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
+#endif
foreach (T item in source)
{
@@ -213,10 +227,14 @@ public static class EnumerableExtensions
///
public static async Task DisposeAllAsync(this IEnumerable source) where T : IAsyncDisposable
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(source);
+#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
+#endif
foreach (T item in source)
{
@@ -246,7 +264,7 @@ public static class EnumerableExtensions
[Pure]
public static TSource LastWhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0
+#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(predicate);
#else
@@ -279,7 +297,7 @@ public static class EnumerableExtensions
[Pure]
public static TSource? LastWhereNotOrDefault(this IEnumerable source, Func predicate)
{
-#if NET6_0
+#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(predicate);
#else
diff --git a/X10D/src/Text/StringBuilderReader.cs b/X10D/src/Text/StringBuilderReader.cs
index fe6e969..337a22c 100644
--- a/X10D/src/Text/StringBuilderReader.cs
+++ b/X10D/src/Text/StringBuilderReader.cs
@@ -55,10 +55,14 @@ public class StringBuilderReader : TextReader
///
public override int Read(char[] buffer, int index, int count)
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(buffer);
+#else
if (buffer is null)
{
throw new ArgumentNullException(nameof(buffer));
}
+#endif
if (index < 0)
{
diff --git a/X10D/src/Time/StringExtensions.cs b/X10D/src/Time/StringExtensions.cs
index 0772ff5..dbb154b 100644
--- a/X10D/src/Time/StringExtensions.cs
+++ b/X10D/src/Time/StringExtensions.cs
@@ -64,10 +64,14 @@ public static class StringExtensions
#endif
public static TimeSpan ToTimeSpan(this string input)
{
+#if NET6_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(input);
+#else
if (input is null)
{
throw new ArgumentNullException(nameof(input));
}
+#endif
return TimeSpanParser.TryParse(input, out TimeSpan result)
? result