diff --git a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs
index 2734af986..820ced0ee 100644
--- a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs
@@ -19,14 +19,10 @@ public static class DiscordChannelExtensions
/// is .
public static DiscordChannel? GetCategory(this DiscordChannel channel)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(channel);
-#else
if (channel is null)
{
throw new ArgumentNullException(nameof(channel));
}
-#endif
while (true)
{
@@ -60,10 +56,6 @@ public static class DiscordChannelExtensions
///
public static async Task NormalizeClientAsync(this DiscordChannel channel, DiscordClient client)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(channel);
- ArgumentNullException.ThrowIfNull(client);
-#else
if (channel is null)
{
throw new ArgumentNullException(nameof(channel));
@@ -73,7 +65,6 @@ public static async Task NormalizeClientAsync(this DiscordChanne
{
throw new ArgumentNullException(nameof(client));
}
-#endif
return await client.GetChannelAsync(channel.Id).ConfigureAwait(false);
}
diff --git a/X10D.DSharpPlus/src/DiscordClientExtensions.cs b/X10D.DSharpPlus/src/DiscordClientExtensions.cs
index f3d8964d4..5dfd41573 100644
--- a/X10D.DSharpPlus/src/DiscordClientExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordClientExtensions.cs
@@ -20,14 +20,10 @@ public static class DiscordClientExtensions
/// is .
public static void AutoJoinThreads(this DiscordClient client, bool rejoinIfRemoved = true)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(client);
-#else
if (client is null)
{
throw new ArgumentNullException(nameof(client));
}
-#endif
client.GuildAvailable += (_, args) => args.Guild.JoinAllThreadsAsync();
client.ThreadCreated += (_, args) => args.Thread.JoinThreadAsync();
@@ -53,14 +49,10 @@ public static void AutoJoinThreads(this DiscordClient client, bool rejoinIfRemov
/// is .
public static async Task GetUserOrNullAsync(this DiscordClient client, ulong userId)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(client);
-#else
if (client is null)
{
throw new ArgumentNullException(nameof(client));
}
-#endif
try
{
diff --git a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs b/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs
index 4a23a34ff..1c2c479c9 100644
--- a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs
@@ -23,14 +23,10 @@ public static DiscordEmbedBuilder AddField(
T? value,
bool inline = false)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(builder);
-#else
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
-#endif
return builder.AddField(name, value?.ToString(), inline);
}
@@ -53,14 +49,10 @@ public static DiscordEmbedBuilder AddFieldIf(
T? value,
bool inline = false)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(builder);
-#else
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
-#endif
if (condition)
{
@@ -92,10 +84,6 @@ public static DiscordEmbedBuilder AddFieldIf(
T? value,
bool inline = false)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(builder);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
@@ -105,7 +93,6 @@ public static DiscordEmbedBuilder AddFieldIf(
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
if (predicate.Invoke())
{
@@ -139,11 +126,6 @@ public static DiscordEmbedBuilder AddFieldIf(
Func valueFactory,
bool inline = false)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(builder);
- ArgumentNullException.ThrowIfNull(predicate);
- ArgumentNullException.ThrowIfNull(valueFactory);
-#else
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
@@ -158,7 +140,6 @@ public static DiscordEmbedBuilder AddFieldIf(
{
throw new ArgumentNullException(nameof(valueFactory));
}
-#endif
if (predicate.Invoke())
{
@@ -190,19 +171,15 @@ public static DiscordEmbedBuilder AddFieldIf(
Func valueFactory,
bool inline = false)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(builder);
- ArgumentNullException.ThrowIfNull(valueFactory);
-#else
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
+
if (valueFactory is null)
{
throw new ArgumentNullException(nameof(valueFactory));
}
-#endif
if (condition)
{
@@ -220,19 +197,15 @@ public static DiscordEmbedBuilder AddFieldIf(
/// The current instance of .
public static DiscordEmbedBuilder WithAuthor(this DiscordEmbedBuilder builder, DiscordUser user)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(builder);
- ArgumentNullException.ThrowIfNull(user);
-#else
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
+
if (user is null)
{
throw new ArgumentNullException(nameof(user));
}
-#endif
return builder.WithAuthor(user.GetUsernameWithDiscriminator(), iconUrl: user.AvatarUrl);
}
diff --git a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs
index c03016bc3..ff4636e33 100644
--- a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs
@@ -16,14 +16,10 @@ public static class DiscordGuildExtensions
/// is .
public static async Task JoinAllThreadsAsync(this DiscordGuild guild)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(guild);
-#else
if (guild is null)
{
throw new ArgumentNullException(nameof(guild));
}
-#endif
await Task.WhenAll(guild.Threads.Values.Select(t => t.JoinThreadAsync())).ConfigureAwait(false);
}
@@ -37,14 +33,10 @@ public static async Task JoinAllThreadsAsync(this DiscordGuild guild)
/// is .
public static async Task GetMemberOrNullAsync(this DiscordGuild guild, ulong userId)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(guild);
-#else
if (guild is null)
{
throw new ArgumentNullException(nameof(guild));
}
-#endif
try
{
@@ -77,10 +69,6 @@ public static async Task JoinAllThreadsAsync(this DiscordGuild guild)
///
public static async Task NormalizeClientAsync(this DiscordGuild guild, DiscordClient client)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(guild);
- ArgumentNullException.ThrowIfNull(client);
-#else
if (guild is null)
{
throw new ArgumentNullException(nameof(guild));
@@ -90,7 +78,6 @@ public static async Task NormalizeClientAsync(this DiscordGuild gu
{
throw new ArgumentNullException(nameof(client));
}
-#endif
return await client.GetGuildAsync(guild.Id).ConfigureAwait(false);
}
diff --git a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs
index 3fd202048..7ec99256b 100644
--- a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs
@@ -18,10 +18,6 @@ public static class DiscordMemberExtensions
///
public static bool HasRole(this DiscordMember member, DiscordRole role)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(member);
- ArgumentNullException.ThrowIfNull(role);
-#else
if (member is null)
{
throw new ArgumentNullException(nameof(member));
@@ -31,7 +27,6 @@ public static bool HasRole(this DiscordMember member, DiscordRole role)
{
throw new ArgumentNullException(nameof(role));
}
-#endif
return member.Roles.Contains(role);
}
@@ -52,10 +47,6 @@ public static bool HasRole(this DiscordMember member, DiscordRole role)
///
public static async Task NormalizeClientAsync(this DiscordMember member, DiscordClient client)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(member);
- ArgumentNullException.ThrowIfNull(client);
-#else
if (member is null)
{
throw new ArgumentNullException(nameof(member));
@@ -65,7 +56,6 @@ public static async Task NormalizeClientAsync(this DiscordMember
{
throw new ArgumentNullException(nameof(client));
}
-#endif
DiscordGuild guild = await member.Guild.NormalizeClientAsync(client).ConfigureAwait(false);
return await guild.GetMemberAsync(member.Id).ConfigureAwait(false);
diff --git a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs
index f8317c71f..f43116d4c 100644
--- a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs
@@ -17,14 +17,10 @@ public static class DiscordMessageExtensions
/// is .
public static async Task DeleteAfterAsync(this DiscordMessage message, TimeSpan delay, string? reason = null)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(message);
-#else
if (message is null)
{
throw new ArgumentNullException(nameof(message));
}
-#endif
await Task.Delay(delay).ConfigureAwait(false);
await message.DeleteAsync(reason).ConfigureAwait(false);
@@ -39,14 +35,10 @@ public static async Task DeleteAfterAsync(this DiscordMessage message, TimeSpan
/// is .
public static async Task DeleteAfterAsync(this Task task, TimeSpan delay, string? reason = null)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(task);
-#else
if (task is null)
{
throw new ArgumentNullException(nameof(task));
}
-#endif
DiscordMessage message = await task.ConfigureAwait(false);
await message.DeleteAfterAsync(delay, reason).ConfigureAwait(false);
@@ -68,10 +60,6 @@ public static async Task DeleteAfterAsync(this Task task, TimeSp
///
public static async Task NormalizeClientAsync(this DiscordMessage message, DiscordClient client)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(message);
- ArgumentNullException.ThrowIfNull(client);
-#else
if (message is null)
{
throw new ArgumentNullException(nameof(message));
@@ -81,7 +69,6 @@ public static async Task NormalizeClientAsync(this DiscordMessag
{
throw new ArgumentNullException(nameof(client));
}
-#endif
DiscordChannel channel = await message.Channel.NormalizeClientAsync(client).ConfigureAwait(false);
return await channel.GetMessageAsync(message.Id).ConfigureAwait(false);
diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs
index 6ab831458..adfd477d3 100644
--- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs
+++ b/X10D.DSharpPlus/src/DiscordUserExtensions.cs
@@ -25,10 +25,6 @@ public static class DiscordUserExtensions
///
public static async Task GetAsMemberOfAsync(this DiscordUser user, DiscordGuild guild)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(user);
- ArgumentNullException.ThrowIfNull(guild);
-#else
if (user is null)
{
throw new ArgumentNullException(nameof(user));
@@ -38,7 +34,6 @@ public static class DiscordUserExtensions
{
throw new ArgumentNullException(nameof(guild));
}
-#endif
if (user is DiscordMember member && member.Guild == guild)
{
@@ -68,14 +63,10 @@ public static class DiscordUserExtensions
/// is .
public static string GetUsernameWithDiscriminator(this DiscordUser user)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(user);
-#else
if (user is null)
{
throw new ArgumentNullException(nameof(user));
}
-#endif
return $"{user.Username}#{user.Discriminator}";
}
@@ -91,10 +82,6 @@ public static string GetUsernameWithDiscriminator(this DiscordUser user)
///
public static async Task IsInGuildAsync(this DiscordUser user, DiscordGuild guild)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(user);
- ArgumentNullException.ThrowIfNull(guild);
-#else
if (user is null)
{
throw new ArgumentNullException(nameof(user));
@@ -104,7 +91,6 @@ public static async Task IsInGuildAsync(this DiscordUser user, DiscordGuil
{
throw new ArgumentNullException(nameof(guild));
}
-#endif
if (guild.Members.TryGetValue(user.Id, out _))
{
@@ -138,10 +124,6 @@ public static async Task IsInGuildAsync(this DiscordUser user, DiscordGuil
///
public static async Task NormalizeClientAsync(this DiscordUser user, DiscordClient client)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(user);
- ArgumentNullException.ThrowIfNull(client);
-#else
if (user is null)
{
throw new ArgumentNullException(nameof(user));
@@ -151,7 +133,6 @@ public static async Task NormalizeClientAsync(this DiscordUser user
{
throw new ArgumentNullException(nameof(client));
}
-#endif
return await client.GetUserAsync(user.Id).ConfigureAwait(false);
}
diff --git a/X10D/src/Collections/ArrayExtensions.cs b/X10D/src/Collections/ArrayExtensions.cs
index c6ed75bbe..7dd5863e4 100644
--- a/X10D/src/Collections/ArrayExtensions.cs
+++ b/X10D/src/Collections/ArrayExtensions.cs
@@ -17,14 +17,10 @@ public static class ArrayExtensions
[Pure]
public static IReadOnlyCollection AsReadOnly(this T[] array)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(array);
-#else
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
-#endif
return Array.AsReadOnly(array);
}
@@ -49,14 +45,10 @@ public static void Clear(this T?[] array)
/// is .
public static void Clear(this T?[] array, Range range)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(array);
-#else
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
-#endif
(int offset, int length) = range.GetOffsetAndLength(array.Length);
array.Clear(offset, length);
@@ -79,14 +71,10 @@ public static void Clear(this T?[] array, Range range)
///
public static void Clear(this T?[] array, int index, int length)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(array);
-#else
if (array is null)
{
throw new ArgumentNullException(nameof(array));
}
-#endif
if (length == 0 || array.Length == 0)
{
diff --git a/X10D/src/Collections/BoolListExtensions.cs b/X10D/src/Collections/BoolListExtensions.cs
index 347d19bb8..6258617fd 100644
--- a/X10D/src/Collections/BoolListExtensions.cs
+++ b/X10D/src/Collections/BoolListExtensions.cs
@@ -18,14 +18,10 @@ public static class BoolListExtensions
[Pure]
public static byte PackByte(this IReadOnlyList source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (source.Count > 8)
{
@@ -52,14 +48,10 @@ public static byte PackByte(this IReadOnlyList source)
[Pure]
public static short PackInt16(this IReadOnlyList source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (source.Count > 16)
{
@@ -86,14 +78,10 @@ public static short PackInt16(this IReadOnlyList source)
[Pure]
public static int PackInt32(this IReadOnlyList source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (source.Count > 32)
{
@@ -120,14 +108,10 @@ public static int PackInt32(this IReadOnlyList source)
[Pure]
public static long PackInt64(this IReadOnlyList source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (source.Count > 64)
{
diff --git a/X10D/src/Collections/CollectionExtensions.cs b/X10D/src/Collections/CollectionExtensions.cs
index 355458666..e9b2c6ed1 100644
--- a/X10D/src/Collections/CollectionExtensions.cs
+++ b/X10D/src/Collections/CollectionExtensions.cs
@@ -16,14 +16,10 @@ 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)
{
@@ -55,14 +51,10 @@ public static void ClearAndDisposeAll(this ICollection source) where T : I
///
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/DictionaryExtensions.cs b/X10D/src/Collections/DictionaryExtensions.cs
index 66823b011..241efe920 100644
--- a/X10D/src/Collections/DictionaryExtensions.cs
+++ b/X10D/src/Collections/DictionaryExtensions.cs
@@ -37,10 +37,6 @@ public static TValue AddOrUpdate(this Dictionary dic
Func updateValueFactory)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(dictionary);
- ArgumentNullException.ThrowIfNull(updateValueFactory);
-#else
if (dictionary is null)
{
throw new ArgumentNullException(nameof(dictionary));
@@ -50,7 +46,6 @@ public static TValue AddOrUpdate(this Dictionary dic
{
throw new ArgumentNullException(nameof(updateValueFactory));
}
-#endif
#if NET6_0_OR_GREATER
ref var value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists);
@@ -97,10 +92,6 @@ public static TValue AddOrUpdate(this IDictionary di
Func updateValueFactory)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(dictionary);
- ArgumentNullException.ThrowIfNull(updateValueFactory);
-#else
if (dictionary is null)
{
throw new ArgumentNullException(nameof(dictionary));
@@ -110,7 +101,6 @@ public static TValue AddOrUpdate(this IDictionary di
{
throw new ArgumentNullException(nameof(updateValueFactory));
}
-#endif
if (dictionary.TryGetValue(key, out TValue? old))
{
@@ -152,11 +142,6 @@ public static TValue AddOrUpdate(this Dictionary dic
Func addValueFactory, Func updateValueFactory)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(dictionary);
- ArgumentNullException.ThrowIfNull(addValueFactory);
- ArgumentNullException.ThrowIfNull(updateValueFactory);
-#else
if (dictionary is null)
{
throw new ArgumentNullException(nameof(dictionary));
@@ -171,7 +156,6 @@ public static TValue AddOrUpdate(this Dictionary dic
{
throw new ArgumentNullException(nameof(updateValueFactory));
}
-#endif
#if NET6_0_OR_GREATER
ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists);
@@ -222,11 +206,6 @@ public static TValue AddOrUpdate(this IDictionary di
Func addValueFactory, Func updateValueFactory)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(dictionary);
- ArgumentNullException.ThrowIfNull(addValueFactory);
- ArgumentNullException.ThrowIfNull(updateValueFactory);
-#else
if (dictionary is null)
{
throw new ArgumentNullException(nameof(dictionary));
@@ -241,7 +220,6 @@ public static TValue AddOrUpdate(this IDictionary di
{
throw new ArgumentNullException(nameof(updateValueFactory));
}
-#endif
if (dictionary.TryGetValue(key, out TValue? old))
{
@@ -291,11 +269,6 @@ public static TValue AddOrUpdate(this Dictionary addValueFactory, Func updateValueFactory, TArg factoryArgument)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(dictionary);
- ArgumentNullException.ThrowIfNull(addValueFactory);
- ArgumentNullException.ThrowIfNull(updateValueFactory);
-#else
if (dictionary is null)
{
throw new ArgumentNullException(nameof(dictionary));
@@ -310,7 +283,6 @@ public static TValue AddOrUpdate(this Dictionary(this IDictionary addValueFactory, Func updateValueFactory, TArg factoryArgument)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(dictionary);
- ArgumentNullException.ThrowIfNull(addValueFactory);
- ArgumentNullException.ThrowIfNull(updateValueFactory);
-#else
if (dictionary is null)
{
throw new ArgumentNullException(nameof(dictionary));
@@ -386,7 +353,6 @@ public static TValue AddOrUpdate(this IDictionary(this IDictionary(this IEnumerable> source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
static string SanitizeValue(string? value)
{
@@ -461,10 +423,6 @@ static string GetQueryParameter(KeyValuePair pair)
public static string ToConnectionString(this IEnumerable> source,
Func selector)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(selector);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -474,7 +432,6 @@ public static string ToConnectionString(this IEnumerable(this IEnumerable keySelector, Func valueSelector)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(keySelector);
- ArgumentNullException.ThrowIfNull(valueSelector);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -539,7 +491,6 @@ public static string ToConnectionString(this IEnumerable pair)
public static string ToGetParameters(this IEnumerable> source)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
static string GetQueryParameter(KeyValuePair pair)
{
@@ -610,10 +557,6 @@ public static string ToGetParameters(this IEnumerable selector)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(selector);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -623,7 +566,6 @@ public static string ToGetParameters(this IEnumerable pair)
@@ -661,11 +603,6 @@ public static string ToGetParameters(this IEnumerable keySelector, Func valueSelector)
where TKey : notnull
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(keySelector);
- ArgumentNullException.ThrowIfNull(valueSelector);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -680,7 +617,6 @@ public static string ToGetParameters(this IEnumerable pair)
diff --git a/X10D/src/Collections/EnumerableExtensions.cs b/X10D/src/Collections/EnumerableExtensions.cs
index c38e4dff2..a183c2b89 100644
--- a/X10D/src/Collections/EnumerableExtensions.cs
+++ b/X10D/src/Collections/EnumerableExtensions.cs
@@ -24,10 +24,6 @@ public static class EnumerableExtensions
[Pure]
public static int CountWhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -37,7 +33,6 @@ public static int CountWhereNot(this IEnumerable source, Func<
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
return source.Count(item => !predicate(item));
}
@@ -58,10 +53,6 @@ public static int CountWhereNot(this IEnumerable source, Func<
[Pure]
public static TSource FirstWhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -71,7 +62,6 @@ public static TSource FirstWhereNot(this IEnumerable source, F
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
return source.First(item => !predicate(item));
}
@@ -91,10 +81,6 @@ public static TSource FirstWhereNot(this IEnumerable source, F
[Pure]
public static TSource? FirstWhereNotOrDefault(this IEnumerable source, Func predicate)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -104,7 +90,6 @@ public static TSource FirstWhereNot(this IEnumerable source, F
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
return source.FirstOrDefault(item => !predicate(item));
}
@@ -127,10 +112,6 @@ public static TSource FirstWhereNot(this IEnumerable source, F
///
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));
@@ -140,7 +121,6 @@ public static void For(this IEnumerable source, Action action)
{
throw new ArgumentNullException(nameof(action));
}
-#endif
var index = 0;
foreach (T item in source)
@@ -166,10 +146,6 @@ public static void For(this IEnumerable source, Action action)
///
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));
@@ -179,7 +155,6 @@ public static void ForEach(this IEnumerable source, Action action)
{
throw new ArgumentNullException(nameof(action));
}
-#endif
foreach (T item in source)
{
@@ -196,14 +171,10 @@ public static void ForEach(this IEnumerable source, Action action)
///
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)
{
@@ -227,14 +198,10 @@ public static void DisposeAll(this IEnumerable source) where T : IDisposab
///
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)
{
@@ -264,10 +231,6 @@ public static async Task DisposeAllAsync(this IEnumerable source) where T
[Pure]
public static TSource LastWhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -277,7 +240,6 @@ public static TSource LastWhereNot(this IEnumerable source, Fu
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
return source.Last(item => !predicate(item));
}
@@ -297,10 +259,6 @@ public static TSource LastWhereNot(this IEnumerable source, Fu
[Pure]
public static TSource? LastWhereNotOrDefault(this IEnumerable source, Func predicate)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -310,7 +268,6 @@ public static TSource LastWhereNot(this IEnumerable source, Fu
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
return source.LastOrDefault(item => !predicate(item));
}
@@ -326,14 +283,10 @@ public static TSource LastWhereNot(this IEnumerable source, Fu
[Pure]
public static IReadOnlyCollection Shuffled(this IEnumerable source, Random? random = null)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
var list = new List(source);
list.Shuffle(random);
@@ -355,10 +308,6 @@ public static IReadOnlyCollection Shuffled(this IEnumerable source, Ran
[Pure]
public static IEnumerable WhereNot(this IEnumerable source, Func predicate)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(predicate);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -368,7 +317,6 @@ public static IEnumerable WhereNot(this IEnumerable s
{
throw new ArgumentNullException(nameof(predicate));
}
-#endif
return source.Where(item => !predicate(item));
}
@@ -386,14 +334,10 @@ public static IEnumerable WhereNot(this IEnumerable s
/// is .
public static IEnumerable WhereNotNull(this IEnumerable source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
return source.Where(item => item is not null).Select(item => item!);
}
diff --git a/X10D/src/Collections/ListExtensions.cs b/X10D/src/Collections/ListExtensions.cs
index 69292b4fb..be53ee814 100644
--- a/X10D/src/Collections/ListExtensions.cs
+++ b/X10D/src/Collections/ListExtensions.cs
@@ -19,14 +19,10 @@ public static class ListExtensions
/// is .
public static void Fill(this IList source, T value)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
for (var i = 0; i < source.Count; i++)
{
@@ -53,14 +49,10 @@ public static void Fill(this IList source, T value)
///
public static void Fill(this IList source, T value, int startIndex, int count)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (startIndex < 0)
{
@@ -105,14 +97,10 @@ public static void Fill(this IList source, T value, int startIndex, int co
/// is .
public static int IndexOf(this IReadOnlyList source, T? item)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
return source.IndexOf(item, 0, source.Count);
}
@@ -138,14 +126,10 @@ public static int IndexOf(this IReadOnlyList source, T? item)
///
public static int IndexOf(this IReadOnlyList source, T? item, int startIndex)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
return source.IndexOf(item, startIndex, source.Count - startIndex);
}
@@ -182,14 +166,10 @@ public static int IndexOf(this IReadOnlyList source, T? item, int startIn
///
public static int IndexOf(this IReadOnlyList source, T? item, int startIndex, int count)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (startIndex < 0 || startIndex > source.Count)
{
@@ -233,14 +213,10 @@ public static int IndexOf(this IReadOnlyList source, T? item, int startIn
[Pure]
public static T Random(this IReadOnlyList source, Random? random = null)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
random ??= RandomExtensions.GetShared();
return random.NextFrom(source);
@@ -260,14 +236,10 @@ public static T Random(this IReadOnlyList source, Random? random = null)
///
public static void RemoveRange(this IList source, Range range)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
int start = range.Start.IsFromEnd ? source.Count - range.Start.Value : range.Start.Value;
int end = range.End.IsFromEnd ? source.Count - range.End.Value : range.End.Value;
@@ -300,14 +272,10 @@ public static void RemoveRange(this IList source, Range range)
/// is .
public static void Shuffle(this IList source, Random? random = null)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
random ??= RandomExtensions.GetShared();
@@ -334,14 +302,10 @@ public static void Shuffle(this IList source, Random? random = null)
///
public static IReadOnlyList Slice(this IReadOnlyList source, int start)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
return source.Slice(start, source.Count - start);
}
@@ -363,14 +327,10 @@ public static IReadOnlyList Slice(this IReadOnlyList source, int start)
///
public static IReadOnlyList Slice(this IReadOnlyList source, int start, int length)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (start < 0 || start > source.Count)
{
@@ -406,10 +366,6 @@ public static IReadOnlyList Slice(this IReadOnlyList source, int start,
///
public static void Swap(this IList source, IList other)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(source);
- ArgumentNullException.ThrowIfNull(other);
-#else
if (source is null)
{
throw new ArgumentNullException(nameof(source));
@@ -419,7 +375,6 @@ public static void Swap(this IList source, IList other)
{
throw new ArgumentNullException(nameof(other));
}
-#endif
int min = System.Math.Min(source.Count, other.Count);
for (var index = 0; index < min; index++)
diff --git a/X10D/src/Core/RandomExtensions.cs b/X10D/src/Core/RandomExtensions.cs
index 32acc3b2e..49e8634af 100644
--- a/X10D/src/Core/RandomExtensions.cs
+++ b/X10D/src/Core/RandomExtensions.cs
@@ -27,14 +27,10 @@ public static class RandomExtensions
public static T Next(this Random random)
where T : struct, Enum
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
var values = Enum.GetValues(typeof(T));
return (T)values.GetValue(random.Next(values.Length))!;
@@ -54,14 +50,10 @@ public static T Next(this Random random)
/// is .
public static bool NextBoolean(this Random random)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return random.NextDouble() >= 0.5;
}
@@ -81,14 +73,10 @@ public static bool NextBoolean(this Random random)
/// is less than 0.
public static double NextDouble(this Random random, double maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
if (maxValue < 0)
{
@@ -117,14 +105,10 @@ public static double NextDouble(this Random random, double maxValue)
///
public static double NextDouble(this Random random, double minValue, double maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
if (maxValue < minValue)
{
@@ -155,10 +139,6 @@ public static double NextDouble(this Random random, double minValue, double maxV
///
public static T NextFrom(this Random random, IEnumerable source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
- ArgumentNullException.ThrowIfNull(source);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
@@ -168,7 +148,6 @@ public static T NextFrom(this Random random, IEnumerable source)
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (source is T[] array)
{
@@ -206,14 +185,10 @@ public static T NextFrom(this Random random, IEnumerable source)
///
public static T NextFrom(this Random random, Span source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return source[random.Next(source.Length)];
}
@@ -242,14 +217,10 @@ public static T NextFrom(this Random random, Span source)
///
public static T NextFrom(this Random random, ReadOnlySpan source)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return source[random.Next(source.Length)];
}
@@ -264,14 +235,10 @@ public static T NextFrom(this Random random, ReadOnlySpan source)
/// is .
public static byte NextByte(this Random random)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return random.NextByte(byte.MaxValue);
}
@@ -292,14 +259,10 @@ public static byte NextByte(this Random random)
/// is .
public static byte NextByte(this Random random, byte maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return random.NextByte(0, maxValue);
}
@@ -325,14 +288,10 @@ public static byte NextByte(this Random random, byte maxValue)
///
public static byte NextByte(this Random random, byte minValue, byte maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return (byte)random.Next(minValue, maxValue);
}
@@ -347,14 +306,10 @@ public static byte NextByte(this Random random, byte minValue, byte maxValue)
/// is .
public static short NextInt16(this Random random)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return random.NextInt16(short.MaxValue);
}
@@ -376,14 +331,10 @@ public static short NextInt16(this Random random)
/// is less than 0.
public static short NextInt16(this Random random, short maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
if (maxValue < 0)
{
@@ -414,14 +365,10 @@ public static short NextInt16(this Random random, short maxValue)
/// is .
public static short NextInt16(this Random random, short minValue, short maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
return (short)random.Next(minValue, maxValue);
}
@@ -459,14 +406,10 @@ public static float NextSingle(this Random random)
/// is less than 0.
public static float NextSingle(this Random random, float maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
if (maxValue < 0)
{
@@ -495,14 +438,10 @@ public static float NextSingle(this Random random, float maxValue)
///
public static float NextSingle(this Random random, float minValue, float maxValue)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
}
-#endif
if (maxValue < minValue)
{
@@ -530,10 +469,6 @@ public static float NextSingle(this Random random, float minValue, float maxValu
/// is less than 0.
public static string NextString(this Random random, IReadOnlyList source, int length)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(random);
- ArgumentNullException.ThrowIfNull(source);
-#else
if (random is null)
{
throw new ArgumentNullException(nameof(random));
@@ -543,7 +478,6 @@ public static string NextString(this Random random, IReadOnlyList source,
{
throw new ArgumentNullException(nameof(source));
}
-#endif
if (length < 0)
{
diff --git a/X10D/src/Drawing/Polygon.cs b/X10D/src/Drawing/Polygon.cs
index 63abae8b3..9f03b588b 100644
--- a/X10D/src/Drawing/Polygon.cs
+++ b/X10D/src/Drawing/Polygon.cs
@@ -22,14 +22,10 @@ public Polygon()
///
public Polygon(Polygon polygon)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(polygon);
-#else
if (polygon is null)
{
throw new ArgumentNullException(nameof(polygon));
}
-#endif
_vertices = new List();
for (var index = 0; index < polygon._vertices.Count; index++)
@@ -45,14 +41,10 @@ public Polygon(Polygon polygon)
/// An enumerable collection of vertices from which the polygon should be constructed.
public Polygon(IEnumerable vertices)
{
-#if NET6_0_OR_GREATER
- ArgumentNullException.ThrowIfNull(vertices);
-#else
if (vertices is null)
{
throw new ArgumentNullException(nameof(vertices));
}
-#endif
_vertices = new List(vertices);
}
@@ -176,14 +168,10 @@ public IReadOnlyList