From 98b57138d686006b6561c9b32ee6f8562c6879f3 Mon Sep 17 00:00:00 2001 From: Johannes Passing Date: Wed, 1 Sep 2021 15:06:44 +0200 Subject: [PATCH] Fix code analysis nits (#553) --- .../ApiExtensions/Instance/TestAddMetadata.cs | 107 ++++++++++-------- .../Auth/TestAuthorization.cs | 15 ++- .../Integration/CredentialFactory.cs | 9 +- .../Integration/InstanceFactory.cs | 88 +++++++------- .../Net/InprocHttpProxy.cs | 12 +- .../Net/TestRestClient.cs | 5 +- .../Auth/GoogleAuthAdapter.cs | 5 +- .../ProjectModel/ProjectModelService.cs | 4 +- .../Util/AsyncLock.cs | 2 +- .../ProjectExplorerViewModel.cs | 1 + .../Services/Adapters/TestAuditLogAdapter.cs | 39 ++++--- .../TestAuditLogStorageSinkAdapter.cs | 77 ++++++++----- .../Services/Adapters/TestStorageAdapter.cs | 10 +- .../Services/UsageReport/TestLicenseLoader.cs | 21 ++-- .../TestReportBuilderLicenseAnnotations.cs | 4 +- .../UsageReport/TestReportBuilderSources.cs | 4 +- 16 files changed, 233 insertions(+), 170 deletions(-) diff --git a/sources/Google.Solutions.Common.Test/ApiExtensions/Instance/TestAddMetadata.cs b/sources/Google.Solutions.Common.Test/ApiExtensions/Instance/TestAddMetadata.cs index 7f92b40e9..b2acdbb9a 100644 --- a/sources/Google.Solutions.Common.Test/ApiExtensions/Instance/TestAddMetadata.cs +++ b/sources/Google.Solutions.Common.Test/ApiExtensions/Instance/TestAddMetadata.cs @@ -88,17 +88,19 @@ public async Task WhenUsingExistingKey_ThenAddInstanceMetadataSucceeds( var key = Guid.NewGuid().ToString(); await this.instancesResource.AddMetadataAsync( - locator, - key, - "value to be overridden", - CancellationToken.None); + locator, + key, + "value to be overridden", + CancellationToken.None) + .ConfigureAwait(false); var value = "metadata value"; await this.instancesResource.AddMetadataAsync( - locator, - key, - value, - CancellationToken.None); + locator, + key, + value, + CancellationToken.None) + .ConfigureAwait(false); var instance = await this.instancesResource.Get( locator.ProjectId, @@ -122,23 +124,24 @@ public async Task WhenUpdateConflictingOnFirstAttempt_ThenUpdateInstanceMetadata int callbacks = 0; await this.instancesResource.UpdateMetadataAsync( - locator, - metadata => - { - if (callbacks++ == 0) + locator, + metadata => { - // Provoke a conflict on the first attempt. - this.instancesResource.AddMetadataAsync( - locator, - key, - "conflict #" + callbacks, - CancellationToken.None).Wait(); - } + if (callbacks++ == 0) + { + // Provoke a conflict on the first attempt. + this.instancesResource.AddMetadataAsync( + locator, + key, + "conflict #" + callbacks, + CancellationToken.None).Wait(); + } - metadata.Add(key, "value"); - }, - CancellationToken.None, - 2); + metadata.Add(key, "value"); + }, + CancellationToken.None, + 2) + .ConfigureAwait(false); var instance = await this.instancesResource.Get( locator.ProjectId, @@ -190,10 +193,11 @@ public async Task WhenUsingNewKey_ThenAddProjectMetadataSucceeds() var value = "metadata value"; await this.projectsResource.AddMetadataAsync( - TestProject.ProjectId, - key, - value, - CancellationToken.None); + TestProject.ProjectId, + key, + value, + CancellationToken.None) + .ConfigureAwait(false); var project = await this.projectsResource.Get(TestProject.ProjectId) .ExecuteAsync(CancellationToken.None) @@ -210,17 +214,19 @@ public async Task WhenUsingExistingKey_ThenAddProjectMetadataSucceeds() var key = Guid.NewGuid().ToString(); await this.projectsResource.AddMetadataAsync( - TestProject.ProjectId, - key, - "value to be overridden", - CancellationToken.None); + TestProject.ProjectId, + key, + "value to be overridden", + CancellationToken.None) + .ConfigureAwait(false); var value = "metadata value"; await this.projectsResource.AddMetadataAsync( - TestProject.ProjectId, - key, - value, - CancellationToken.None); + TestProject.ProjectId, + key, + value, + CancellationToken.None) + .ConfigureAwait(false); var project = await this.projectsResource.Get(TestProject.ProjectId) .ExecuteAsync(CancellationToken.None) @@ -238,23 +244,24 @@ public async Task WhenUpdateConflictingOnFirstAttempt_ThenUpdateProjectMetadataR int callbacks = 0; await this.projectsResource.UpdateMetadataAsync( - TestProject.ProjectId, - metadata => - { - if (callbacks++ == 0) + TestProject.ProjectId, + metadata => { - // Provoke a conflict on the first attempt. - this.projectsResource.AddMetadataAsync( - TestProject.ProjectId, - key, - "conflict #" + callbacks, - CancellationToken.None).Wait(); - } + if (callbacks++ == 0) + { + // Provoke a conflict on the first attempt. + this.projectsResource.AddMetadataAsync( + TestProject.ProjectId, + key, + "conflict #" + callbacks, + CancellationToken.None).Wait(); + } - metadata.Add(key, "value"); - }, - CancellationToken.None, - 2); + metadata.Add(key, "value"); + }, + CancellationToken.None, + 2) + .ConfigureAwait(false); var project = await this.projectsResource.Get(TestProject.ProjectId) .ExecuteAsync(CancellationToken.None) diff --git a/sources/Google.Solutions.Common.Test/Auth/TestAuthorization.cs b/sources/Google.Solutions.Common.Test/Auth/TestAuthorization.cs index cbc39a329..3813baf77 100644 --- a/sources/Google.Solutions.Common.Test/Auth/TestAuthorization.cs +++ b/sources/Google.Solutions.Common.Test/Auth/TestAuthorization.cs @@ -40,8 +40,9 @@ public async Task WhenNoExistingAuthPresent_TryLoadExistingAuthorizationAsyncRet .Returns(Task.FromResult(null)); var authz = await OAuthAuthorization.TryLoadExistingAuthorizationAsync( - adapter.Object, - CancellationToken.None); + adapter.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.IsNull(authz); } @@ -64,8 +65,9 @@ public async Task WhenExistingAuthLacksScopes_TryLoadExistingAuthorizationAsyncR .Returns(new[] { "one", "two", "email" }); var authz = await OAuthAuthorization.TryLoadExistingAuthorizationAsync( - adapter.Object, - CancellationToken.None); + adapter.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.IsNull(authz); @@ -90,8 +92,9 @@ public async Task WhenExistingAuthIsOk_TryLoadExistingAuthorizationAsyncReturnsA .Returns(new[] { "one", "two", "email" }); var authz = await OAuthAuthorization.TryLoadExistingAuthorizationAsync( - adapter.Object, - CancellationToken.None); + adapter.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.IsNotNull(authz); diff --git a/sources/Google.Solutions.Common.Test/Integration/CredentialFactory.cs b/sources/Google.Solutions.Common.Test/Integration/CredentialFactory.cs index 371464ecc..6a72f1329 100644 --- a/sources/Google.Solutions.Common.Test/Integration/CredentialFactory.cs +++ b/sources/Google.Solutions.Common.Test/Integration/CredentialFactory.cs @@ -140,13 +140,16 @@ public static async Task CreateServiceAccountCredentialAsync( try { // Create a service account. - var serviceAccount = await CreateOrGetServiceAccountAsync(name); + var serviceAccount = await CreateOrGetServiceAccountAsync(name) + .ConfigureAwait(true); // Assign roles. - await GrantRolesToServiceAccountAsync(serviceAccount, roles); + await GrantRolesToServiceAccountAsync(serviceAccount, roles) + .ConfigureAwait(true); // Create a token. - return await CreateTemporaryCredentialsAsync(serviceAccount.Email); + return await CreateTemporaryCredentialsAsync(serviceAccount.Email) + .ConfigureAwait(true); } catch (Exception e) { diff --git a/sources/Google.Solutions.Common.Test/Integration/InstanceFactory.cs b/sources/Google.Solutions.Common.Test/Integration/InstanceFactory.cs index f4a1600c5..ac6336d7d 100644 --- a/sources/Google.Solutions.Common.Test/Integration/InstanceFactory.cs +++ b/sources/Google.Solutions.Common.Test/Integration/InstanceFactory.cs @@ -53,7 +53,8 @@ private static async Task AwaitInstanceCreatedAndReady( locator.ProjectId, locator.Zone, locator.Name) - .ExecuteAsync(); + .ExecuteAsync() + .ConfigureAwait(true); // Determine the name of the guest attribute we need to await. var guestAttributeToAwait = instance.Metadata.Items @@ -138,51 +139,55 @@ public static async Task CreateOrStartInstanceAsync( { new ServiceAccount() { - Email = await GetComputeEngineDefaultServiceAccount(), + Email = await GetComputeEngineDefaultServiceAccount() + .ConfigureAwait(true), Scopes = new [] { "https://www.googleapis.com/auth/cloud-platform" } } }; } await computeEngine.Instances.Insert( - new Apis.Compute.v1.Data.Instance() - { - Name = name, - MachineType = $"zones/{locator.Zone}/machineTypes/{machineType}", - Disks = new[] + new Apis.Compute.v1.Data.Instance() { - new AttachedDisk() + Name = name, + MachineType = $"zones/{locator.Zone}/machineTypes/{machineType}", + Disks = new[] { - AutoDelete = true, - Boot = true, - InitializeParams = new AttachedDiskInitializeParams() + new AttachedDisk() { - SourceImage = imageFamily + AutoDelete = true, + Boot = true, + InitializeParams = new AttachedDiskInitializeParams() + { + SourceImage = imageFamily + } } - } - }, - Metadata = metadata, - NetworkInterfaces = new[] - { - new NetworkInterface() + }, + Metadata = metadata, + NetworkInterfaces = new[] { - AccessConfigs = publicIp - ? new [] { new AccessConfig() } - : null - } - }, - Scheduling = new Scheduling() - { - Preemptible = true + new NetworkInterface() + { + AccessConfigs = publicIp + ? new [] { new AccessConfig() } + : null + } + }, + Scheduling = new Scheduling() + { + Preemptible = true + }, + ServiceAccounts = serviceAccounts }, - ServiceAccounts = serviceAccounts - }, - locator.ProjectId, - locator.Zone).ExecuteAsync(); + locator.ProjectId, + locator.Zone) + .ExecuteAsync() + .ConfigureAwait(true); await AwaitInstanceCreatedAndReady( - computeEngine.Instances, - locator); + computeEngine.Instances, + locator) + .ConfigureAwait(true); return locator; } @@ -194,7 +199,8 @@ await AwaitInstanceCreatedAndReady( locator.ProjectId, locator.Zone, locator.Name) - .ExecuteAsync(); + .ExecuteAsync() + .ConfigureAwait(true); if (instance.Status == "RUNNING" || instance.Status == "PROVISIONING" || @@ -204,8 +210,9 @@ await AwaitInstanceCreatedAndReady( "Instance {0} exists and is running...", locator.Name); await AwaitInstanceCreatedAndReady( - computeEngine.Instances, - locator); + computeEngine.Instances, + locator) + .ConfigureAwait(true); return locator; } else if (instance.Status == "TERMINATED") @@ -217,17 +224,20 @@ await AwaitInstanceCreatedAndReady( await computeEngine.Instances.AddMetadataAsync( locator, metadata, - CancellationToken.None); + CancellationToken.None) + .ConfigureAwait(true); await computeEngine.Instances.Start( locator.ProjectId, locator.Zone, locator.Name) - .ExecuteAsync(); + .ExecuteAsync() + .ConfigureAwait(true); await AwaitInstanceCreatedAndReady( - computeEngine.Instances, - locator); + computeEngine.Instances, + locator) + .ConfigureAwait(true); return locator; } else diff --git a/sources/Google.Solutions.Common.Test/Net/InprocHttpProxy.cs b/sources/Google.Solutions.Common.Test/Net/InprocHttpProxy.cs index 491fe1134..61e039497 100644 --- a/sources/Google.Solutions.Common.Test/Net/InprocHttpProxy.cs +++ b/sources/Google.Solutions.Common.Test/Net/InprocHttpProxy.cs @@ -105,10 +105,11 @@ private async Task DispatchRequestAsync(NetworkStream clientStream) this.connectionTargets.AddLast(matchConnect.Groups[1].Value); await DispatchRequestAsync( - matchConnect.Groups[1].Value, - ushort.Parse(matchConnect.Groups[2].Value), - headers, - clientStream); + matchConnect.Groups[1].Value, + ushort.Parse(matchConnect.Groups[2].Value), + headers, + clientStream) + .ConfigureAwait(true); } else if (GetRequestPattern.Match(firstLine) is Match getMatch && getMatch.Success && @@ -236,7 +237,8 @@ protected override async Task DispatchRequestAsync( } else { - await base.DispatchRequestAsync(server, serverPort, headers, clientStream); + await base.DispatchRequestAsync(server, serverPort, headers, clientStream) + .ConfigureAwait(true); } } else diff --git a/sources/Google.Solutions.Common.Test/Net/TestRestClient.cs b/sources/Google.Solutions.Common.Test/Net/TestRestClient.cs index 03e2a1065..22564d377 100644 --- a/sources/Google.Solutions.Common.Test/Net/TestRestClient.cs +++ b/sources/Google.Solutions.Common.Test/Net/TestRestClient.cs @@ -50,8 +50,9 @@ public async Task WhenUrlPointsToJson_ThenGetAsyncReturnsObject() { var client = new RestClient(); var result = await client.GetAsync( - SampleRestUrl, - CancellationToken.None); + SampleRestUrl, + CancellationToken.None) + .ConfigureAwait(false); Assert.IsNotNull(result.Issuer); } diff --git a/sources/Google.Solutions.Common/Auth/GoogleAuthAdapter.cs b/sources/Google.Solutions.Common/Auth/GoogleAuthAdapter.cs index 1dc89a149..b8bf0b522 100644 --- a/sources/Google.Solutions.Common/Auth/GoogleAuthAdapter.cs +++ b/sources/Google.Solutions.Common/Auth/GoogleAuthAdapter.cs @@ -93,8 +93,9 @@ public async Task AuthorizeUsingBrowserAsync(CancellationToken toke try { var userCredential = await this.installedApp.AuthorizeAsync( - StoreUserId, - token); + StoreUserId, + token) + .ConfigureAwait(true); // // NB. If an admin changes the access level for the app (in the Admin Console), diff --git a/sources/Google.Solutions.IapDesktop.Application/Services/ProjectModel/ProjectModelService.cs b/sources/Google.Solutions.IapDesktop.Application/Services/ProjectModel/ProjectModelService.cs index 66f51494a..3b08e051a 100644 --- a/sources/Google.Solutions.IapDesktop.Application/Services/ProjectModel/ProjectModelService.cs +++ b/sources/Google.Solutions.IapDesktop.Application/Services/ProjectModel/ProjectModelService.cs @@ -42,7 +42,7 @@ namespace Google.Solutions.IapDesktop.Application.Services.ProjectModel /// Represents the in-memory model (or workspace) of projects and /// instances. Data is cached, but read-only. /// - public interface IProjectModelService + public interface IProjectModelService : IDisposable { /// /// Add a project so that it will be considered when @@ -102,7 +102,7 @@ Task SetActiveNodeAsync( CancellationToken token); } - public class ProjectModelService : IProjectModelService, IDisposable + public class ProjectModelService : IProjectModelService { private readonly IServiceProvider serviceProvider; diff --git a/sources/Google.Solutions.IapDesktop.Application/Util/AsyncLock.cs b/sources/Google.Solutions.IapDesktop.Application/Util/AsyncLock.cs index 966103f22..59eca00c4 100644 --- a/sources/Google.Solutions.IapDesktop.Application/Util/AsyncLock.cs +++ b/sources/Google.Solutions.IapDesktop.Application/Util/AsyncLock.cs @@ -34,7 +34,7 @@ public sealed class AsyncLock : IDisposable public void Dispose() { - this.semaphore.Release(); + this.semaphore.Dispose(); } public async Task AcquireAsync(CancellationToken token) diff --git a/sources/Google.Solutions.IapDesktop.Application/Views/ProjectExplorer/ProjectExplorerViewModel.cs b/sources/Google.Solutions.IapDesktop.Application/Views/ProjectExplorer/ProjectExplorerViewModel.cs index ab3a9c0f2..0a2151849 100644 --- a/sources/Google.Solutions.IapDesktop.Application/Views/ProjectExplorer/ProjectExplorerViewModel.cs +++ b/sources/Google.Solutions.IapDesktop.Application/Views/ProjectExplorer/ProjectExplorerViewModel.cs @@ -460,6 +460,7 @@ public void ConfigureIapAccess() public void Dispose() { this.settingsRepository.Dispose(); + this.projectModelService.Dispose(); } //--------------------------------------------------------------------- diff --git a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogAdapter.cs b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogAdapter.cs index ce9df4580..15b9ecad0 100644 --- a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogAdapter.cs +++ b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogAdapter.cs @@ -78,14 +78,15 @@ public async Task WhenInstanceCreated_ThenListLogEntriesReturnsInsertEvent( for (int retry = 0; retry < 4 && !events.Any(); retry++) { await adapter.ListEventsAsync( - request, - events.Add, - new Apis.Util.ExponentialBackOff(), - CancellationToken.None); + request, + events.Add, + new Apis.Util.ExponentialBackOff(), + CancellationToken.None) + .ConfigureAwait(false); if (!events.Any()) { - await Task.Delay(20 * 1000); + await Task.Delay(20 * 1000).ConfigureAwait(false); } } @@ -114,20 +115,30 @@ public async Task WhenInstanceCreated_ThenProcessInstanceEventsAsyncCanFeedHisto var computeAdapter = new ComputeEngineAdapter(await credential); instanceBuilder.AddExistingInstances( - await computeAdapter.ListInstancesAsync(TestProject.ProjectId, CancellationToken.None), - await computeAdapter.ListNodesAsync(TestProject.ProjectId, CancellationToken.None), - await computeAdapter.ListDisksAsync(TestProject.ProjectId, CancellationToken.None), + await computeAdapter.ListInstancesAsync( + TestProject.ProjectId, + CancellationToken.None) + .ConfigureAwait(false), + await computeAdapter.ListNodesAsync + (TestProject.ProjectId, + CancellationToken.None) + .ConfigureAwait(false), + await computeAdapter.ListDisksAsync( + TestProject.ProjectId, + CancellationToken.None) + .ConfigureAwait(false), TestProject.ProjectId); var adapter = new AuditLogAdapter(await credential); await adapter.ProcessInstanceEventsAsync( - new[] { TestProject.ProjectId }, - null, // all zones. - null, // all instances. - instanceBuilder.StartDate, - instanceBuilder, - CancellationToken.None); + new[] { TestProject.ProjectId }, + null, // all zones. + null, // all instances. + instanceBuilder.StartDate, + instanceBuilder, + CancellationToken.None) + .ConfigureAwait(false); var set = instanceBuilder.Build(); var testInstanceHistory = set.Instances.FirstOrDefault(i => i.Reference == instanceRef); diff --git a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogStorageSinkAdapter.cs b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogStorageSinkAdapter.cs index a65b1326c..c5993a9d4 100644 --- a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogStorageSinkAdapter.cs +++ b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestAuditLogStorageSinkAdapter.cs @@ -150,9 +150,10 @@ public async Task WhenSinkTooYoung_ThenFindCloudStorageExportBucketForAuditLogsA auditLogAdapter.Object); var bucket = await service.FindCloudStorageExportBucketForAuditLogsAsync( - TestProject.ProjectId, - new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc), // Before sink creation - CancellationToken.None); + TestProject.ProjectId, + new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc), // Before sink creation + CancellationToken.None) + .ConfigureAwait(false); Assert.IsNull(bucket); } @@ -272,8 +273,10 @@ public async Task WhenObjectIsEmpty_ThenListInstanceEventsAsyncReturnsEmptyListO new AuditLogAdapter(await credential)); var events = await service.ListInstanceEventsAsync( - EmptyLocator, - CancellationToken.None); + EmptyLocator, + CancellationToken.None) + .ConfigureAwait(false); + CollectionAssert.IsEmpty(events); } @@ -286,8 +289,10 @@ public async Task WhenObjectContainsEventExport_ThenListInstanceEventsAsyncRetur new AuditLogAdapter(await credential)); var events = await service.ListInstanceEventsAsync( - ValidLocator_Jan1_00, - CancellationToken.None); + ValidLocator_Jan1_00, + CancellationToken.None) + .ConfigureAwait(false); + Assert.AreEqual(3, events.Count()); } @@ -318,8 +323,10 @@ public async Task WhenObjectsContainEventExports_ThenListInstanceEventsAsyncRetu new AuditLogAdapter(await credential)); var events = await service.ListInstanceEventsAsync( - new[] { EmptyLocator, ValidLocator_Jan1_00 }, - CancellationToken.None); + new[] { EmptyLocator, ValidLocator_Jan1_00 }, + CancellationToken.None) + .ConfigureAwait(false); + Assert.AreEqual(3, events.Count()); } @@ -355,7 +362,9 @@ public async Task WhenNoObjectsInRange_ThenFindExportObjectsReturnsEmptyDictiona GcsTestData.Bucket, new DateTime(2020, 2, 1, 0, 0, 0, DateTimeKind.Utc), new DateTime(2020, 2, 2, 0, 0, 0, DateTimeKind.Utc), - CancellationToken.None); + CancellationToken.None) + .ConfigureAwait(false); + CollectionAssert.IsEmpty(locators); } @@ -374,7 +383,9 @@ public async Task WhenObjectsInRange_ThenFindExportObjectsReturnsList( GcsTestData.Bucket, jan1, jan2, - CancellationToken.None); + CancellationToken.None) + .ConfigureAwait(false); + Assert.AreEqual(2, locators.Count()); // 2 days Assert.AreEqual(2, locators[jan1].Count()); Assert.AreEqual(1, locators[jan2].Count()); @@ -404,11 +415,12 @@ public async Task WhenExpectedOrderIsNewestFirst_ThenEventsAreProcessedInDescend var jan1 = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc); await service.ProcessInstanceEventsAsync( - GcsTestData.Bucket, - jan1, - jan1.AddMonths(1), - processor.Object, - CancellationToken.None); + GcsTestData.Bucket, + jan1, + jan1.AddMonths(1), + processor.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(5, eventsProcessed.Count); @@ -439,11 +451,12 @@ public async Task WhenExpectedOrderIsOldestFirst_ThenEventsAreProcessedInAscendi var jan1 = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc); await service.ProcessInstanceEventsAsync( - GcsTestData.Bucket, - jan1, - jan1.AddMonths(1), - processor.Object, - CancellationToken.None); + GcsTestData.Bucket, + jan1, + jan1.AddMonths(1), + processor.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(5, eventsProcessed.Count); @@ -474,11 +487,12 @@ public async Task WhenSeverityDoesNotMatch_ThenEventsAreNotProcessed( var jan1 = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc); await service.ProcessInstanceEventsAsync( - GcsTestData.Bucket, - jan1, - jan1.AddMonths(1), - processor.Object, - CancellationToken.None); + GcsTestData.Bucket, + jan1, + jan1.AddMonths(1), + processor.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(0, eventsProcessed.Count); } @@ -503,11 +517,12 @@ public async Task WhenMethodDoesNotMatch_ThenEventsAreNotProcessed( var jan1 = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc); await service.ProcessInstanceEventsAsync( - GcsTestData.Bucket, - jan1, - jan1.AddMonths(1), - processor.Object, - CancellationToken.None); + GcsTestData.Bucket, + jan1, + jan1.AddMonths(1), + processor.Object, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(0, eventsProcessed.Count); } diff --git a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestStorageAdapter.cs b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestStorageAdapter.cs index 79d448efc..7e9087a13 100644 --- a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestStorageAdapter.cs +++ b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/Adapters/TestStorageAdapter.cs @@ -78,8 +78,9 @@ public async Task WhenBucketExists_ThenListBucketsAsyncReturnsObject( var adapter = new StorageAdapter(await credential); var buckets = await adapter.ListBucketsAsync( - TestProject.ProjectId, - CancellationToken.None); + TestProject.ProjectId, + CancellationToken.None) + .ConfigureAwait(false); Assert.IsNotNull(buckets); CollectionAssert.Contains( @@ -143,8 +144,9 @@ public async Task WhenObjectExists_ThenDownloadObjectToMemoryAsyncReturnsObject( var adapter = new StorageAdapter(await credential); var stream = await adapter.DownloadObjectToMemoryAsync( - SampleLocator, - CancellationToken.None); + SampleLocator, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual( SampleData, diff --git a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestLicenseLoader.cs b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestLicenseLoader.cs index ce4475035..79fa1a1fa 100644 --- a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestLicenseLoader.cs +++ b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestLicenseLoader.cs @@ -67,9 +67,10 @@ public async Task WhenImageFound_ThenAnnotationIsAdded( var computeEngineAdapter = new ComputeEngineAdapter( await credential); await LicenseLoader.LoadLicenseAnnotationsAsync( - annotatedSet, - computeEngineAdapter, - CancellationToken.None); + annotatedSet, + computeEngineAdapter, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(1, annotatedSet.LicenseAnnotations.Count()); @@ -90,9 +91,10 @@ public async Task WhenImageNotFoundButFromWindowsProject_ThenAnnotationIsAdded( var computeEngineAdapter = new ComputeEngineAdapter( await credential); await LicenseLoader.LoadLicenseAnnotationsAsync( - annotatedSet, - computeEngineAdapter, - CancellationToken.None); + annotatedSet, + computeEngineAdapter, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(1, annotatedSet.LicenseAnnotations.Count()); @@ -113,9 +115,10 @@ public async Task WhenImageNotFound_ThenAnnotationNotAdded( var computeEngineAdapter = new ComputeEngineAdapter( await credential); await LicenseLoader.LoadLicenseAnnotationsAsync( - annotatedSet, - computeEngineAdapter, - CancellationToken.None); + annotatedSet, + computeEngineAdapter, + CancellationToken.None) + .ConfigureAwait(false); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); } diff --git a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderLicenseAnnotations.cs b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderLicenseAnnotations.cs index e6e7d8203..b6fd38cb6 100644 --- a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderLicenseAnnotations.cs +++ b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderLicenseAnnotations.cs @@ -86,7 +86,9 @@ public async Task WhenLinuxInstanceCreated_ThenReportContainsInstanceAndLicenseI AuditLogSources.Api, new[] { TestProject.ProjectId }, startDate); - var report = await builder.BuildAsync(CancellationToken.None); + var report = await builder + .BuildAsync(CancellationToken.None) + .ConfigureAwait(false); var instance = report.History.Instances.First(i => i.Reference == instanceRef); Assert.IsTrue(report.IsInstanceAnnotatedAs( diff --git a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderSources.cs b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderSources.cs index 85bfb4d68..aba835f05 100644 --- a/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderSources.cs +++ b/sources/Google.Solutions.IapDesktop.Extensions.Activity.Test/Services/UsageReport/TestReportBuilderSources.cs @@ -57,7 +57,9 @@ public async Task WhenNoApplicableExportSinkAvailable_ThenApiIsUsed() new[] { "project-1" }, DateTime.UtcNow.AddYears(-1)); - await reportBuilder.BuildAsync(CancellationToken.None); + await reportBuilder + .BuildAsync(CancellationToken.None) + .ConfigureAwait(false); auditExportAdapter.Verify( a => a.ProcessInstanceEventsAsync(