Skip to content

Commit

Permalink
add configureAwait(false) to missing places
Browse files Browse the repository at this point in the history
  • Loading branch information
mwwoda committed Nov 23, 2021
1 parent 817ca61 commit 505c613
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 62 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,6 @@ dotnet_diagnostic.CS0618.severity = suggestion

# CS0612: Default expression can be simplified
dotnet_diagnostic.IDE0034.severity = silent

# CA2007: Consider calling ConfigureAwait on the awaited task
dotnet_diagnostic.CA2007.severity = warning
2 changes: 1 addition & 1 deletion Box.V2/Auth/AuthRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public virtual async Task LogoutAsync()
_mutex.Release();
}

await InvalidateTokens(token);
await InvalidateTokens(token).ConfigureAwait(false);
}

#endregion
Expand Down
4 changes: 2 additions & 2 deletions Box.V2/Managers/BoxCollaborationWhitelistManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task<BoxCollectionMarkerBased<BoxCollaborationWhitelistEntry>> GetA

if (autoPaginate)
{
return await AutoPaginateMarker<BoxCollaborationWhitelistEntry>(request, limit);
return await AutoPaginateMarker<BoxCollaborationWhitelistEntry>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -163,7 +163,7 @@ public async Task<BoxCollectionMarkerBased<BoxCollaborationWhitelistTargetEntry>

if (autoPaginate)
{
return await AutoPaginateMarker<BoxCollaborationWhitelistTargetEntry>(request, limit);
return await AutoPaginateMarker<BoxCollaborationWhitelistTargetEntry>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Box.V2/Managers/BoxDevicePinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task<BoxCollectionMarkerBased<BoxDevicePin>> GetEnterpriseDevicePin

if (autoPaginate)
{
return await AutoPaginateMarker<BoxDevicePin>(request, limit);
return await AutoPaginateMarker<BoxDevicePin>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down
36 changes: 18 additions & 18 deletions Box.V2/Managers/BoxFilesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public async Task<BoxCollection<BoxSessionPartInfo>> GetSessionUploadedPartsAsyn
request.Param("offset", "0");
}

return await AutoPaginateLimitOffset<BoxSessionPartInfo>(request, limit.Value);
return await AutoPaginateLimitOffset<BoxSessionPartInfo>(request, limit.Value).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -476,7 +476,7 @@ public async Task<BoxSessionUploadStatus> GetSessionUploadStatusAsync(Uri sessio
public async Task<BoxFileVersion> UploadFileVersionUsingSessionAsync(Stream stream, string fileId, string fileName = null,
TimeSpan? timeout = null, IProgress<BoxProgress> progress = null)
{
var response = await UploadNewVersionUsingSessionAsync(stream, fileId, fileName, timeout, progress);
var response = await UploadNewVersionUsingSessionAsync(stream, fileId, fileName, timeout, progress).ConfigureAwait(false);
return response.FileVersion;
}

Expand All @@ -499,8 +499,8 @@ public async Task<BoxFile> UploadNewVersionUsingSessionAsync(Stream stream, stri
FileName = fileName
};

var boxFileVersionUploadSession = await CreateNewVersionUploadSessionAsync(fileId, uploadNewVersionSessionRequest);
var response = await UploadSessionAsync(stream, boxFileVersionUploadSession, timeout, progress);
var boxFileVersionUploadSession = await CreateNewVersionUploadSessionAsync(fileId, uploadNewVersionSessionRequest).ConfigureAwait(false);
var response = await UploadSessionAsync(stream, boxFileVersionUploadSession, timeout, progress).ConfigureAwait(false);
return response;
}

Expand All @@ -525,8 +525,8 @@ public async Task<BoxFile> UploadUsingSessionAsync(Stream stream, string fileNam
FolderId = folderId
};

var boxFileUploadSession = await CreateUploadSessionAsync(uploadSessionRequest);
var response = await UploadSessionAsync(stream, boxFileUploadSession, timeout, progress);
var boxFileUploadSession = await CreateUploadSessionAsync(uploadSessionRequest).ConfigureAwait(false);
var response = await UploadSessionAsync(stream, boxFileUploadSession, timeout, progress).ConfigureAwait(false);

return response;
}
Expand Down Expand Up @@ -566,7 +566,7 @@ private async Task<BoxFile> UploadSessionAsync(Stream stream, BoxFileUploadSessi
// Upload parts in session
var allSessionParts = await UploadPartsInSessionAsync(uploadPartUri,
numberOfParts, partSizeLong, stream,
fileSize, timeout, progress);
fileSize, timeout, progress).ConfigureAwait(false);

var allSessionPartsList = allSessionParts.ToList();

Expand Down Expand Up @@ -624,7 +624,7 @@ private async Task<IEnumerable<BoxSessionPartInfo>> UploadPartsInSessionAsync(
var tasks = new List<Task<BoxUploadPartResponse>>();
for (var i = 0; i < numberOfParts; i++)
{
await concurrencySemaphore.WaitAsync();
await concurrencySemaphore.WaitAsync().ConfigureAwait(false);

// Split file as per part size
var partOffset = partSize * i;
Expand All @@ -640,7 +640,7 @@ private async Task<IEnumerable<BoxSessionPartInfo>> UploadPartsInSessionAsync(
partFileStream.Position = 0;
var uploadPartResponse = await UploadPartAsync(
uploadPartsUri, sha, partOffset, fileSize, partFileStream,
timeout);
timeout).ConfigureAwait(false);

return uploadPartResponse;
}
Expand Down Expand Up @@ -881,7 +881,7 @@ public async Task<BoxCollectionMarkerBasedV2<BoxCollaboration>> GetCollaboration
request.Param("limit", limit.ToString());
}

return await AutoPaginateMarkerV2<BoxCollaboration>(request, limit.Value);
return await AutoPaginateMarkerV2<BoxCollaboration>(request, limit.Value).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -956,7 +956,7 @@ public async Task<Stream> GetThumbnailAsync(string id, int? minHeight = null, in
public async Task<Uri> GetPreviewLinkAsync(string id)
{
var fields = new List<string>() { "expiring_embed_link" };
var file = await GetInformationAsync(id, fields);
var file = await GetInformationAsync(id, fields).ConfigureAwait(false);
return file.ExpiringEmbedLink.Url;
}

Expand All @@ -970,7 +970,7 @@ public async Task<Uri> GetPreviewLinkAsync(string id)
[Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")]
public async Task<Stream> GetPreviewAsync(string id, int page, bool handleRetry = true)
{
return (await GetPreviewResponseAsync(id, page, handleRetry: handleRetry)).ResponseObject;
return (await GetPreviewResponseAsync(id, page, handleRetry: handleRetry).configureAwait(false)).ResponseObject;
}

/// <summary>
Expand All @@ -984,7 +984,7 @@ public async Task<Stream> GetPreviewAsync(string id, int page, bool handleRetry
[Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")]
public async Task<BoxFilePreview> GetFilePreviewAsync(string id, int page, int? maxWidth = null, int? minWidth = null, int? maxHeight = null, int? minHeight = null, bool handleRetry = true)
{
IBoxResponse<Stream> response = await GetPreviewResponseAsync(id, page, maxWidth, minWidth, maxHeight, minHeight, handleRetry);
IBoxResponse<Stream> response = await GetPreviewResponseAsync(id, page, maxWidth, minWidth, maxHeight, minHeight, handleRetry).configureAwait(false);

var filePreview = new BoxFilePreview
{
Expand Down Expand Up @@ -1138,7 +1138,7 @@ public async Task<BoxFileLock> UpdateLockAsync(BoxFileLockRequest lockFileReques
/// <returns>Returns information about locked file</returns>
public async Task<BoxFileLock> LockAsync(BoxFileLockRequest lockFileRequest, string id)
{
return await UpdateLockAsync(lockFileRequest, id);
return await UpdateLockAsync(lockFileRequest, id).configureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -1323,7 +1323,7 @@ public async Task<BoxRepresentationCollection<BoxRepresentation>> GetRepresentat
/// </summary>
public async Task<BoxZipDownloadStatus> DownloadZip(BoxZipRequest zipRequest, Stream output)
{
BoxZip createdZip = await CreateZip(zipRequest);
BoxZip createdZip = await CreateZip(zipRequest).configureAwait(false);
IBoxRequest downloadRequest = new BoxRequest(createdZip.DownloadUrl);
IBoxResponse<Stream> streamResponse = await ToResponseAsync<Stream>(downloadRequest).ConfigureAwait(false);
Stream fileStream = streamResponse.ResponseObject;
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public async Task<BoxZipDownloadStatus> DownloadZip(BoxZipRequest zipRequest, St
/// </summary>
public async Task<Stream> GetRepresentationContentAsync(BoxRepresentationRequest representationRequest, string assetPath = "")
{
var reps = await GetRepresentationsAsync(representationRequest);
var reps = await GetRepresentationsAsync(representationRequest).ConfigureAwait(false);
if (reps.Entries.Count == 0)
{
throw new BoxCodingException("Could not get requested representation!");
Expand All @@ -1380,7 +1380,7 @@ public async Task<Stream> GetRepresentationContentAsync(BoxRepresentationRequest
throw new BoxCodingException("Representation had error status");
case "none":
case "pending":
var urlTemplate = await PollRepresentationInfo(repInfo.Info.Url);
var urlTemplate = await PollRepresentationInfo(repInfo.Info.Url).ConfigureAwait(false);
downloadRequest = new BoxRequest(new Uri(urlTemplate.Replace("{+asset_path}", assetPath)));
response = await ToResponseAsync<Stream>(downloadRequest).ConfigureAwait(false);
return response.ResponseObject;
Expand Down Expand Up @@ -1415,7 +1415,7 @@ private async Task<string> PollRepresentationInfo(string infoUrl)
case "none":
case "pending":
await Task.Delay(1000);
return await PollRepresentationInfo(infoUrl);
return await PollRepresentationInfo(infoUrl).ConfigureAwait(false);
default:
throw new BoxCodingException("Representation has unknown status");
}
Expand Down
6 changes: 3 additions & 3 deletions Box.V2/Managers/BoxFoldersManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task<BoxCollection<BoxItem>> GetFolderItemsAsync(string id, int lim

if (autoPaginate)
{
return await AutoPaginateLimitOffset<BoxItem>(request, limit);
return await AutoPaginateLimitOffset<BoxItem>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -279,7 +279,7 @@ public async Task<BoxCollection<BoxItem>> GetTrashItemsAsync(int limit, int offs

if (autoPaginate)
{
return await AutoPaginateLimitOffset<BoxItem>(request, limit);
return await AutoPaginateLimitOffset<BoxItem>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -490,7 +490,7 @@ public async Task<BoxCollection<BoxFolderLock>> GetLocksAsync(string id, bool au

if (autoPaginate)
{
return await AutoPaginateLimitOffset<BoxFolderLock>(request, 1000);
return await AutoPaginateLimitOffset<BoxFolderLock>(request, 1000).ConfigureAwait(false);
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions Box.V2/Managers/BoxGroupsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task<BoxCollection<BoxGroup>> GetAllGroupsAsync(int? limit = null,
if (!offset.HasValue)
request.Param("offset", "0");

return await AutoPaginateLimitOffset<BoxGroup>(request, limit.Value);
return await AutoPaginateLimitOffset<BoxGroup>(request, limit.Value).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -209,7 +209,7 @@ public async Task<BoxCollection<BoxCollaboration>> GetCollaborationsForGroupAsyn
if (!offset.HasValue)
request.Param("offset", "0");

return await AutoPaginateLimitOffset<BoxCollaboration>(request, limit.Value);
return await AutoPaginateLimitOffset<BoxCollaboration>(request, limit.Value).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -247,7 +247,7 @@ public async Task<BoxCollection<BoxGroupMembership>> GetAllGroupMembershipsForGr
if (!offset.HasValue)
request.Param("offset", "0");

return await AutoPaginateLimitOffset<BoxGroupMembership>(request, limit.Value);
return await AutoPaginateLimitOffset<BoxGroupMembership>(request, limit.Value).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -287,7 +287,7 @@ public async Task<BoxCollection<BoxGroupMembership>> GetAllGroupMembershipsForUs
request.Param("offset", "0");
}

return await AutoPaginateLimitOffset<BoxGroupMembership>(request, limit.Value);
return await AutoPaginateLimitOffset<BoxGroupMembership>(request, limit.Value).ConfigureAwait(false);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions Box.V2/Managers/BoxLegalHoldPoliciesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<BoxCollectionMarkerBased<BoxLegalHoldPolicy>> GetListLegalHold

if (autoPaginate)
{
return await AutoPaginateMarker<BoxLegalHoldPolicy>(request, limit);
return await AutoPaginateMarker<BoxLegalHoldPolicy>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -170,7 +170,7 @@ public async Task<BoxCollectionMarkerBased<BoxLegalHoldPolicyAssignment>> GetAss

if (autoPaginate)
{
return await AutoPaginateMarker<BoxLegalHoldPolicyAssignment>(request, limit);
return await AutoPaginateMarker<BoxLegalHoldPolicyAssignment>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -254,7 +254,7 @@ public async Task<BoxCollectionMarkerBased<BoxFileVersionLegalHold>> GetFileVers

if (autoPaginate)
{
return await AutoPaginateMarker<BoxFileVersionLegalHold>(request, limit);
return await AutoPaginateMarker<BoxFileVersionLegalHold>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Box.V2/Managers/BoxMetadataCascadePolicyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task<BoxCollectionMarkerBased<BoxMetadataCascadePolicy>> GetAllMeta

if (autopaginate)
{
return await AutoPaginateMarker<BoxMetadataCascadePolicy>(request, limit);
return await AutoPaginateMarker<BoxMetadataCascadePolicy>(request, limit).ConfigureAwait(false);
}
else
{
Expand Down
Loading

0 comments on commit 505c613

Please sign in to comment.