diff --git a/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationHostBuilderExtensions.cs b/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationHostBuilderExtensions.cs index 1dfb19c3..8bdc9884 100644 --- a/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationHostBuilderExtensions.cs +++ b/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationHostBuilderExtensions.cs @@ -31,10 +31,10 @@ public static IHostBuilder UseConfigurationValue(this IHostBuilder hostBuilder, { var memoryConfigurationSource = new MemoryConfigurationSource { - InitialData = new List> - { + InitialData = + [ new KeyValuePair(key, value), - }, + ], }; builder.Add(memoryConfigurationSource); }); diff --git a/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationWebHostBuilderExtensions.cs b/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationWebHostBuilderExtensions.cs index 9a1a4f85..0bd3a72b 100644 --- a/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationWebHostBuilderExtensions.cs +++ b/src/DotNet.Sdk.Extensions.Testing/Configuration/TestConfigurationWebHostBuilderExtensions.cs @@ -31,10 +31,10 @@ public static IWebHostBuilder UseConfigurationValue(this IWebHostBuilder builder { var memoryConfigurationSource = new MemoryConfigurationSource { - InitialData = new List> - { + InitialData = + [ new KeyValuePair(key, value), - }, + ], }; appConfigBuilder.Add(memoryConfigurationSource); }); diff --git a/src/DotNet.Sdk.Extensions.Testing/HttpMocking/OutOfProcess/MockServers/HttpMockServerExtensions.cs b/src/DotNet.Sdk.Extensions.Testing/HttpMocking/OutOfProcess/MockServers/HttpMockServerExtensions.cs index d45f20bb..e6efe769 100644 --- a/src/DotNet.Sdk.Extensions.Testing/HttpMocking/OutOfProcess/MockServers/HttpMockServerExtensions.cs +++ b/src/DotNet.Sdk.Extensions.Testing/HttpMocking/OutOfProcess/MockServers/HttpMockServerExtensions.cs @@ -9,7 +9,7 @@ public static ICollection GetServerAddresses(this IHost host) var server = host.Services.GetRequiredService(); var addressFeature = server.Features.Get(); return addressFeature is null - ? new List() + ? [] : addressFeature.Addresses; } diff --git a/tests/DotNet.Sdk.Extensions.Testing.Tests/DotNet.Sdk.Extensions.Testing.Tests.csproj b/tests/DotNet.Sdk.Extensions.Testing.Tests/DotNet.Sdk.Extensions.Testing.Tests.csproj index d73ca19f..db21d715 100644 --- a/tests/DotNet.Sdk.Extensions.Testing.Tests/DotNet.Sdk.Extensions.Testing.Tests.csproj +++ b/tests/DotNet.Sdk.Extensions.Testing.Tests/DotNet.Sdk.Extensions.Testing.Tests.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithAsyncPredicateTests.cs b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithAsyncPredicateTests.cs index 44b0e21e..e8bfa808 100644 --- a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithAsyncPredicateTests.cs +++ b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithAsyncPredicateTests.cs @@ -6,14 +6,12 @@ namespace DotNet.Sdk.Extensions.Testing.Tests.HostedServices; [Trait("Category", XUnitCategories.HostedServices)] public class RunUntilHostExtensionsWithAsyncPredicateTests { -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose public static TheoryData ValidateArgumentsData => new TheoryData { { null!, () => Task.FromResult(true), typeof(ArgumentNullException), "Value cannot be null. (Parameter 'host')" }, { CreateHost(), null!, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'predicateAsync')" }, }; -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose private static IHost CreateHost() { diff --git a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithSyncPredicateTests.cs b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithSyncPredicateTests.cs index a1d5b48b..7d969c18 100644 --- a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithSyncPredicateTests.cs +++ b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilHostExtensionsWithSyncPredicateTests.cs @@ -6,14 +6,12 @@ namespace DotNet.Sdk.Extensions.Testing.Tests.HostedServices; [Trait("Category", XUnitCategories.HostedServices)] public class RunUntilHostExtensionsWithSyncPredicateTests { -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose public static TheoryData ValidateArgumentsData => new TheoryData { { null!, () => true, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'host')" }, { CreateHost(), null!, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'predicate')" }, }; -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose private static IHost CreateHost() { diff --git a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithAsyncPredicateTests.cs b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithAsyncPredicateTests.cs index a2ace5cf..b6527de4 100644 --- a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithAsyncPredicateTests.cs +++ b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithAsyncPredicateTests.cs @@ -7,14 +7,12 @@ namespace DotNet.Sdk.Extensions.Testing.Tests.HostedServices; [Trait("Category", XUnitCategories.HostedServices)] public class RunUntilWebApplicationFactoryExtensionsWithAsyncPredicateTests { -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose public static TheoryData ValidateArgumentsData => new TheoryData { { null!, () => Task.FromResult(true), typeof(ArgumentNullException), "Value cannot be null. (Parameter 'webApplicationFactory')" }, { new HostedServicesWebApplicationFactory(), null!, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'predicateAsync')" }, }; -#pragma warning restore CA2000 // Dispose objects before losing scope - the test method will do the dispose /// /// Validates the arguments for the @@ -35,7 +33,6 @@ public void ValidatesArguments( webApplicationFactory?.Dispose(); } -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose public static TheoryData, Type, string> ValidateArgumentsWithOptionsData => new TheoryData, Type, string> { @@ -43,7 +40,6 @@ public void ValidatesArguments( { new HostedServicesWebApplicationFactory(), null!, _ => { }, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'predicateAsync')" }, { new HostedServicesWebApplicationFactory(), () => Task.FromResult(true), null!, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'configureOptions')" }, }; -#pragma warning restore CA2000 // Dispose objects before losing scope - the test method will do the dispose /// /// Validates the arguments for the diff --git a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithSyncPredicateTests.cs b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithSyncPredicateTests.cs index d517ff04..d398598a 100644 --- a/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithSyncPredicateTests.cs +++ b/tests/DotNet.Sdk.Extensions.Testing.Tests/HostedServices/RunUntilWebApplicationFactoryExtensionsWithSyncPredicateTests.cs @@ -7,14 +7,12 @@ namespace DotNet.Sdk.Extensions.Testing.Tests.HostedServices; [Trait("Category", XUnitCategories.HostedServices)] public class RunUntilWebApplicationFactoryExtensionsWithSyncPredicateTests { -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose public static TheoryData ValidateArgumentsData => new TheoryData { { null!, () => true, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'webApplicationFactory')" }, { new HostedServicesWebApplicationFactory(), null!, typeof(ArgumentNullException), "Value cannot be null. (Parameter 'predicate')" }, }; -#pragma warning disable CA2000 // Dispose objects before losing scope - the test method will do the dispose /// /// Validates the arguments for the diff --git a/tests/DotNet.Sdk.Extensions.Tests/DotNet.Sdk.Extensions.Tests.csproj b/tests/DotNet.Sdk.Extensions.Tests/DotNet.Sdk.Extensions.Tests.csproj index 7d96285e..5d1cd6ca 100644 --- a/tests/DotNet.Sdk.Extensions.Tests/DotNet.Sdk.Extensions.Tests.csproj +++ b/tests/DotNet.Sdk.Extensions.Tests/DotNet.Sdk.Extensions.Tests.csproj @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/DotNet.Sdk.Extensions.Tests/Options/AddOptionsValue/AddOptionsValueTests.cs b/tests/DotNet.Sdk.Extensions.Tests/Options/AddOptionsValue/AddOptionsValueTests.cs index 340aadcf..21e53b21 100644 --- a/tests/DotNet.Sdk.Extensions.Tests/Options/AddOptionsValue/AddOptionsValueTests.cs +++ b/tests/DotNet.Sdk.Extensions.Tests/Options/AddOptionsValue/AddOptionsValueTests.cs @@ -10,7 +10,7 @@ public class AddOptionsValueTests [Fact] public void AddsOptionsType1() { - using var configuration = new ConfigurationRoot(new List()); + using var configuration = new ConfigurationRoot([]); var serviceCollection = new ServiceCollection(); serviceCollection.AddOptionsValue(configuration); var serviceProvider = serviceCollection.BuildServiceProvider(); @@ -25,7 +25,7 @@ public void AddsOptionsType1() [Fact] public void ValidatesArguments1() { - using var configuration = new ConfigurationRoot(new List()); + using var configuration = new ConfigurationRoot([]); var servicesArgumentNullException = Should.Throw(() => { OptionsBuilderExtensions.AddOptionsValue(services: null!, configuration); @@ -42,10 +42,10 @@ public void AddsOptionsType2() { var memoryConfigurationSource = new MemoryConfigurationSource { - InitialData = new List> - { + InitialData = + [ new KeyValuePair("MyOptionsSection:SomeOption", "some value"), - }, + ], }; var memoryConfigurationProvider = new MemoryConfigurationProvider(memoryConfigurationSource); var configurationProviders = new List { memoryConfigurationProvider }; @@ -65,7 +65,7 @@ public void AddsOptionsType2() [Fact] public void ValidatesArguments2() { - using var configuration = new ConfigurationRoot(new List()); + using var configuration = new ConfigurationRoot([]); var serviceCollection = new ServiceCollection(); var servicesArgumentNullException = Should.Throw(() => { @@ -86,7 +86,7 @@ public void ValidatesArguments2() [Fact] public void AddsOptionsType3() { - using var configuration = new ConfigurationRoot(new List()); + using var configuration = new ConfigurationRoot([]); var serviceCollection = new ServiceCollection(); serviceCollection .AddOptions() diff --git a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/CircuitBreaker/Auxiliary/CircuitBreakerPolicyEventHandlerCalls.cs b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/CircuitBreaker/Auxiliary/CircuitBreakerPolicyEventHandlerCalls.cs index 74104428..d38b7bf3 100644 --- a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/CircuitBreaker/Auxiliary/CircuitBreakerPolicyEventHandlerCalls.cs +++ b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/CircuitBreaker/Auxiliary/CircuitBreakerPolicyEventHandlerCalls.cs @@ -2,11 +2,11 @@ namespace DotNet.Sdk.Extensions.Tests.Polly.Http.CircuitBreaker.Auxiliary; public class CircuitBreakerPolicyEventHandlerCalls { - public IList OnBreakAsyncCalls { get; } = new List(); + public IList OnBreakAsyncCalls { get; } = []; - public IList OnHalfOpenAsyncCalls { get; } = new List(); + public IList OnHalfOpenAsyncCalls { get; } = []; - public IList OnResetAsyncCalls { get; } = new List(); + public IList OnResetAsyncCalls { get; } = []; public void AddOnBreak(BreakEvent breakEvent) { diff --git a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Fallback/Auxiliary/FallbackPolicyEventHandlerCalls.cs b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Fallback/Auxiliary/FallbackPolicyEventHandlerCalls.cs index 9f0c64f3..6dfdeff6 100644 --- a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Fallback/Auxiliary/FallbackPolicyEventHandlerCalls.cs +++ b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Fallback/Auxiliary/FallbackPolicyEventHandlerCalls.cs @@ -2,13 +2,13 @@ namespace DotNet.Sdk.Extensions.Tests.Polly.Http.Fallback.Auxiliary; public class FallbackPolicyEventHandlerCalls { - public IList OnHttpRequestExceptionFallbackAsyncCalls { get; } = new List(); + public IList OnHttpRequestExceptionFallbackAsyncCalls { get; } = []; - public IList OnTimeoutFallbackAsyncCalls { get; } = new List(); + public IList OnTimeoutFallbackAsyncCalls { get; } = []; - public IList OnBrokenCircuitFallbackAsyncCalls { get; } = new List(); + public IList OnBrokenCircuitFallbackAsyncCalls { get; } = []; - public IList OnTaskCancelledFallbackAsyncCalls { get; } = new List(); + public IList OnTaskCancelledFallbackAsyncCalls { get; } = []; public void AddOnHttpRequestExceptionFallback(FallbackEvent fallbackEvent) { diff --git a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Retry/Auxiliary/RetryPolicyEventHandlerCalls.cs b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Retry/Auxiliary/RetryPolicyEventHandlerCalls.cs index 49579d93..c20b7556 100644 --- a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Retry/Auxiliary/RetryPolicyEventHandlerCalls.cs +++ b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Retry/Auxiliary/RetryPolicyEventHandlerCalls.cs @@ -2,7 +2,7 @@ namespace DotNet.Sdk.Extensions.Tests.Polly.Http.Retry.Auxiliary; public class RetryPolicyEventHandlerCalls { - public IList OnRetryAsyncCalls { get; } = new List(); + public IList OnRetryAsyncCalls { get; } = []; public void AddOnRetry(RetryEvent retryEvent) { diff --git a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Timeout/Auxiliary/TimeoutPolicyEventHandlerCalls.cs b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Timeout/Auxiliary/TimeoutPolicyEventHandlerCalls.cs index 74c74923..67ba9c08 100644 --- a/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Timeout/Auxiliary/TimeoutPolicyEventHandlerCalls.cs +++ b/tests/DotNet.Sdk.Extensions.Tests/Polly/Http/Timeout/Auxiliary/TimeoutPolicyEventHandlerCalls.cs @@ -2,7 +2,7 @@ namespace DotNet.Sdk.Extensions.Tests.Polly.Http.Timeout.Auxiliary; public class TimeoutPolicyEventHandlerCalls { - public IList OnTimeoutAsyncCalls { get; } = new List(); + public IList OnTimeoutAsyncCalls { get; } = []; public void AddOnTimeout(TimeoutEvent timeoutEvent) {