diff --git a/SteamKit2/SteamKit2/.editorconfig b/SteamKit2/SteamKit2/.editorconfig new file mode 100644 index 000000000..8454a7561 --- /dev/null +++ b/SteamKit2/SteamKit2/.editorconfig @@ -0,0 +1,5 @@ +root = false + +[*.cs] +# CA2007: Consider calling ConfigureAwait on the awaited task +dotnet_diagnostic.CA2007.severity = warning diff --git a/SteamKit2/SteamKit2/Steam/CDN/Client.cs b/SteamKit2/SteamKit2/Steam/CDN/Client.cs index fa96b7e23..207f9f93d 100644 --- a/SteamKit2/SteamKit2/Steam/CDN/Client.cs +++ b/SteamKit2/SteamKit2/Steam/CDN/Client.cs @@ -123,7 +123,7 @@ public async Task 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 ) { @@ -134,7 +134,7 @@ public async Task DownloadManifestAsync( uint depotId, ulong mani } else { - var data = await response.Content.ReadAsByteArrayAsync(); + var data = await response.Content.ReadAsByteArrayAsync().ConfigureAwait( false ); ms = new MemoryStream( data ); } @@ -281,7 +281,7 @@ public async Task 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 ) { @@ -299,7 +299,7 @@ public async Task 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 ) { diff --git a/SteamKit2/SteamKit2/Steam/CDN/ClientLancache.cs b/SteamKit2/SteamKit2/Steam/CDN/ClientLancache.cs index 60324cefa..613dc4759 100644 --- a/SteamKit2/SteamKit2/Steam/CDN/ClientLancache.cs +++ b/SteamKit2/SteamKit2/Steam/CDN/ClientLancache.cs @@ -29,7 +29,8 @@ public partial class Client /// 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(); diff --git a/SteamKit2/SteamKit2/Steam/SteamClient/CallbackMgr/CallbackMgr.cs b/SteamKit2/SteamKit2/Steam/SteamClient/CallbackMgr/CallbackMgr.cs index 38192ebbe..37921b1ad 100644 --- a/SteamKit2/SteamKit2/Steam/SteamClient/CallbackMgr/CallbackMgr.cs +++ b/SteamKit2/SteamKit2/Steam/SteamClient/CallbackMgr/CallbackMgr.cs @@ -105,7 +105,7 @@ public void RunWaitCallbacks() /// public async Task RunWaitCallbackAsync( CancellationToken cancellationToken = default ) { - var call = await client.WaitForCallbackAsync( cancellationToken ); + var call = await client.WaitForCallbackAsync( cancellationToken ).ConfigureAwait( false ); Handle( call ); } diff --git a/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs b/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs index 79d9fe9e2..05f6f7910 100644 --- a/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs +++ b/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs @@ -237,7 +237,7 @@ internal AsyncInterface( HttpClient httpClient, string iface, string apiKey ) /// An error occured when parsing the response from the WebAPI. public async Task CallProtobufAsync( HttpMethod method, string func, int version = 1, Dictionary? 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 ); @@ -282,7 +282,7 @@ public async Task> CallProtobufAsync CallAsync( string func, int version = 1, DictionaryAn error occured when parsing the response from the WebAPI. public async Task CallAsync( HttpMethod method, string func, int version = 1, Dictionary? 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 );