Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Address missing ConfigureAwait(false) and unnecessary awaits.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarmer-msft committed Aug 1, 2019
1 parent 1312900 commit 8d51333
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/Blob/CloudBlobContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ await Executor.ExecuteAsync(
this.DeleteContainerImpl(accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken).ConfigureAwait(false);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/Blob/CloudPageBlob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,7 @@ await Executor.ExecuteAsync(
this.PutPageImpl(new AggregatingProgressIncrementer(progressHandler).CreateProgressIncrementingStream(seekableStream), startOffset, contentChecksum, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken).ConfigureAwait(false);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/File/CloudFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3840,7 +3840,7 @@ await Executor.ExecuteAsync(
options: modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken.Value);
cancellationToken.Value).ConfigureAwait(false);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/File/CloudFileShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ private RESTCommand<string> GetFilePermissionImp(string filePermissionKey, FileR
getCmd.PostProcessResponseAsync = async (cmd, resp, ex, ctx) =>
{
StreamReader reader = new StreamReader(cmd.ResponseStream);
string json = await reader.ReadToEndAsync();
string json = await reader.ReadToEndAsync().ConfigureAwait(false);
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
return dictionary[Constants.Permission.ToLowerInvariant()];
};
Expand Down
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/File/FileWriteStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc

if (continueTCS == null)
{
await continueTask;
await continueTask.ConfigureAwait(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public static Stream AsStreamForWrite(this Stream stream)
/// <param name="stream">input stream</param>
/// <param name="buffer">buffer to write to the stream</param>
/// <returns>Async task</returns>
public static async Task WriteAsync(this Stream stream, byte[] buffer)
public static Task WriteAsync(this Stream stream, byte[] buffer)
{
await stream.WriteAsync(buffer, 0, buffer.Length);
return stream.WriteAsync(buffer, 0, buffer.Length);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Lib/Common/Blob/Protocol/GetPageDiffRangesResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static async Task<PageDiffRange> ParsePageDiffRangeAsync(XmlReader reade
break;

default:
await reader.SkipAsync();
await reader.SkipAsync().ConfigureAwait(false);
break;
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ internal static async Task<IEnumerable<PageDiffRange>> ParseAsync(Stream stream,

if (await reader.IsStartElementAsync(Constants.ClearRangeElement).ConfigureAwait(false))
{
ranges.Add(await ParsePageDiffRangeAsync(reader, true /* isClear */, token));
ranges.Add(await ParsePageDiffRangeAsync(reader, true /* isClear */, token).ConfigureAwait(false));
}
else if (await reader.IsStartElementAsync(Constants.PageRangeElement).ConfigureAwait(false))
{
Expand Down
4 changes: 2 additions & 2 deletions Lib/Common/Core/Util/AsyncExtensions.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ public async Task Set()
{
TaskCompletionSource<bool> tcs = m_tcs;
await Task.Factory.StartNew(s => ((TaskCompletionSource<bool>)s).TrySetResult(true),
tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default);
await tcs.Task;
tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default).ConfigureAwait(false);
await tcs.Task.ConfigureAwait(false);
}

public void Reset()
Expand Down
2 changes: 1 addition & 1 deletion Lib/Common/Core/Util/CounterEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task DecrementAsync()
}
if (setEvent)
{
await this.internalEvent.Set();
await this.internalEvent.Set().ConfigureAwait(false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Lib/Common/File/Protocol/ListSharesResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal static async Task<ListSharesResponse> ParseAsync(Stream stream, Cancell

case Constants.SharesElement:
await reader.ReadStartElementAsync().ConfigureAwait(false);
while (await reader.IsStartElementAsync(Constants.ShareElement))
while (await reader.IsStartElementAsync(Constants.ShareElement).ConfigureAwait(false))
{
shares.Add(await ParseShareEntryAsync(reader, baseUri, token).ConfigureAwait(false));
}
Expand Down
2 changes: 1 addition & 1 deletion Lib/Common/Shared/Protocol/GetUserDelegationKeyResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static async Task<UserDelegationKey> ParseAsync(Stream stream, Cancella
}
else
{
key = await ParseKey(reader, token);
key = await ParseKey(reader, token).ConfigureAwait(false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lib/WindowsRuntime/Blob/CloudBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public virtual Task<AccountProperties> GetAccountPropertiesAsync(BlobRequestOpti
operationContext = operationContext ?? new OperationContext();

return Task.Run(
async () => await Executor.ExecuteAsync(
() => Executor.ExecuteAsync(
this.GetAccountPropertiesImpl(modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
Expand Down
6 changes: 3 additions & 3 deletions Lib/WindowsRuntime/Blob/CloudBlockBlob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ await Executor.ExecuteAsyncNullReturn(
this.PutBlockImpl(progressIncrementer.CreateProgressIncrementingStream(seekableStream), blockId, contentChecksum, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken).ConfigureAwait(false);
}
finally
{
Expand All @@ -897,12 +897,12 @@ await Executor.ExecuteAsyncNullReturn(
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task"/> that represents an asynchronous action.</returns>
[DoesServiceRequest]
public virtual async Task PutBlockAsync(string blockId, Uri sourceUri, long? offset, long? count, Checksum contentChecksum, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task PutBlockAsync(string blockId, Uri sourceUri, long? offset, long? count, Checksum contentChecksum, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
{
BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient);
operationContext = operationContext ?? new OperationContext();

await Executor.ExecuteAsyncNullReturn(
return Executor.ExecuteAsyncNullReturn(
this.PutBlockImpl(sourceUri, offset, count, contentChecksum, blockId, accessCondition, modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
Expand Down
12 changes: 6 additions & 6 deletions Lib/WindowsRuntime/File/CloudFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task"/> that represents an asynchronous action.</returns>
[DoesServiceRequest]
public virtual async Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, IProgress<StorageProgress> progressHandler, CancellationToken cancellationToken)
public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, IProgress<StorageProgress> progressHandler, CancellationToken cancellationToken)
#else
/// <summary>
/// Downloads the contents of a file to a stream.
Expand All @@ -1051,7 +1051,7 @@ public virtual async Task DownloadRangeToStreamAsync(Stream target, long? offset
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
/// <returns>A <see cref="Task"/> that represents an asynchronous action.</returns>
[DoesServiceRequest]
public virtual async Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
public virtual Task DownloadRangeToStreamAsync(Stream target, long? offset, long? length, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
#endif
{
CommonUtility.AssertNotNull("target", target);
Expand All @@ -1060,7 +1060,7 @@ public virtual async Task DownloadRangeToStreamAsync(Stream target, long? offset

// We should always call AsStreamForWrite with bufferSize=0 to prevent buffering. Our
// stream copier only writes 64K buffers at a time anyway, so no buffering is needed.
await Executor.ExecuteAsyncNullReturn(
return Executor.ExecuteAsyncNullReturn(
#if NETCORE
this.GetFileImpl(new AggregatingProgressIncrementer(progressHandler).CreateProgressIncrementingStream(target), offset, length, accessCondition, modifiedOptions),
#else
Expand Down Expand Up @@ -1638,7 +1638,7 @@ public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileReques
/// <param name="operationContext">An object that represents the context for the current operation.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for a task to complete.</param>
[DoesServiceRequest]
public virtual async Task WriteRangeAsync(
public virtual Task WriteRangeAsync(
Uri sourceUri,
long sourceOffset,
long count,
Expand All @@ -1660,7 +1660,7 @@ public virtual async Task WriteRangeAsync(
operationContext = operationContext ?? new OperationContext();
cancellationToken = cancellationToken ?? CancellationToken.None;

await Executor.ExecuteAsync(
return Executor.ExecuteAsync(
this.PutRangeFromUriImpl(
sourceUri: sourceUri,
sourceOffset: sourceOffset,
Expand Down Expand Up @@ -1836,7 +1836,7 @@ await Executor.ExecuteAsyncNullReturn(
#endif
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken);
cancellationToken).ConfigureAwait(false);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion Lib/WindowsRuntime/File/CloudFileShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ private RESTCommand<string> GetFilePermissionImp(string filePermissionKey, FileR
getCmd.PostProcessResponseAsync = async (cmd, resp, ex, ctx) =>
{
StreamReader reader = new StreamReader(cmd.ResponseStream);
string json = await reader.ReadToEndAsync();
string json = await reader.ReadToEndAsync().ConfigureAwait(false);
return json.Split('"')[3];
};

Expand Down

0 comments on commit 8d51333

Please sign in to comment.