Skip to content

Commit 9f4513e

Browse files
committed
Use ConfigureAwait in a library methods
1 parent ef042b8 commit 9f4513e

11 files changed

Lines changed: 112 additions & 112 deletions

src/corelib/Compute/v2_1/ComputeService.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
7676
/// <inheritdoc cref="ComputeApi.ListServerSummariesAsync{TPage}" />
7777
public async Task<IPage<ServerSummary>> ListServerSummariesAsync(ServerListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
7878
{
79-
return await _computeApi.ListServerSummariesAsync<ServerSummaryCollection>(options, cancellationToken);
79+
return await _computeApi.ListServerSummariesAsync<ServerSummaryCollection>(options, cancellationToken).ConfigureAwait(false);
8080
}
8181

8282
/// <inheritdoc cref="ComputeApi.ListServersAsync{TPage}(IQueryStringBuilder,CancellationToken)" />
8383
public async Task<IPage<Server>> ListServersAsync(ServerListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
8484
{
85-
return await _computeApi.ListServersAsync<ServerCollection>(options, cancellationToken);
85+
return await _computeApi.ListServersAsync<ServerCollection>(options, cancellationToken).ConfigureAwait(false);
8686
}
8787

8888
/// <inheritdoc cref="ComputeApi.UpdateServerAsync{T}" />
@@ -209,7 +209,7 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
209209
/// <inheritdoc cref="ComputeApi.ListServerActionSummariesAsync{T}" />
210210
public virtual async Task<IEnumerable<ServerActionSummary>> ListServerActionSummariesAsync(Identifier serverId, CancellationToken cancellationToken = default(CancellationToken))
211211
{
212-
return await _computeApi.ListServerActionSummariesAsync<ServerActionSummaryCollection>(serverId, cancellationToken);
212+
return await _computeApi.ListServerActionSummariesAsync<ServerActionSummaryCollection>(serverId, cancellationToken).ConfigureAwait(false);
213213
}
214214

215215
/// <inheritdoc cref="ComputeApi.ListServerActionSummariesAsync{T}" />
@@ -230,13 +230,13 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
230230
/// <inheritdoc cref="ComputeApi.ListFlavorSummariesAsync{T}" />
231231
public async Task<IEnumerable<FlavorSummary>> ListFlavorSummariesAsync(CancellationToken cancellationToken = default(CancellationToken))
232232
{
233-
return await _computeApi.ListFlavorSummariesAsync<FlavorSummaryCollection>(cancellationToken);
233+
return await _computeApi.ListFlavorSummariesAsync<FlavorSummaryCollection>(cancellationToken).ConfigureAwait(false);
234234
}
235235

236236
/// <inheritdoc cref="ComputeApi.ListFlavorsAsync{T}" />
237237
public async Task<IEnumerable<Flavor>> ListFlavorsAsync(CancellationToken cancellationToken = default(CancellationToken))
238238
{
239-
return await _computeApi.ListFlavorsAsync<FlavorCollection>(cancellationToken);
239+
return await _computeApi.ListFlavorsAsync<FlavorCollection>(cancellationToken).ConfigureAwait(false);
240240
}
241241

242242
#endregion
@@ -276,13 +276,13 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
276276
/// <inheritdoc cref="ComputeApi.ListImageSummariesAsync{TPage}" />
277277
public async Task<IPage<ImageSummary>> ListImageSummariesAsync(ImageListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
278278
{
279-
return await _computeApi.ListImageSummariesAsync<ImageSummaryCollection>(options, cancellationToken);
279+
return await _computeApi.ListImageSummariesAsync<ImageSummaryCollection>(options, cancellationToken).ConfigureAwait(false);
280280
}
281281

282282
/// <inheritdoc cref="ComputeApi.ListImagesAsync{TPage}" />
283283
public async Task<IPage<Image>> ListImagesAsync(ImageListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
284284
{
285-
return await _computeApi.ListImagesAsync<ImageCollection>(options, cancellationToken);
285+
return await _computeApi.ListImagesAsync<ImageCollection>(options, cancellationToken).ConfigureAwait(false);
286286
}
287287

288288
/// <inheritdoc cref="ComputeApi.UpdateImageMetadataAsync{T}" />
@@ -321,22 +321,22 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
321321
/// <inheritdoc cref="ComputeApi.ListServerAddressesAsync{T}" />
322322
public async Task<IDictionary<string, IList<ServerAddress>>> ListServerAddressesAsync(Identifier serverId, CancellationToken cancellationToken = default(CancellationToken))
323323
{
324-
return await _computeApi.ListServerAddressesAsync<ServerAddressCollection>(serverId, cancellationToken);
324+
return await _computeApi.ListServerAddressesAsync<ServerAddressCollection>(serverId, cancellationToken).ConfigureAwait(false);
325325
}
326326

327327
#endregion
328328

329329
#region Server Volumes
330330
/// <inheritdoc cref="ComputeApi.GetServerVolumeAsync{T}" />
331-
public async Task<ServerVolume> GetServerVolumeAsync(Identifier serverId, Identifier volumeId, CancellationToken cancellationToken = default(CancellationToken))
331+
public Task<ServerVolume> GetServerVolumeAsync(Identifier serverId, Identifier volumeId, CancellationToken cancellationToken = default(CancellationToken))
332332
{
333-
return await _computeApi.GetServerVolumeAsync<ServerVolume>(serverId, volumeId, cancellationToken);
333+
return _computeApi.GetServerVolumeAsync<ServerVolume>(serverId, volumeId, cancellationToken);
334334
}
335335

336336
/// <inheritdoc cref="ComputeApi.ListServerVolumesAsync{T}" />
337337
public async Task<IEnumerable<ServerVolume>> ListServerVolumesAsync(Identifier serverId, CancellationToken cancellationToken = default(CancellationToken))
338338
{
339-
return await _computeApi.ListServerVolumesAsync<ServerVolumeCollection>(serverId, cancellationToken);
339+
return await _computeApi.ListServerVolumesAsync<ServerVolumeCollection>(serverId, cancellationToken).ConfigureAwait(false);
340340
}
341341

342342
/// <inheritdoc cref="ComputeApi.AttachVolumeAsync{T}" />
@@ -375,7 +375,7 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
375375
/// <inheritdoc cref="ComputeApi.ListKeyPairsAsync{T}" />
376376
public virtual async Task<IEnumerable<KeyPairSummary>> ListKeyPairsAsync(CancellationToken cancellationToken = default(CancellationToken))
377377
{
378-
return await _computeApi.ListKeyPairsAsync<KeyPairSummaryCollection>(cancellationToken);
378+
return await _computeApi.ListKeyPairsAsync<KeyPairSummaryCollection>(cancellationToken).ConfigureAwait(false);
379379
}
380380

381381
/// <summary />
@@ -402,7 +402,7 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
402402
/// <inheritdoc cref="ComputeApi.ListSecurityGroupsAsync{T}" />
403403
public async Task<IEnumerable<SecurityGroup>> ListSecurityGroupsAsync(Identifier serverId = null, CancellationToken cancellationToken = default(CancellationToken))
404404
{
405-
return await _computeApi.ListSecurityGroupsAsync<SecurityGroupCollection>(serverId, cancellationToken);
405+
return await _computeApi.ListSecurityGroupsAsync<SecurityGroupCollection>(serverId, cancellationToken).ConfigureAwait(false);
406406
}
407407

408408
/// <inheritdoc cref="ComputeApi.UpdateSecurityGroupAsync{T}" />
@@ -436,7 +436,7 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
436436
/// <inheritdoc cref="ComputeApi.ListServerGroupsAsync{T}" />
437437
public async Task<IEnumerable<ServerGroup>> ListServerGroupsAsync(CancellationToken cancellationToken = default(CancellationToken))
438438
{
439-
return await _computeApi.ListServerGroupsAsync<ServerGroupCollection>(cancellationToken);
439+
return await _computeApi.ListServerGroupsAsync<ServerGroupCollection>(cancellationToken).ConfigureAwait(false);
440440
}
441441

442442
/// <inheritdoc cref="ComputeApi.DeleteServerGroupAsync" />
@@ -482,7 +482,7 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
482482
/// <inheritdoc cref="ComputeApi.ListVolumesAsync{T}" />
483483
public async Task<IEnumerable<Volume>> ListVolumesAsync(CancellationToken cancellationToken = default(CancellationToken))
484484
{
485-
return await _computeApi.ListVolumesAsync<VolumeCollection>(cancellationToken);
485+
return await _computeApi.ListVolumesAsync<VolumeCollection>(cancellationToken).ConfigureAwait(false);
486486
}
487487

488488
///// <inheritdoc cref="ComputeApiBuilder.ListVolumeTypesAsync{T}" />
@@ -494,7 +494,7 @@ public ComputeService(IAuthenticationProvider authenticationProvider, string reg
494494
/// <inheritdoc cref="ComputeApi.ListVolumeSnapshotsAsync{T}" />
495495
public async Task<IEnumerable<VolumeSnapshot>> ListVolumeSnapshotsAsync(CancellationToken cancellationToken = default(CancellationToken))
496496
{
497-
return await _computeApi.ListVolumeSnapshotsAsync<VolumeSnapshotCollection>(cancellationToken);
497+
return await _computeApi.ListVolumeSnapshotsAsync<VolumeSnapshotCollection>(cancellationToken).ConfigureAwait(false);
498498
}
499499

500500
/// <inheritdoc cref="ComputeApi.DeleteVolumeAsync" />

src/corelib/Compute/v2_1/ImageMetadata.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void AssertParentIsSet([CallerMemberName]string callerName = "")
5454
{
5555
AssertParentIsSet();
5656
var compute = this.GetOwnerOrThrow<ComputeApi>();
57-
await compute.CreateImageMetadataAsync(Image.Id, key, value, cancellationToken);
57+
await compute.CreateImageMetadataAsync(Image.Id, key, value, cancellationToken).ConfigureAwait(false);
5858
this[key] = value;
5959
}
6060

@@ -63,7 +63,7 @@ protected void AssertParentIsSet([CallerMemberName]string callerName = "")
6363
{
6464
AssertParentIsSet();
6565
var compute = this.GetOwnerOrThrow<ComputeApi>();
66-
var results = await compute.UpdateImageMetadataAsync<ImageMetadata>(Image.Id, this, overwrite, cancellationToken);
66+
var results = await compute.UpdateImageMetadataAsync<ImageMetadata>(Image.Id, this, overwrite, cancellationToken).ConfigureAwait(false);
6767
Clear();
6868
foreach (var result in results)
6969
{
@@ -79,7 +79,7 @@ protected void AssertParentIsSet([CallerMemberName]string callerName = "")
7979

8080
AssertParentIsSet();
8181
var compute = this.GetOwnerOrThrow<ComputeApi>();
82-
await compute.DeleteImageMetadataAsync(Image.Id, key, cancellationToken);
82+
await compute.DeleteImageMetadataAsync(Image.Id, key, cancellationToken).ConfigureAwait(false);
8383
Remove(key);
8484
}
8585
}

src/corelib/Compute/v2_1/ImageReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ImageReference : IHaveExtraData, IServiceResource
5252
public virtual async Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
5353
{
5454
var owner = this.GetOwnerOrThrow<ComputeApi>();
55-
await owner.DeleteImageAsync(Id, cancellationToken);
55+
await owner.DeleteImageAsync(Id, cancellationToken).ConfigureAwait(false);
5656
}
5757

5858
/// <inheritdoc cref="ComputeApi.WaitUntilImageIsDeletedAsync{TImage,TStatus}" />

src/corelib/Compute/v2_1/SecurityGroup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public SecurityGroup()
3838
var compute = this.GetOwnerOrThrow<ComputeApi>();
3939
var request = new SecurityGroupDefinition(Name, Description);
4040

41-
var result = await compute.UpdateSecurityGroupAsync<SecurityGroup>(Id, request, cancellationToken);
41+
var result = await compute.UpdateSecurityGroupAsync<SecurityGroup>(Id, request, cancellationToken).ConfigureAwait(false);
4242
result.CopyProperties(this);
4343
}
4444

@@ -49,7 +49,7 @@ public SecurityGroup()
4949
var compute = this.GetOwnerOrThrow<ComputeApi>();
5050
rule.GroupId = Id;
5151

52-
var result = await compute.CreateSecurityGroupRuleAsync<SecurityGroupRule>(rule, cancellationToken);
52+
var result = await compute.CreateSecurityGroupRuleAsync<SecurityGroupRule>(rule, cancellationToken).ConfigureAwait(false);
5353
Rules.Add(result);
5454
return result;
5555
}

src/corelib/Compute/v2_1/SecurityGroupReference.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private async Task<SecurityGroup> LoadSecurityGroup(CancellationToken cancellati
3232
var owner = this.GetOwnerOrThrow<ComputeApi>();
3333

3434
// In some cases, such as when working with the groups on a server, we only have the name and not the id
35-
var groups = await owner.ListSecurityGroupsAsync<SecurityGroupCollection>(cancellationToken: cancellationToken);
35+
var groups = await owner.ListSecurityGroupsAsync<SecurityGroupCollection>(cancellationToken: cancellationToken).ConfigureAwait(false);
3636
securityGroup = groups.FirstOrDefault(x => x.Name == Name);
3737
if(securityGroup == null)
3838
throw new Exception($"Unable to find the security group named: {Name}.");
@@ -42,19 +42,19 @@ private async Task<SecurityGroup> LoadSecurityGroup(CancellationToken cancellati
4242

4343
/// <inheritdoc cref="ComputeApi.GetSecurityGroupAsync{T}" />
4444
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
45-
public async Task<SecurityGroup> GetSecurityGroupAsync(CancellationToken cancellationToken = default(CancellationToken))
45+
public Task<SecurityGroup> GetSecurityGroupAsync(CancellationToken cancellationToken = default(CancellationToken))
4646
{
47-
return await LoadSecurityGroup(cancellationToken);
47+
return LoadSecurityGroup(cancellationToken);
4848
}
4949

5050
/// <inheritdoc cref="ComputeApi.DeleteSecurityGroupAsync" />
5151
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
5252
public async Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
5353
{
5454
var owner = this.GetOwnerOrThrow<ComputeApi>();
55-
var securityGroup = await LoadSecurityGroup(cancellationToken);
55+
var securityGroup = await LoadSecurityGroup(cancellationToken).ConfigureAwait(false);
5656

57-
await owner.DeleteSecurityGroupAsync(securityGroup.Id, cancellationToken);
57+
await owner.DeleteSecurityGroupAsync(securityGroup.Id, cancellationToken).ConfigureAwait(false);
5858
}
5959
}
6060
}

src/corelib/Compute/v2_1/SecurityGroupRule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public string CIDR
5757

5858
/// <inheritdoc cref="ComputeApi.DeleteSecurityGroupRuleAsync" />
5959
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
60-
public async Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
60+
public Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
6161
{
6262
var owner = this.GetOwnerOrThrow<ComputeApi>();
63-
await owner.DeleteSecurityGroupRuleAsync(Id, cancellationToken);
63+
return owner.DeleteSecurityGroupRuleAsync(Id, cancellationToken);
6464
}
6565

6666
private class CIDRWrapper

0 commit comments

Comments
 (0)