diff --git a/Directory.Build.props b/Directory.Build.props index f2dc675..126f176 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,6 +23,7 @@ 14 true enable + enable diff --git a/src/Events/Events/src/ClickView.Extensions.Events.csproj b/src/Events/Events/src/ClickView.Extensions.Events.csproj index 2bbf00b..730e056 100644 --- a/src/Events/Events/src/ClickView.Extensions.Events.csproj +++ b/src/Events/Events/src/ClickView.Extensions.Events.csproj @@ -3,6 +3,7 @@ $(FullTargetFrameworks) events + disable diff --git a/src/Events/Events/test/ClickView.Extensions.Events.Tests.csproj b/src/Events/Events/test/ClickView.Extensions.Events.Tests.csproj index e5cf2c6..35307ce 100644 --- a/src/Events/Events/test/ClickView.Extensions.Events.Tests.csproj +++ b/src/Events/Events/test/ClickView.Extensions.Events.Tests.csproj @@ -3,13 +3,14 @@ $(TestTargetFrameworks) false + Exe - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Events/Events/test/EventsIntegrationTests.cs b/src/Events/Events/test/EventsIntegrationTests.cs index af6c705..8bc10fd 100644 --- a/src/Events/Events/test/EventsIntegrationTests.cs +++ b/src/Events/Events/test/EventsIntegrationTests.cs @@ -26,7 +26,7 @@ public async Task CanPublishUsingInMemoryBus() await eventPublisher.PublishAsync(evt); //Wait for events to propagate/tasks to finish - await Task.Delay(100); + await Task.Delay(100, TestContext.Current.CancellationToken); //assert Assert.Single(eventHandler.Events); @@ -55,4 +55,4 @@ public Task HandleEventAsync(CustomEvent evt) return Task.FromResult(0); } } -} \ No newline at end of file +} diff --git a/src/Hosting/Hosting/src/ClickView.Extensions.Hosting.csproj b/src/Hosting/Hosting/src/ClickView.Extensions.Hosting.csproj index 089c8f7..56c69d9 100644 --- a/src/Hosting/Hosting/src/ClickView.Extensions.Hosting.csproj +++ b/src/Hosting/Hosting/src/ClickView.Extensions.Hosting.csproj @@ -2,7 +2,6 @@ $(FullTargetFrameworks) - enable hosting diff --git a/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/ClickView.Extensions.Hosting.Tests.csproj b/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/ClickView.Extensions.Hosting.Tests.csproj index f486e83..0a770ed 100644 --- a/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/ClickView.Extensions.Hosting.Tests.csproj +++ b/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/ClickView.Extensions.Hosting.Tests.csproj @@ -2,8 +2,7 @@ $(TestTargetFrameworks) - enable - enable + Exe false true @@ -12,7 +11,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/CronWorkerTests.cs b/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/CronWorkerTests.cs index c34d336..96a6ae1 100644 --- a/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/CronWorkerTests.cs +++ b/src/Hosting/Hosting/test/ClickView.Extensions.Hosting.Tests/CronWorkerTests.cs @@ -18,7 +18,7 @@ public async Task RunAsync_RunEveryTwoSeconds() await scheduler.StartAsync(CancellationToken.None); - await Task.Delay(TimeSpan.FromSeconds(5)); + await Task.Delay(TimeSpan.FromSeconds(5), TestContext.Current.CancellationToken); await scheduler.StopAsync(CancellationToken.None); @@ -30,7 +30,7 @@ public void CronWorkerOption_MinGreaterThanMax_ThrowException() { const string everyTwoSecondCron = "*/2 * * * * *"; - Assert.Throws(() => + Assert.Throws(() => { new CronWorkerOption(everyTwoSecondCron, true, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(1)); }); } @@ -48,7 +48,7 @@ public async Task RunAsync_RunEveryTwoSecondsWithJitter_Executes() var currentTime = DateTime.UtcNow; // Give it a bit more time to ensure the task is executed - await Task.Delay(TimeSpan.FromSeconds(4)); + await Task.Delay(TimeSpan.FromSeconds(4), TestContext.Current.CancellationToken); await scheduler.StopAsync(CancellationToken.None); @@ -70,4 +70,4 @@ protected override Task RunAsync(CancellationToken cancellationToken) return Task.CompletedTask; } } -} \ No newline at end of file +} diff --git a/src/Primitives/Primitives/src/ClickView.Extensions.Primitives.csproj b/src/Primitives/Primitives/src/ClickView.Extensions.Primitives.csproj index ce26dfa..d24cf79 100644 --- a/src/Primitives/Primitives/src/ClickView.Extensions.Primitives.csproj +++ b/src/Primitives/Primitives/src/ClickView.Extensions.Primitives.csproj @@ -3,7 +3,6 @@ $(FullTargetFrameworks) primitives - enable diff --git a/src/Primitives/Primitives/test/ClickView.Extensions.Primitives.Tests.csproj b/src/Primitives/Primitives/test/ClickView.Extensions.Primitives.Tests.csproj index 0f1be14..387e8fe 100644 --- a/src/Primitives/Primitives/test/ClickView.Extensions.Primitives.Tests.csproj +++ b/src/Primitives/Primitives/test/ClickView.Extensions.Primitives.Tests.csproj @@ -3,12 +3,12 @@ $(TestTargetFrameworks) false - enable + Exe - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/RestClient/Authenticators/OAuth/src/ClickView.Extensions.RestClient.Authenticators.OAuth.csproj b/src/RestClient/Authenticators/OAuth/src/ClickView.Extensions.RestClient.Authenticators.OAuth.csproj index 165b78c..20f5767 100644 --- a/src/RestClient/Authenticators/OAuth/src/ClickView.Extensions.RestClient.Authenticators.OAuth.csproj +++ b/src/RestClient/Authenticators/OAuth/src/ClickView.Extensions.RestClient.Authenticators.OAuth.csproj @@ -4,6 +4,7 @@ $(FullTargetFrameworks) restclient rest http oauth OAuth authenticators for ClickView.Extensions.RestClient + disable diff --git a/src/RestClient/Authenticators/OAuth/test/ClickView.Extensions.RestClient.Authenticators.OAuth.Tests.csproj b/src/RestClient/Authenticators/OAuth/test/ClickView.Extensions.RestClient.Authenticators.OAuth.Tests.csproj index dcc65be..8e11d6e 100644 --- a/src/RestClient/Authenticators/OAuth/test/ClickView.Extensions.RestClient.Authenticators.OAuth.Tests.csproj +++ b/src/RestClient/Authenticators/OAuth/test/ClickView.Extensions.RestClient.Authenticators.OAuth.Tests.csproj @@ -3,12 +3,14 @@ $(TestTargetFrameworks) false + disable + Exe - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/RestClient/Authenticators/OAuth/test/DiscoveryEndpointFactoryTests.cs b/src/RestClient/Authenticators/OAuth/test/DiscoveryEndpointFactoryTests.cs index eb8abcc..ea439a3 100644 --- a/src/RestClient/Authenticators/OAuth/test/DiscoveryEndpointFactoryTests.cs +++ b/src/RestClient/Authenticators/OAuth/test/DiscoveryEndpointFactoryTests.cs @@ -39,7 +39,7 @@ public async Task GetTokenClientAsync_Expired_Refreshes() var endpoints = await factory.GetAsync(); - await Task.Delay(1500); + await Task.Delay(1500, TestContext.Current.CancellationToken); var endpoints2 = await factory.GetAsync(); @@ -76,4 +76,4 @@ public async Task GetTokenClientAsync_ThreadSafe_SameInstance() Assert.Equal(await endpoints1Task, await endpoints2Task); } -} \ No newline at end of file +} diff --git a/src/RestClient/Authenticators/OAuth/test/TokenSource/TokenStoreTokenSourceTests.cs b/src/RestClient/Authenticators/OAuth/test/TokenSource/TokenStoreTokenSourceTests.cs index e3ce31a..35c011c 100644 --- a/src/RestClient/Authenticators/OAuth/test/TokenSource/TokenStoreTokenSourceTests.cs +++ b/src/RestClient/Authenticators/OAuth/test/TokenSource/TokenStoreTokenSourceTests.cs @@ -17,8 +17,8 @@ public async Task GetTokensAsync_TokenStoreReturnsNull_DoesNotReturnListWithNull var source = new TokenStoreTokenSource(tokenStore.Object); - var tokens = await source.GetTokensAsync(); + var tokens = await source.GetTokensAsync(TestContext.Current.CancellationToken); Assert.Empty(tokens); } -} \ No newline at end of file +} diff --git a/src/RestClient/RestClient/src/ClickView.Extensions.RestClient.csproj b/src/RestClient/RestClient/src/ClickView.Extensions.RestClient.csproj index dcf6f73..769eaca 100644 --- a/src/RestClient/RestClient/src/ClickView.Extensions.RestClient.csproj +++ b/src/RestClient/RestClient/src/ClickView.Extensions.RestClient.csproj @@ -3,7 +3,6 @@ $(FullTargetFrameworks) restclient rest http - enable @@ -18,7 +17,7 @@ - + diff --git a/src/RestClient/RestClient/test/ClickView.Extensions.RestClient.Tests.csproj b/src/RestClient/RestClient/test/ClickView.Extensions.RestClient.Tests.csproj index a377742..a7000d5 100644 --- a/src/RestClient/RestClient/test/ClickView.Extensions.RestClient.Tests.csproj +++ b/src/RestClient/RestClient/test/ClickView.Extensions.RestClient.Tests.csproj @@ -3,13 +3,13 @@ $(TestTargetFrameworks) false - enable + Exe - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/RestClient/RestClient/test/RestClientRequestTests.cs b/src/RestClient/RestClient/test/RestClientRequestTests.cs index 5cc7474..7cc7e67 100644 --- a/src/RestClient/RestClient/test/RestClientRequestTests.cs +++ b/src/RestClient/RestClient/test/RestClientRequestTests.cs @@ -27,7 +27,9 @@ public async Task GetContent_StreamBody_ReturnsStreamContent() var result = request.GetContent(); var streamContent = Assert.IsType(result); +#pragma warning disable xUnit1051 var bytes = await streamContent.ReadAsByteArrayAsync(); +#pragma warning restore xUnit1051 Assert.Equal(streamContent.Headers.ContentType, MediaTypeHeaderValue.Parse("application/octet-stream")); Assert.Equal([1, 2, 3], bytes); } @@ -41,7 +43,9 @@ public async Task GetContent_StreamBodyContentType_ReturnsStreamContent() var result = request.GetContent(); var streamContent = Assert.IsType(result); +#pragma warning disable xUnit1051 var bytes = await streamContent.ReadAsByteArrayAsync(); +#pragma warning restore xUnit1051 Assert.Equal(streamContent.Headers.ContentType, MediaTypeHeaderValue.Parse("application/test")); Assert.Equal([1, 2, 3], bytes); } @@ -58,7 +62,9 @@ public async Task GetContent_ObjectBody_ReturnsStringContent() var result = request.GetContent(); var streamContent = Assert.IsType(result); +#pragma warning disable xUnit1051 var resultString = await streamContent.ReadAsStringAsync(); +#pragma warning restore xUnit1051 Assert.Equal("hello world", resultString); Assert.Equal("application/test", streamContent.Headers.ContentType?.MediaType); diff --git a/src/RestClient/RestClient/test/RestClientTests.cs b/src/RestClient/RestClient/test/RestClientTests.cs index 5cc8acc..f3911ac 100644 --- a/src/RestClient/RestClient/test/RestClientTests.cs +++ b/src/RestClient/RestClient/test/RestClientTests.cs @@ -40,7 +40,7 @@ public async Task ExecuteAsync_UsesBaseAddress() var client = new RestClient(new Uri("http://clickview.com.au"), new HttpClient(mockMessageHandler.Object)); // act - await client.ExecuteAsync(request); + await client.ExecuteAsync(request, TestContext.Current.CancellationToken); // assert mockMessageHandler.Verify(); @@ -74,7 +74,7 @@ public async Task ExecuteAsync_UsesBaseAddressOverHttpClientBaseAddress() }); // act - await client.ExecuteAsync(request); + await client.ExecuteAsync(request, TestContext.Current.CancellationToken); // assert mockMessageHandler.Verify(); @@ -108,7 +108,7 @@ public async Task ExecuteAsync_UsesHttpClientBaseAddress() }); // act - await client.ExecuteAsync(request); + await client.ExecuteAsync(request, TestContext.Current.CancellationToken); // assert mockMessageHandler.Verify(); @@ -142,7 +142,7 @@ public async Task ExecuteAsync_AbsoluteUriRequest() }); // act - await client.ExecuteAsync(request); + await client.ExecuteAsync(request, TestContext.Current.CancellationToken); // assert mockMessageHandler.Verify(); @@ -159,7 +159,7 @@ public async Task ExecuteAsync_NoBaseAddress_ThrowsInvalidOperationException() var client = new RestClient(new HttpClient(mockMessageHandler.Object)); // act/assert - await Assert.ThrowsAsync(() => client.ExecuteAsync(request)); + await Assert.ThrowsAsync(() => client.ExecuteAsync(request, TestContext.Current.CancellationToken)); } [Fact] @@ -186,7 +186,7 @@ public async Task ExecuteAsync_AddBodyStream_MessageContentStreamContent() request.AddBody(new MemoryStream()); - var response = await client.ExecuteAsync(request); + var response = await client.ExecuteAsync(request, TestContext.Current.CancellationToken); mockMessageHandler.Verify(); Assert.Equal("test: success", response.Data); @@ -231,7 +231,7 @@ public async Task ExecuteAsync_DefaultUserAgentSet_RequestContainsDefaultUserAge DefaultUserAgent = "testapp/1.0.0 (rv:1; test; example/1.2.3)" }); - await client.ExecuteAsync(request); + await client.ExecuteAsync(request, TestContext.Current.CancellationToken); mockMessageHandler.Verify(); Assert.Equal("testapp/1.0.0 (rv:1; test; example/1.2.3)", userAgentHeader); @@ -244,4 +244,4 @@ protected override async ValueTask> ParseResponseAsyn return new RestClientResponse(message, await message.Content.ReadAsStringAsync()); } } -} \ No newline at end of file +} diff --git a/src/RestClient/examples/ExampleClient/ErrorResponse.cs b/src/RestClient/examples/ExampleClient/ErrorResponse.cs index 7331fd0..6be46fc 100644 --- a/src/RestClient/examples/ExampleClient/ErrorResponse.cs +++ b/src/RestClient/examples/ExampleClient/ErrorResponse.cs @@ -2,5 +2,5 @@ public class ErrorResponse { - public string Message { get; set; } -} \ No newline at end of file + public string? Message { get; set; } +} diff --git a/src/RestClient/examples/ExampleClient/ExampleApiClient.cs b/src/RestClient/examples/ExampleClient/ExampleApiClient.cs index 6e8560d..f37eb17 100644 --- a/src/RestClient/examples/ExampleClient/ExampleApiClient.cs +++ b/src/RestClient/examples/ExampleClient/ExampleApiClient.cs @@ -24,21 +24,21 @@ public ExampleApiClient(Uri baseAddress, string authKey) /// /// /// - public async Task GetUserCustomRequestAsync(string username) + public async Task GetUserCustomRequestAsync(string username) { - var response = await _client.ExecuteAsync(new ExampleUserRequest(username)).ConfigureAwait(false); + var response = await _client.ExecuteAsync(new ExampleUserRequest(username)); return response.Data; } - public async Task GetUserAsync(string username) + public async Task GetUserAsync(string username) { var request = new RestClientRequest(HttpMethod.Get, "v1/users"); request.AddQueryParameter("username", username); - var response = await _client.ExecuteAsync(request).ConfigureAwait(false); + var response = await _client.ExecuteAsync(request); return response.Data; } -} \ No newline at end of file +} diff --git a/src/RestClient/examples/ExampleClient/ExampleUserRequest.cs b/src/RestClient/examples/ExampleClient/ExampleUserRequest.cs index 87a8404..866bbca 100644 --- a/src/RestClient/examples/ExampleClient/ExampleUserRequest.cs +++ b/src/RestClient/examples/ExampleClient/ExampleUserRequest.cs @@ -1,5 +1,6 @@ namespace ExampleClient; +using System.Diagnostics.CodeAnalysis; using System.Net; using System.Net.Http; using ClickView.Extensions.RestClient; @@ -26,7 +27,7 @@ protected override void HandleError(Error error) base.HandleError(error); } - protected override bool TryParseErrorBody(string content, out ErrorBody error) + protected override bool TryParseErrorBody(string content, [NotNullWhen(true)] out ErrorBody? error) { var errorResponse = Deserialize(content); @@ -43,4 +44,4 @@ protected override bool TryParseErrorBody(string content, out ErrorBody error) return true; } -} \ No newline at end of file +} diff --git a/src/RestClient/examples/ExampleClient/UserModel.cs b/src/RestClient/examples/ExampleClient/UserModel.cs index 748b269..aab6034 100644 --- a/src/RestClient/examples/ExampleClient/UserModel.cs +++ b/src/RestClient/examples/ExampleClient/UserModel.cs @@ -2,5 +2,5 @@ public class UserModel { - public string Username { get; set; } -} \ No newline at end of file + public string? Username { get; set; } +} diff --git a/src/Utilities/Utilities/src/ClickView.Extensions.Utilities.csproj b/src/Utilities/Utilities/src/ClickView.Extensions.Utilities.csproj index 3b4012f..bb6b20f 100644 --- a/src/Utilities/Utilities/src/ClickView.Extensions.Utilities.csproj +++ b/src/Utilities/Utilities/src/ClickView.Extensions.Utilities.csproj @@ -3,7 +3,6 @@ $(FullTargetFrameworks) utilities - enable diff --git a/src/Utilities/Utilities/test/ClickView.Extensions.Utilities.Tests/ClickView.Extensions.Utilities.Tests.csproj b/src/Utilities/Utilities/test/ClickView.Extensions.Utilities.Tests/ClickView.Extensions.Utilities.Tests.csproj index 685571e..8164922 100644 --- a/src/Utilities/Utilities/test/ClickView.Extensions.Utilities.Tests/ClickView.Extensions.Utilities.Tests.csproj +++ b/src/Utilities/Utilities/test/ClickView.Extensions.Utilities.Tests/ClickView.Extensions.Utilities.Tests.csproj @@ -3,7 +3,7 @@ $(TestTargetFrameworks) false - enable + Exe @@ -18,7 +18,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive