diff --git a/CHANGELOG.md b/CHANGELOG.md index d48fe972d..19bcbac11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Bug Fixes 1. [#106](https://github.com/influxdata/influxdb-client-csharp/pull/106): Fixed serialization of `\n`, `\r` and `\t` to Line Protocol, `=` is valid sign for measurement name +1. [#108](https://github.com/influxdata/influxdb-client-csharp/issues/108): Replaced useless .ContinueWith in Api by direct call ## 1.9.0 [2020-06-19] diff --git a/Client.Legacy/FluxClient.cs b/Client.Legacy/FluxClient.cs index f0e4cd5f1..1e8a64307 100644 --- a/Client.Legacy/FluxClient.cs +++ b/Client.Legacy/FluxClient.cs @@ -389,9 +389,9 @@ public async Task VersionAsync() { try { - var response = ExecuteAsync(PingRequest()); + var response = await ExecuteAsync(PingRequest()); - return await response.ContinueWith(t => GetVersion(t.Result)); + return GetVersion(response); } catch (Exception e) { diff --git a/Client.Test/ItBucketsApiTest.cs b/Client.Test/ItBucketsApiTest.cs index 9d3365cfb..9067604ab 100644 --- a/Client.Test/ItBucketsApiTest.cs +++ b/Client.Test/ItBucketsApiTest.cs @@ -69,8 +69,8 @@ public void CloneBucketNotFound() var ioe = Assert.ThrowsAsync(async () => await _bucketsApi.CloneBucketAsync(GenerateName("bucket"), "020f755c3c082000")); - Assert.AreEqual(typeof(HttpException), ioe.InnerException.InnerException.GetType()); - Assert.AreEqual("bucket not found", ioe.InnerException.InnerException.Message); + Assert.AreEqual(typeof(HttpException), ioe.InnerException?.GetType()); + Assert.AreEqual("bucket not found", ioe.InnerException?.Message); } [Test] diff --git a/Client.Test/ItLabelsApiTest.cs b/Client.Test/ItLabelsApiTest.cs index f0c21ea3c..81a12ee3a 100644 --- a/Client.Test/ItLabelsApiTest.cs +++ b/Client.Test/ItLabelsApiTest.cs @@ -50,8 +50,8 @@ public void CloneLabelNotFound() Assert.ThrowsAsync(async () => await _labelsApi.CloneLabelAsync(GenerateName("bucket"), "020f755c3c082000")); Assert.IsNotNull(exception); - Assert.AreEqual(typeof(HttpException), exception.InnerException.InnerException.GetType()); - Assert.AreEqual("label not found", exception.InnerException.InnerException.Message); + Assert.AreEqual(typeof(HttpException), exception.InnerException.GetType()); + Assert.AreEqual("label not found", exception.InnerException.Message); } [Test] @@ -99,11 +99,11 @@ public async Task DeleteLabel() // delete user await _labelsApi.DeleteLabelAsync(createdLabel); - var exception = Assert.ThrowsAsync(async () => await _labelsApi.FindLabelByIdAsync(createdLabel.Id)); + var exception = Assert.ThrowsAsync(async () => await _labelsApi.FindLabelByIdAsync(createdLabel.Id)); Assert.IsNotNull(exception); - Assert.AreEqual("label not found", exception.InnerException.Message); - Assert.AreEqual(typeof(HttpException), exception.InnerException.GetType()); + Assert.AreEqual("label not found", exception.Message); + Assert.AreEqual(typeof(HttpException), exception.GetType()); } [Test] @@ -122,11 +122,11 @@ public async Task FindLabelById() [Test] public void FindLabelByIdNull() { - var exception = Assert.ThrowsAsync(async () => await _labelsApi.FindLabelByIdAsync("020f755c3c082000")); + var exception = Assert.ThrowsAsync(async () => await _labelsApi.FindLabelByIdAsync("020f755c3c082000")); Assert.IsNotNull(exception); - Assert.AreEqual("label not found", exception.InnerException.Message); - Assert.AreEqual(typeof(HttpException), exception.InnerException.GetType()); + Assert.AreEqual("label not found", exception.Message); + Assert.AreEqual(typeof(HttpException), exception.GetType()); } [Test] diff --git a/Client.Test/ItNotificationEndpointsApiTest.cs b/Client.Test/ItNotificationEndpointsApiTest.cs index 60d320af7..8fc617f9f 100644 --- a/Client.Test/ItNotificationEndpointsApiTest.cs +++ b/Client.Test/ItNotificationEndpointsApiTest.cs @@ -431,27 +431,27 @@ public void CloneNotFound() var ioe = Assert.ThrowsAsync(async () => await _notificationEndpointsApi .CloneSlackEndpointAsync("not-found-cloned", "token", "020f755c3c082000")); - Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message); + Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message); ioe = Assert.ThrowsAsync(async () => await _notificationEndpointsApi .ClonePagerDutyEndpointAsync("not-found-cloned", "token", "020f755c3c082000")); - Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message); + Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message); ioe = Assert.ThrowsAsync(async () => await _notificationEndpointsApi .CloneHttpEndpointAsync("not-found-cloned", "020f755c3c082000")); - Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message); + Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message); ioe = Assert.ThrowsAsync(async () => await _notificationEndpointsApi .CloneHttpEndpointBearerAsync("not-found-cloned", "token", "020f755c3c082000")); - Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message); + Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message); ioe = Assert.ThrowsAsync(async () => await _notificationEndpointsApi .CloneHttpEndpointBasicAuthAsync("not-found-cloned", "username", "password", "020f755c3c082000")); - Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.InnerException?.Message); + Assert.AreEqual("notification endpoint not found for key \"020f755c3c082000\"", ioe.InnerException?.Message); } [Test] diff --git a/Client.Test/ItSourcesApiTest.cs b/Client.Test/ItSourcesApiTest.cs index 90bc6cf0a..7fc1de49c 100644 --- a/Client.Test/ItSourcesApiTest.cs +++ b/Client.Test/ItSourcesApiTest.cs @@ -137,12 +137,12 @@ public async Task FindBucketsBySource() [Test] public void FindBucketsBySourceByUnknownSource() { - var nfe = Assert.ThrowsAsync(async () => + var nfe = Assert.ThrowsAsync(async () => await _sourcesApi.FindBucketsBySourceIdAsync("020f755c3d082000")); Assert.IsNotNull(nfe); - Assert.AreEqual("source not found", nfe.InnerException.Message); - Assert.AreEqual(typeof(HttpException), nfe.InnerException.GetType()); + Assert.AreEqual("source not found", nfe.Message); + Assert.AreEqual(typeof(HttpException), nfe.GetType()); } [Test] diff --git a/Client.Test/ItTasksApiTest.cs b/Client.Test/ItTasksApiTest.cs index b048451ea..205658249 100644 --- a/Client.Test/ItTasksApiTest.cs +++ b/Client.Test/ItTasksApiTest.cs @@ -331,10 +331,10 @@ public async Task GetLogs() [Test] public void GetLogsNotExist() { - var ioe = Assert.ThrowsAsync(async () => await _tasksApi.GetLogsAsync("020f755c3c082000")); + var ioe = Assert.ThrowsAsync(async () => await _tasksApi.GetLogsAsync("020f755c3c082000")); - Assert.NotNull(ioe.InnerException, "ioe.InnerException != null"); - Assert.AreEqual("failed to find task logs: task not found", ioe.InnerException.Message); + Assert.NotNull(ioe, "ioe.InnerException != null"); + Assert.AreEqual("failed to find task logs: task not found", ioe.Message); } [Test] @@ -372,10 +372,10 @@ public async Task GetRunLogsNotExist() { var task = await _tasksApi.CreateTaskEveryAsync(GenerateName("it task"), TaskFlux, "1s", _organization); - var ioe = Assert.ThrowsAsync(async () => await _tasksApi.GetRunLogsAsync(task.Id, "020f755c3c082000")); + var ioe = Assert.ThrowsAsync(async () => await _tasksApi.GetRunLogsAsync(task.Id, "020f755c3c082000")); - Assert.NotNull(ioe.InnerException, "ioe.InnerException != null"); - Assert.AreEqual("failed to find task logs: run not found", ioe.InnerException.Message); + Assert.NotNull(ioe, "ioe.InnerException != null"); + Assert.AreEqual("failed to find task logs: run not found", ioe.Message); } [Test] @@ -570,11 +570,11 @@ public async Task RunsLimit() [Test] public void RunsNotExist() { - var ioe = Assert.ThrowsAsync(async () => + var ioe = Assert.ThrowsAsync(async () => await _tasksApi.GetRunsAsync("020f755c3c082000", _organization.Id)); - Assert.NotNull(ioe.InnerException, "ioe.InnerException != null"); - Assert.AreEqual("failed to find runs: task not found", ioe.InnerException.Message); + Assert.NotNull(ioe, "ioe.InnerException != null"); + Assert.AreEqual("failed to find runs: task not found", ioe.Message); } [Test] diff --git a/Client.Test/ItUsersApiTest.cs b/Client.Test/ItUsersApiTest.cs index 09992a2b4..8a01f4384 100644 --- a/Client.Test/ItUsersApiTest.cs +++ b/Client.Test/ItUsersApiTest.cs @@ -84,7 +84,7 @@ public async Task FindUsers() var users = await _usersApi.FindUsersAsync(); - Assert.AreEqual(users.Count, size + 1); + Assert.AreEqual(size + 1, users.Count); } [Test] diff --git a/Client/AuthorizationsApi.cs b/Client/AuthorizationsApi.cs index a92b5c970..b1a31911f 100644 --- a/Client/AuthorizationsApi.cs +++ b/Client/AuthorizationsApi.cs @@ -186,8 +186,7 @@ public async Task> FindAuthorizationsByUserNameAsync(string private async Task> FindAuthorizationsByAsync(string userId, string userName) { - return await _service.GetAuthorizationsAsync(null, userId, userName) - .ContinueWith(t => t.Result._Authorizations); + return (await _service.GetAuthorizationsAsync(null, userId, userName))._Authorizations; } } } \ No newline at end of file diff --git a/Client/BucketsApi.cs b/Client/BucketsApi.cs index 6a9404cbb..128872efe 100644 --- a/Client/BucketsApi.cs +++ b/Client/BucketsApi.cs @@ -155,7 +155,7 @@ public async Task CloneBucketAsync(string clonedName, string bucketId) Arguments.CheckNonEmptyString(clonedName, nameof(clonedName)); Arguments.CheckNonEmptyString(bucketId, nameof(bucketId)); - return await FindBucketByIdAsync(bucketId).ContinueWith(t => t.Result) + return await FindBucketByIdAsync(bucketId) .ContinueWith(t => CloneBucketAsync(clonedName, t.Result)).Unwrap(); } @@ -209,9 +209,8 @@ public async Task FindBucketByNameAsync(string bucketName) { Arguments.CheckNonEmptyString(bucketName, nameof(bucketName)); - return await _service - .GetBucketsAsync(null, null, null, null, null, bucketName) - .ContinueWith(t => t.Result._Buckets.FirstOrDefault()); + return (await _service.GetBucketsAsync(null, null, null, null, null, bucketName)) + ._Buckets.FirstOrDefault(); } /// @@ -233,9 +232,7 @@ public async Task> FindBucketsByOrganizationAsync(Organization orga /// A list of buckets public async Task> FindBucketsByOrgNameAsync(string orgName) { - var buckets = FindBucketsAsync(orgName, new FindOptions()); - - return await buckets.ContinueWith(t => t.Result._Buckets); + return (await FindBucketsAsync(orgName, new FindOptions()))._Buckets; } /// @@ -280,7 +277,7 @@ public async Task> GetMembersAsync(string bucketId) { Arguments.CheckNonEmptyString(bucketId, nameof(bucketId)); - return await _service.GetBucketsIDMembersAsync(bucketId).ContinueWith(t => t.Result.Users); + return (await _service.GetBucketsIDMembersAsync(bucketId)).Users; } /// @@ -362,7 +359,7 @@ public async Task> GetOwnersAsync(string bucketId) { Arguments.CheckNonEmptyString(bucketId, nameof(bucketId)); - return await _service.GetBucketsIDOwnersAsync(bucketId).ContinueWith(t => t.Result.Users); + return (await _service.GetBucketsIDOwnersAsync(bucketId)).Users; } /// @@ -444,7 +441,7 @@ public async Task> GetLabelsAsync(string bucketId) { Arguments.CheckNonEmptyString(bucketId, nameof(bucketId)); - return await _service.GetBucketsIDLabelsAsync(bucketId).ContinueWith(t => t.Result.Labels); + return (await _service.GetBucketsIDLabelsAsync(bucketId)).Labels; } /// @@ -474,7 +471,7 @@ public async Task