From b16267e8f3dca5396e87be660e30a1e9405d8139 Mon Sep 17 00:00:00 2001 From: Mateusz Woda Date: Tue, 23 Nov 2021 14:36:05 +0100 Subject: [PATCH] fix: add missing configureAwait(false) when awaiting to prevent deadlocks (#775) --- .editorconfig | 3 ++ Box.V2/Auth/AuthRepository.cs | 4 +- .../BoxCollaborationWhitelistManager.cs | 4 +- Box.V2/Managers/BoxDevicePinManager.cs | 2 +- Box.V2/Managers/BoxFilesManager.cs | 42 +++++++++---------- Box.V2/Managers/BoxFoldersManager.cs | 6 +-- Box.V2/Managers/BoxGroupsManager.cs | 8 ++-- .../Managers/BoxLegalHoldPoliciesManager.cs | 6 +-- .../BoxMetadataCascadePolicyManager.cs | 2 +- Box.V2/Managers/BoxMetadataManager.cs | 28 ++++++------- Box.V2/Managers/BoxRecentItemsManager.cs | 2 +- .../Managers/BoxRetentionPoliciesManager.cs | 10 ++--- Box.V2/Managers/BoxSignRequestsManager.cs | 2 +- Box.V2/Managers/BoxStoragePoliciesManager.cs | 8 ++-- Box.V2/Managers/BoxUsersManager.cs | 6 +-- Box.V2/Managers/BoxWebhooksManager.cs | 2 +- Box.V2/Utility/Retry.cs | 8 ++-- 17 files changed, 73 insertions(+), 70 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4e33bf0f9..68add9cce 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 \ No newline at end of file diff --git a/Box.V2/Auth/AuthRepository.cs b/Box.V2/Auth/AuthRepository.cs index 95a1ebe64..8634dd677 100644 --- a/Box.V2/Auth/AuthRepository.cs +++ b/Box.V2/Auth/AuthRepository.cs @@ -71,7 +71,7 @@ public AuthRepository(IBoxConfig boxConfig, IBoxService boxService, IBoxConverte /// The session of the Box Client after authentification public virtual async Task AuthenticateAsync(string authCode) { - OAuthSession session = await ExchangeAuthCode(authCode); + OAuthSession session = await ExchangeAuthCode(authCode).ConfigureAwait(false); await _mutex.WaitAsync().ConfigureAwait(false); // using (await _mutex.LockAsync().ConfigureAwait(false)) @@ -147,7 +147,7 @@ public virtual async Task LogoutAsync() _mutex.Release(); } - await InvalidateTokens(token); + await InvalidateTokens(token).ConfigureAwait(false); } #endregion diff --git a/Box.V2/Managers/BoxCollaborationWhitelistManager.cs b/Box.V2/Managers/BoxCollaborationWhitelistManager.cs index b0234a098..16615ffa8 100644 --- a/Box.V2/Managers/BoxCollaborationWhitelistManager.cs +++ b/Box.V2/Managers/BoxCollaborationWhitelistManager.cs @@ -75,7 +75,7 @@ public async Task> GetA if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -163,7 +163,7 @@ public async Task if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxDevicePinManager.cs b/Box.V2/Managers/BoxDevicePinManager.cs index dcd99676d..4052f77fe 100644 --- a/Box.V2/Managers/BoxDevicePinManager.cs +++ b/Box.V2/Managers/BoxDevicePinManager.cs @@ -34,7 +34,7 @@ public async Task> GetEnterpriseDevicePin if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxFilesManager.cs b/Box.V2/Managers/BoxFilesManager.cs index 7550cbca5..8cecc6ea2 100644 --- a/Box.V2/Managers/BoxFilesManager.cs +++ b/Box.V2/Managers/BoxFilesManager.cs @@ -439,7 +439,7 @@ public async Task> GetSessionUploadedPartsAsyn request.Param("offset", "0"); } - return await AutoPaginateLimitOffset(request, limit.Value); + return await AutoPaginateLimitOffset(request, limit.Value).ConfigureAwait(false); } else { @@ -476,7 +476,7 @@ public async Task GetSessionUploadStatusAsync(Uri sessio public async Task UploadFileVersionUsingSessionAsync(Stream stream, string fileId, string fileName = null, TimeSpan? timeout = null, IProgress 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; } @@ -499,8 +499,8 @@ public async Task 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; } @@ -525,8 +525,8 @@ public async Task 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; } @@ -566,7 +566,7 @@ private async Task 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(); @@ -588,7 +588,7 @@ private async Task UploadSessionAsync(Stream stream, BoxFileUploadSessi await Retry.ExecuteAsync( async () => await CommitSessionAsync(commitUri, fullFileSha1, - sessionPartsForCommit), + sessionPartsForCommit).ConfigureAwait(false), TimeSpan.FromMilliseconds(retryInterval), RetryCount); return fileResponse; } @@ -598,7 +598,7 @@ await CommitSessionAsync(commitUri, fullFileSha1, await Retry.ExecuteAsync( async () => await CommitFileVersionSessionAsync(commitUri, fullFileSha1, - sessionPartsForCommit), + sessionPartsForCommit).ConfigureAwait(false), TimeSpan.FromMilliseconds(retryInterval), RetryCount); return versionResponse; } @@ -624,7 +624,7 @@ private async Task> UploadPartsInSessionAsync( var tasks = new List>(); 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; @@ -640,7 +640,7 @@ private async Task> UploadPartsInSessionAsync( partFileStream.Position = 0; var uploadPartResponse = await UploadPartAsync( uploadPartsUri, sha, partOffset, fileSize, partFileStream, - timeout); + timeout).ConfigureAwait(false); return uploadPartResponse; } @@ -666,7 +666,7 @@ private async Task> UploadPartsInSessionAsync( tasks.Add(uploadPartWithRetryTask); } - var results = await Task.WhenAll(tasks); + var results = await Task.WhenAll(tasks).ConfigureAwait(false); ret.AddRange(results.Select(elem => elem.Part)); } @@ -881,7 +881,7 @@ public async Task> GetCollaboration request.Param("limit", limit.ToString()); } - return await AutoPaginateMarkerV2(request, limit.Value); + return await AutoPaginateMarkerV2(request, limit.Value).ConfigureAwait(false); } else { @@ -956,7 +956,7 @@ public async Task GetThumbnailAsync(string id, int? minHeight = null, in public async Task GetPreviewLinkAsync(string id) { var fields = new List() { "expiring_embed_link" }; - var file = await GetInformationAsync(id, fields); + var file = await GetInformationAsync(id, fields).ConfigureAwait(false); return file.ExpiringEmbedLink.Url; } @@ -970,7 +970,7 @@ public async Task GetPreviewLinkAsync(string id) [Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")] public async Task 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; } /// @@ -984,7 +984,7 @@ public async Task GetPreviewAsync(string id, int page, bool handleRetry [Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")] public async Task GetFilePreviewAsync(string id, int page, int? maxWidth = null, int? minWidth = null, int? maxHeight = null, int? minHeight = null, bool handleRetry = true) { - IBoxResponse response = await GetPreviewResponseAsync(id, page, maxWidth, minWidth, maxHeight, minHeight, handleRetry); + IBoxResponse response = await GetPreviewResponseAsync(id, page, maxWidth, minWidth, maxHeight, minHeight, handleRetry).ConfigureAwait(false); var filePreview = new BoxFilePreview { @@ -1138,7 +1138,7 @@ public async Task UpdateLockAsync(BoxFileLockRequest lockFileReques /// Returns information about locked file public async Task LockAsync(BoxFileLockRequest lockFileRequest, string id) { - return await UpdateLockAsync(lockFileRequest, id); + return await UpdateLockAsync(lockFileRequest, id).ConfigureAwait(false); } /// @@ -1323,7 +1323,7 @@ public async Task> GetRepresentat /// public async Task DownloadZip(BoxZipRequest zipRequest, Stream output) { - BoxZip createdZip = await CreateZip(zipRequest); + BoxZip createdZip = await CreateZip(zipRequest).ConfigureAwait(false); IBoxRequest downloadRequest = new BoxRequest(createdZip.DownloadUrl); IBoxResponse streamResponse = await ToResponseAsync(downloadRequest).ConfigureAwait(false); Stream fileStream = streamResponse.ResponseObject; @@ -1360,7 +1360,7 @@ public async Task DownloadZip(BoxZipRequest zipRequest, St /// public async Task 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!"); @@ -1380,7 +1380,7 @@ public async Task 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(downloadRequest).ConfigureAwait(false); return response.ResponseObject; @@ -1415,7 +1415,7 @@ private async Task 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"); } diff --git a/Box.V2/Managers/BoxFoldersManager.cs b/Box.V2/Managers/BoxFoldersManager.cs index 93edfe9d0..509c0db44 100644 --- a/Box.V2/Managers/BoxFoldersManager.cs +++ b/Box.V2/Managers/BoxFoldersManager.cs @@ -69,7 +69,7 @@ public async Task> GetFolderItemsAsync(string id, int lim if (autoPaginate) { - return await AutoPaginateLimitOffset(request, limit); + return await AutoPaginateLimitOffset(request, limit).ConfigureAwait(false); } else { @@ -279,7 +279,7 @@ public async Task> GetTrashItemsAsync(int limit, int offs if (autoPaginate) { - return await AutoPaginateLimitOffset(request, limit); + return await AutoPaginateLimitOffset(request, limit).ConfigureAwait(false); } else { @@ -490,7 +490,7 @@ public async Task> GetLocksAsync(string id, bool au if (autoPaginate) { - return await AutoPaginateLimitOffset(request, 1000); + return await AutoPaginateLimitOffset(request, 1000).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxGroupsManager.cs b/Box.V2/Managers/BoxGroupsManager.cs index 79b22ffda..307f6e4a0 100644 --- a/Box.V2/Managers/BoxGroupsManager.cs +++ b/Box.V2/Managers/BoxGroupsManager.cs @@ -56,7 +56,7 @@ public async Task> GetAllGroupsAsync(int? limit = null, if (!offset.HasValue) request.Param("offset", "0"); - return await AutoPaginateLimitOffset(request, limit.Value); + return await AutoPaginateLimitOffset(request, limit.Value).ConfigureAwait(false); } else { @@ -209,7 +209,7 @@ public async Task> GetCollaborationsForGroupAsyn if (!offset.HasValue) request.Param("offset", "0"); - return await AutoPaginateLimitOffset(request, limit.Value); + return await AutoPaginateLimitOffset(request, limit.Value).ConfigureAwait(false); } else { @@ -247,7 +247,7 @@ public async Task> GetAllGroupMembershipsForGr if (!offset.HasValue) request.Param("offset", "0"); - return await AutoPaginateLimitOffset(request, limit.Value); + return await AutoPaginateLimitOffset(request, limit.Value).ConfigureAwait(false); } else { @@ -287,7 +287,7 @@ public async Task> GetAllGroupMembershipsForUs request.Param("offset", "0"); } - return await AutoPaginateLimitOffset(request, limit.Value); + return await AutoPaginateLimitOffset(request, limit.Value).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxLegalHoldPoliciesManager.cs b/Box.V2/Managers/BoxLegalHoldPoliciesManager.cs index 129e6b81a..d799e5d29 100644 --- a/Box.V2/Managers/BoxLegalHoldPoliciesManager.cs +++ b/Box.V2/Managers/BoxLegalHoldPoliciesManager.cs @@ -59,7 +59,7 @@ public async Task> GetListLegalHold if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -170,7 +170,7 @@ public async Task> GetAss if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -254,7 +254,7 @@ public async Task> GetFileVers if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxMetadataCascadePolicyManager.cs b/Box.V2/Managers/BoxMetadataCascadePolicyManager.cs index b657f3fb8..848bde946 100644 --- a/Box.V2/Managers/BoxMetadataCascadePolicyManager.cs +++ b/Box.V2/Managers/BoxMetadataCascadePolicyManager.cs @@ -88,7 +88,7 @@ public async Task> GetAllMeta if (autopaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxMetadataManager.cs b/Box.V2/Managers/BoxMetadataManager.cs index 2b711d1cb..7095ff962 100644 --- a/Box.V2/Managers/BoxMetadataManager.cs +++ b/Box.V2/Managers/BoxMetadataManager.cs @@ -30,7 +30,7 @@ public BoxMetadataManager(IBoxConfig config, IBoxService service, IBoxConverter /// A Dictionary of key:value pairs representing the metadata. public async Task> GetFileMetadataAsync(string fileId, string scope, string template) { - return await GetMetadata(_config.FilesEndpointUri, fileId, scope, template); + return await GetMetadata(_config.FilesEndpointUri, fileId, scope, template).ConfigureAwait(false); } /// @@ -42,7 +42,7 @@ public async Task> GetFileMetadataAsync(string fileId /// A Dictionary of key:value pairs representing the metadata. public async Task> GetFolderMetadataAsync(string folderId, string scope, string template) { - return await GetMetadata(_config.FoldersEndpointUri, folderId, scope, template); + return await GetMetadata(_config.FoldersEndpointUri, folderId, scope, template).ConfigureAwait(false); } /// @@ -55,7 +55,7 @@ public async Task> GetFolderMetadataAsync(string fold /// A Dictionary of key:value pairs representing the metadata. public async Task> CreateFileMetadataAsync(string fileId, Dictionary metadata, string scope, string template) { - return await CreateMetadata(_config.FilesEndpointUri, fileId, metadata, scope, template); + return await CreateMetadata(_config.FilesEndpointUri, fileId, metadata, scope, template).ConfigureAwait(false); } /// @@ -68,7 +68,7 @@ public async Task> CreateFileMetadataAsync(string fil /// A Dictionary of key:value pairs representing the metadata. public async Task> CreateFolderMetadataAsync(string folderId, Dictionary metadata, string scope, string template) { - return await CreateMetadata(_config.FoldersEndpointUri, folderId, metadata, scope, template); + return await CreateMetadata(_config.FoldersEndpointUri, folderId, metadata, scope, template).ConfigureAwait(false); } /// @@ -81,7 +81,7 @@ public async Task> CreateFolderMetadataAsync(string f /// A Dictionary of key:value pairs representing the metadata. public async Task> UpdateFileMetadataAsync(string fileId, List updates, string scope, string template) { - return await UpdateMetadata(_config.FilesEndpointUri, fileId, updates, scope, template); + return await UpdateMetadata(_config.FilesEndpointUri, fileId, updates, scope, template).ConfigureAwait(false); } /// @@ -94,7 +94,7 @@ public async Task> UpdateFileMetadataAsync(string fil /// A Dictionary of key:value pairs representing the metadata. public async Task> UpdateFolderMetadataAsync(string folderId, List updates, string scope, string template) { - return await UpdateMetadata(_config.FoldersEndpointUri, folderId, updates, scope, template); + return await UpdateMetadata(_config.FoldersEndpointUri, folderId, updates, scope, template).ConfigureAwait(false); } /// @@ -109,7 +109,7 @@ public async Task> SetFileMetadataAsync(string fileId { try { - return await CreateFileMetadataAsync(fileId, metadata, scope, template); + return await CreateFileMetadataAsync(fileId, metadata, scope, template).ConfigureAwait(false); } catch (BoxAPIException ex) { @@ -126,7 +126,7 @@ public async Task> SetFileMetadataAsync(string fileId Value = md.Value, }); } - return await UpdateFileMetadataAsync(fileId, updates, scope, template); + return await UpdateFileMetadataAsync(fileId, updates, scope, template).ConfigureAwait(false); } // Some other exception, just rethrow it @@ -146,7 +146,7 @@ public async Task> SetFolderMetadataAsync(string fold { try { - return await CreateFolderMetadataAsync(folderId, metadata, scope, template); + return await CreateFolderMetadataAsync(folderId, metadata, scope, template).ConfigureAwait(false); } catch (BoxAPIException ex) { @@ -163,7 +163,7 @@ public async Task> SetFolderMetadataAsync(string fold Value = md.Value, }); } - return await UpdateFolderMetadataAsync(folderId, updates, scope, template); + return await UpdateFolderMetadataAsync(folderId, updates, scope, template).ConfigureAwait(false); } // Some other exception, just rethrow it @@ -180,7 +180,7 @@ public async Task> SetFolderMetadataAsync(string fold /// True if successful, false otherwise. public async Task DeleteFileMetadataAsync(string fileId, string scope, string template) { - return await DeleteMetadata(_config.FilesEndpointUri, fileId, scope, template); + return await DeleteMetadata(_config.FilesEndpointUri, fileId, scope, template).ConfigureAwait(false); } /// @@ -192,7 +192,7 @@ public async Task DeleteFileMetadataAsync(string fileId, string scope, str /// True if successful, false otherwise. public async Task DeleteFolderMetadataAsync(string folderId, string scope, string template) { - return await DeleteMetadata(_config.FoldersEndpointUri, folderId, scope, template); + return await DeleteMetadata(_config.FoldersEndpointUri, folderId, scope, template).ConfigureAwait(false); } /// @@ -340,7 +340,7 @@ public async Task> ExecuteMetadat if (autoPaginate) { - return await AutoPaginateMarkerMetadataQuery(request); + return await AutoPaginateMarkerMetadataQuery(request).ConfigureAwait(false); } else { @@ -381,7 +381,7 @@ public async Task> ExecuteMetadataQueryAsync(s if (autoPaginate) { - return await AutoPaginateMarkerMetadataQueryV2(request); + return await AutoPaginateMarkerMetadataQueryV2(request).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxRecentItemsManager.cs b/Box.V2/Managers/BoxRecentItemsManager.cs index 9980b4755..69d1fde88 100644 --- a/Box.V2/Managers/BoxRecentItemsManager.cs +++ b/Box.V2/Managers/BoxRecentItemsManager.cs @@ -34,7 +34,7 @@ public async Task> GetRecentItemsAsync if (autoPaginate) { - return await AutoPaginateMarkerV2(request, limit); + return await AutoPaginateMarkerV2(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxRetentionPoliciesManager.cs b/Box.V2/Managers/BoxRetentionPoliciesManager.cs index 3c3267231..e78a42287 100644 --- a/Box.V2/Managers/BoxRetentionPoliciesManager.cs +++ b/Box.V2/Managers/BoxRetentionPoliciesManager.cs @@ -100,7 +100,7 @@ public async Task> GetRetentionPoli if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -129,7 +129,7 @@ public async Task> GetRet if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -202,7 +202,7 @@ public async Task> GetFileVers if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -248,7 +248,7 @@ public async Task> GetFilesUnderRetentionForAs if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -278,7 +278,7 @@ public async Task> GetFileVersionsUnder if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxSignRequestsManager.cs b/Box.V2/Managers/BoxSignRequestsManager.cs index e53f51a33..cf45a658e 100644 --- a/Box.V2/Managers/BoxSignRequestsManager.cs +++ b/Box.V2/Managers/BoxSignRequestsManager.cs @@ -50,7 +50,7 @@ public async Task> GetSignRequestsAsync if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxStoragePoliciesManager.cs b/Box.V2/Managers/BoxStoragePoliciesManager.cs index 633c3713a..acdbbd128 100644 --- a/Box.V2/Managers/BoxStoragePoliciesManager.cs +++ b/Box.V2/Managers/BoxStoragePoliciesManager.cs @@ -52,7 +52,7 @@ public async Task> GetListStoragePoli if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { @@ -184,7 +184,7 @@ public async Task AssignAsync(string userId, string userId.ThrowIfNullOrWhiteSpace("userId"); storagePolicyId.ThrowIfNullOrWhiteSpace("storagePolicyId"); - var result = await GetAssignmentForTargetAsync(userId); + var result = await GetAssignmentForTargetAsync(userId).ConfigureAwait(false); if (result.BoxStoragePolicy.Id.Equals(storagePolicyId)) { @@ -192,8 +192,8 @@ public async Task AssignAsync(string userId, string } return result.AssignedTo.Type.Equals("enterprise") - ? await CreateAssignmentAsync(userId, storagePolicyId) - : await UpdateStoragePolicyAssignment(result.Id, storagePolicyId); + ? await CreateAssignmentAsync(userId, storagePolicyId).ConfigureAwait(false) + : await UpdateStoragePolicyAssignment(result.Id, storagePolicyId).ConfigureAwait(false); } } } diff --git a/Box.V2/Managers/BoxUsersManager.cs b/Box.V2/Managers/BoxUsersManager.cs index 481e5a075..298775f2d 100644 --- a/Box.V2/Managers/BoxUsersManager.cs +++ b/Box.V2/Managers/BoxUsersManager.cs @@ -110,7 +110,7 @@ public async Task> GetEnterpriseUsersAsync(string filterT if (autoPaginate) { - return await AutoPaginateLimitOffset(request, (int)limit); + return await AutoPaginateLimitOffset(request, (int)limit).ConfigureAwait(false); } else { @@ -151,7 +151,7 @@ public async Task> GetEnterpriseUsersWithMarke if (autoPaginate) { - return await AutoPaginateMarker(request, (int)limit); + return await AutoPaginateMarker(request, (int)limit).ConfigureAwait(false); } else { @@ -365,7 +365,7 @@ public async Task> GetMembershipsForUserAsync( if (autoPaginate) { - return await AutoPaginateLimitOffset(request, (int)limit); + return await AutoPaginateLimitOffset(request, (int)limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Managers/BoxWebhooksManager.cs b/Box.V2/Managers/BoxWebhooksManager.cs index c4d2caeb8..a6a804299 100644 --- a/Box.V2/Managers/BoxWebhooksManager.cs +++ b/Box.V2/Managers/BoxWebhooksManager.cs @@ -104,7 +104,7 @@ public async Task> GetWebhooksAsync(int lim if (autoPaginate) { - return await AutoPaginateMarker(request, limit); + return await AutoPaginateMarker(request, limit).ConfigureAwait(false); } else { diff --git a/Box.V2/Utility/Retry.cs b/Box.V2/Utility/Retry.cs index d5668664f..ebee420e3 100644 --- a/Box.V2/Utility/Retry.cs +++ b/Box.V2/Utility/Retry.cs @@ -119,7 +119,7 @@ public static async Task ExecuteAsync(Action action, TimeSpan retryInterval, int return null; }); - await ExecuteAsync(async () => await task, retryInterval, retryCount, executeOnEveryException, executeBeforeFinalException, exceptionTypesToHandle); + await ExecuteAsync(async () => await task, retryInterval, retryCount, executeOnEveryException, executeBeforeFinalException, exceptionTypesToHandle).ConfigureAwait(false); } /// @@ -150,13 +150,13 @@ public static async Task ExecuteAsync(Func> action, TimeSpan retry { try { - return await action(); + return await action().ConfigureAwait(false); } catch (Exception ex) { if (executeOnEveryException != null) { - await executeOnEveryException(ex); + await executeOnEveryException(ex).ConfigureAwait(false); } if (exceptionTypesToHandle != null @@ -169,7 +169,7 @@ public static async Task ExecuteAsync(Func> action, TimeSpan retry exceptions.Add(ex); if (retry < retryCount) { - await Task.Delay(retryInterval); + await Task.Delay(retryInterval).ConfigureAwait(false); } } }