Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing ConfigureAwait( false ) calls #1488

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions SteamKit2/SteamKit2/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = false

[*.cs]
# CA2007: Consider calling ConfigureAwait on the awaited task
dotnet_diagnostic.CA2007.severity = warning
8 changes: 4 additions & 4 deletions SteamKit2/SteamKit2/Steam/CDN/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async Task<DepotManifest> DownloadManifestAsync( uint depotId, ulong mani
ms = new MemoryStream( buffer, 0, contentLength );

// Stream the http response into the rented buffer
await response.Content.CopyToAsync( ms, cts.Token );
await response.Content.CopyToAsync( ms, cts.Token ).ConfigureAwait( false );

if ( ms.Position != contentLength )
{
Expand All @@ -134,7 +134,7 @@ public async Task<DepotManifest> DownloadManifestAsync( uint depotId, ulong mani
}
else
{
var data = await response.Content.ReadAsByteArrayAsync();
var data = await response.Content.ReadAsByteArrayAsync().ConfigureAwait( false );
ms = new MemoryStream( data );
}

Expand Down Expand Up @@ -281,7 +281,7 @@ public async Task<int> DownloadDepotChunkAsync( uint depotId, DepotManifest.Chun
using var ms = new MemoryStream( destination, 0, contentLength );

// Stream the http response into the provided destination
await response.Content.CopyToAsync( ms, cts.Token );
await response.Content.CopyToAsync( ms, cts.Token ).ConfigureAwait( false );

if ( ms.Position != contentLength )
{
Expand All @@ -299,7 +299,7 @@ public async Task<int> DownloadDepotChunkAsync( uint depotId, DepotManifest.Chun
using var ms = new MemoryStream( buffer, 0, contentLength );

// Stream the http response into the rented buffer
await response.Content.CopyToAsync( ms, cts.Token );
await response.Content.CopyToAsync( ms, cts.Token ).ConfigureAwait( false );

if ( ms.Position != contentLength )
{
Expand Down
3 changes: 2 additions & 1 deletion SteamKit2/SteamKit2/Steam/CDN/ClientLancache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public partial class Client
/// </summary>
public static async Task DetectLancacheServerAsync()
{
var ipAddresses = ( await Dns.GetHostAddressesAsync( TriggerDomain ) )
var dns = await Dns.GetHostAddressesAsync( TriggerDomain ).ConfigureAwait( false );
var ipAddresses = dns
.Where( e => e.AddressFamily == AddressFamily.InterNetwork || e.AddressFamily == AddressFamily.InterNetworkV6 )
.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void RunWaitCallbacks()
/// </summary>
public async Task RunWaitCallbackAsync( CancellationToken cancellationToken = default )
{
var call = await client.WaitForCallbackAsync( cancellationToken );
var call = await client.WaitForCallbackAsync( cancellationToken ).ConfigureAwait( false );
Handle( call );
}

Expand Down
6 changes: 3 additions & 3 deletions SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ internal AsyncInterface( HttpClient httpClient, string iface, string apiKey )
/// <exception cref="ProtoException">An error occured when parsing the response from the WebAPI.</exception>
public async Task<T> CallProtobufAsync<T>( HttpMethod method, string func, int version = 1, Dictionary<string, object?>? args = null )
{
var response = await CallAsyncInternal( method, func, version, args, "protobuf_raw" );
var response = await CallAsyncInternal( method, func, version, args, "protobuf_raw" ).ConfigureAwait( false );

using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait( false );

Expand Down Expand Up @@ -282,7 +282,7 @@ public async Task<WebAPIResponse<TResponse>> CallProtobufAsync<TResponse, TReque
{ "input_protobuf_encoded", base64 },
};

var response = await CallAsyncInternal( method, func, version, args, "protobuf_raw" );
var response = await CallAsyncInternal( method, func, version, args, "protobuf_raw" ).ConfigureAwait( false );
var eresult = EResult.Invalid;

using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait( false );
Expand Down Expand Up @@ -326,7 +326,7 @@ public Task<KeyValue> CallAsync( string func, int version = 1, Dictionary<string
/// <exception cref="InvalidDataException">An error occured when parsing the response from the WebAPI.</exception>
public async Task<KeyValue> CallAsync( HttpMethod method, string func, int version = 1, Dictionary<string, object?>? args = null )
{
var response = await CallAsyncInternal( method, func, version, args, "vdf" );
var response = await CallAsyncInternal( method, func, version, args, "vdf" ).ConfigureAwait( false );

using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait( false );

Expand Down
Loading