From c9e473e86f1e3a838041fcf55547bedb28bdd7d4 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 29 Nov 2022 16:11:06 +0000 Subject: [PATCH] ConfigureAwait(true) on awaited methods --- X10D.DSharpPlus/src/DiscordChannelExtensions.cs | 2 +- X10D.DSharpPlus/src/DiscordGuildExtensions.cs | 4 ++-- X10D.DSharpPlus/src/DiscordMemberExtensions.cs | 4 ++-- X10D.DSharpPlus/src/DiscordMessageExtensions.cs | 12 ++++++------ X10D.DSharpPlus/src/DiscordUserExtensions.cs | 6 +++--- X10D/src/Collections/CollectionExtensions.cs | 2 +- X10D/src/Collections/EnumerableExtensions.cs | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs index 48957c3..026e8bb 100644 --- a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs @@ -75,6 +75,6 @@ public static class DiscordChannelExtensions } #endif - return await client.GetChannelAsync(channel.Id); + return await client.GetChannelAsync(channel.Id).ConfigureAwait(true); } } diff --git a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs index d5451f4..38f8a05 100644 --- a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs @@ -24,7 +24,7 @@ public static class DiscordGuildExtensions } #endif - await Task.WhenAll(guild.Threads.Values.Select(t => t.JoinThreadAsync())); + await Task.WhenAll(guild.Threads.Values.Select(t => t.JoinThreadAsync())).ConfigureAwait(true); } /// @@ -58,6 +58,6 @@ public static class DiscordGuildExtensions } #endif - return await client.GetGuildAsync(guild.Id); + return await client.GetGuildAsync(guild.Id).ConfigureAwait(true); } } diff --git a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs index aede000..566c815 100644 --- a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs @@ -67,7 +67,7 @@ public static class DiscordMemberExtensions } #endif - DiscordGuild guild = await member.Guild.NormalizeClientAsync(client); - return await guild.GetMemberAsync(member.Id); + DiscordGuild guild = await member.Guild.NormalizeClientAsync(client).ConfigureAwait(true); + return await guild.GetMemberAsync(member.Id).ConfigureAwait(true); } } diff --git a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs index e52b25f..e179a73 100644 --- a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs @@ -26,8 +26,8 @@ public static class DiscordMessageExtensions } #endif - await Task.Delay(delay); - await message.DeleteAsync(reason); + await Task.Delay(delay).ConfigureAwait(true); + await message.DeleteAsync(reason).ConfigureAwait(true); } /// @@ -48,8 +48,8 @@ public static class DiscordMessageExtensions } #endif - DiscordMessage message = await task; - await message.DeleteAfterAsync(delay, reason); + DiscordMessage message = await task.ConfigureAwait(true); + await message.DeleteAfterAsync(delay, reason).ConfigureAwait(true); } /// @@ -83,7 +83,7 @@ public static class DiscordMessageExtensions } #endif - DiscordChannel channel = await message.Channel.NormalizeClientAsync(client); - return await channel.GetMessageAsync(message.Id); + DiscordChannel channel = await message.Channel.NormalizeClientAsync(client).ConfigureAwait(true); + return await channel.GetMessageAsync(message.Id).ConfigureAwait(true); } } diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs index b67aca2..02f555f 100644 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordUserExtensions.cs @@ -52,7 +52,7 @@ public static class DiscordUserExtensions try { - return await guild.GetMemberAsync(user.Id); + return await guild.GetMemberAsync(user.Id).ConfigureAwait(true); } catch (NotFoundException) { @@ -113,7 +113,7 @@ public static class DiscordUserExtensions try { - DiscordMember? member = await guild.GetMemberAsync(user.Id); + DiscordMember? member = await guild.GetMemberAsync(user.Id).ConfigureAwait(true); return member is not null; } catch (NotFoundException) @@ -153,6 +153,6 @@ public static class DiscordUserExtensions } #endif - return await client.GetUserAsync(user.Id); + return await client.GetUserAsync(user.Id).ConfigureAwait(true); } } diff --git a/X10D/src/Collections/CollectionExtensions.cs b/X10D/src/Collections/CollectionExtensions.cs index 6bad398..9279393 100644 --- a/X10D/src/Collections/CollectionExtensions.cs +++ b/X10D/src/Collections/CollectionExtensions.cs @@ -69,7 +69,7 @@ public static class CollectionExtensions continue; } - await item.DisposeAsync(); + await item.DisposeAsync().ConfigureAwait(true); } source.Clear(); diff --git a/X10D/src/Collections/EnumerableExtensions.cs b/X10D/src/Collections/EnumerableExtensions.cs index 9747235..909b862 100644 --- a/X10D/src/Collections/EnumerableExtensions.cs +++ b/X10D/src/Collections/EnumerableExtensions.cs @@ -226,7 +226,7 @@ public static class EnumerableExtensions continue; } - await item.DisposeAsync(); + await item.DisposeAsync().ConfigureAwait(true); } }