diff --git a/.editorconfig b/.editorconfig index adf8ab64ba..ae71398246 100644 --- a/.editorconfig +++ b/.editorconfig @@ -162,3 +162,7 @@ dotnet_diagnostic.JSON002.severity = silent # CA1848: Use the LoggerMessage delegates (depends on https://github.com/SteeltoeOSS/Steeltoe/issues/969) dotnet_diagnostic.CA1848.severity = silent + +[*Test.cs] +resharper_access_to_disposed_closure_highlighting = none +resharper_access_to_modified_closure_highlighting = none diff --git a/src/Common/src/Common/Discovery/IDiscoveryClient.cs b/src/Common/src/Common/Discovery/IDiscoveryClient.cs index bd2b8c3cb8..07c9c21b0c 100644 --- a/src/Common/src/Common/Discovery/IDiscoveryClient.cs +++ b/src/Common/src/Common/Discovery/IDiscoveryClient.cs @@ -17,7 +17,7 @@ public interface IDiscoveryClient /// /// Occurs when service instances have been fetched from the discovery server. /// - public event EventHandler InstancesFetched; + event EventHandler InstancesFetched; /// /// Gets information used to register the local service instance (this app) to the discovery server. diff --git a/src/Common/test/Hosting.Test/HostBuilderWrapperTest.cs b/src/Common/test/Hosting.Test/HostBuilderWrapperTest.cs index 65e138ca66..1e5b7ea4d1 100644 --- a/src/Common/test/Hosting.Test/HostBuilderWrapperTest.cs +++ b/src/Common/test/Hosting.Test/HostBuilderWrapperTest.cs @@ -29,7 +29,6 @@ public async Task WebApplicationBuilder_Wraps() HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder); wrapper.ConfigureServices(services => services.AddSingleton()); wrapper.ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddInMemoryCollection(appSettings)); - // ReSharper disable once AccessToDisposedClosure wrapper.ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(capturingLoggerProvider)); wrapper.ConfigureWebHost(hostBuilder => hostBuilder.UseUrls("http://*:8888")); wrapper.ConfigureServices((contextWrapper, _) => contextWrapper.HostEnvironment.ApplicationName = "TestApp"); @@ -65,7 +64,6 @@ public void HostApplicationBuilder_Wraps() HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder); wrapper.ConfigureServices(services => services.AddSingleton()); wrapper.ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddInMemoryCollection(appSettings)); - // ReSharper disable once AccessToDisposedClosure wrapper.ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(capturingLoggerProvider)); wrapper.ConfigureServices((contextWrapper, _) => contextWrapper.HostEnvironment.ApplicationName = "TestApp"); @@ -100,7 +98,6 @@ public void WebHostBuilder_Wraps() HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder); wrapper.ConfigureServices(services => services.AddSingleton()); wrapper.ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddInMemoryCollection(appSettings)); - // ReSharper disable once AccessToDisposedClosure wrapper.ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(capturingLoggerProvider)); wrapper.ConfigureWebHost(hostBuilder => hostBuilder.UseUrls("http://*:8888")); wrapper.ConfigureServices((contextWrapper, _) => contextWrapper.HostEnvironment.ApplicationName = "TestApp"); @@ -138,7 +135,6 @@ public void GenericHostBuilder_Wraps() HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder); wrapper.ConfigureServices(services => services.AddSingleton()); wrapper.ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddInMemoryCollection(appSettings)); - // ReSharper disable once AccessToDisposedClosure wrapper.ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(capturingLoggerProvider)); wrapper.ConfigureWebHost(hostBuilder => hostBuilder.UseUrls("http://*:8888")); wrapper.ConfigureServices((contextWrapper, _) => contextWrapper.HostEnvironment.ApplicationName = "TestApp"); diff --git a/src/Common/test/Logging.Test/BootstrapperLoggerFactoryTest.cs b/src/Common/test/Logging.Test/BootstrapperLoggerFactoryTest.cs index 79ea85acc6..434e7feaeb 100644 --- a/src/Common/test/Logging.Test/BootstrapperLoggerFactoryTest.cs +++ b/src/Common/test/Logging.Test/BootstrapperLoggerFactoryTest.cs @@ -20,7 +20,6 @@ public async Task Upgrades_existing_loggers() var bootstrapLoggerFactory = BootstrapLoggerFactory.CreateEmpty(loggingBuilder => { loggingBuilder.SetMinimumLevel(LogLevel.Trace); - // ReSharper disable once AccessToDisposedClosure loggingBuilder.AddProvider(capturingLoggerProvider); }); diff --git a/src/Configuration/test/CloudFoundry.Test/CloudfoundryConfigurationProviderTest.cs b/src/Configuration/test/CloudFoundry.Test/CloudfoundryConfigurationProviderTest.cs index d461d659a7..5566efc479 100644 --- a/src/Configuration/test/CloudFoundry.Test/CloudfoundryConfigurationProviderTest.cs +++ b/src/Configuration/test/CloudFoundry.Test/CloudfoundryConfigurationProviderTest.cs @@ -216,7 +216,6 @@ public void Load_VCAP_APPLICATION_Allows_Reload_Without_Throwing_Exception() _ = Task.Run(() => { - // ReSharper disable once AccessToDisposedClosure while (!tokenSource.IsCancellationRequested) { configurationRoot.Reload(); diff --git a/src/Configuration/test/ConfigServer.Discovery.Test/ConfigServerClientOptionsTest.cs b/src/Configuration/test/ConfigServer.Discovery.Test/ConfigServerClientOptionsTest.cs index 5ca2eab3c0..61c57e5a36 100644 --- a/src/Configuration/test/ConfigServer.Discovery.Test/ConfigServerClientOptionsTest.cs +++ b/src/Configuration/test/ConfigServer.Discovery.Test/ConfigServerClientOptionsTest.cs @@ -90,7 +90,6 @@ public void Config_Server_URI_is_resolved_from_discovery_and_survives_changes_in var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryAppSettingsJsonFile(fileProvider); - // ReSharper disable once AccessToDisposedClosure configurationBuilder.AddConfigServer(new ConfigServerClientOptions(), configureOptions, () => handler, NullLoggerFactory.Instance); IConfigurationRoot configuration = configurationBuilder.Build(); @@ -306,7 +305,6 @@ public void Updates_discovered_Config_Server_URI_on_provider_reload() var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryAppSettingsJsonFile(fileProvider); - // ReSharper disable once AccessToDisposedClosure configurationBuilder.AddConfigServer(new ConfigServerClientOptions(), configureOptions, () => handler, NullLoggerFactory.Instance); IConfigurationRoot configuration = configurationBuilder.Build(); diff --git a/src/Configuration/test/ConfigServer.Test/ConfigServerClientOptionsTest.cs b/src/Configuration/test/ConfigServer.Test/ConfigServerClientOptionsTest.cs index 2c648dc0b3..27d0f98929 100644 --- a/src/Configuration/test/ConfigServer.Test/ConfigServerClientOptionsTest.cs +++ b/src/Configuration/test/ConfigServer.Test/ConfigServerClientOptionsTest.cs @@ -265,7 +265,6 @@ public void Certificate_configuration_survives_options_reload() var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryAppSettingsJsonFile(fileProvider); - // ReSharper disable once AccessToDisposedClosure configurationBuilder.AddConfigServer(new ConfigServerClientOptions(), null, () => handler, NullLoggerFactory.Instance); IConfigurationRoot configuration = configurationBuilder.Build(); @@ -368,7 +367,6 @@ public void Changes_in_IConfiguration_update_provider_options_and_injected_optio var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddInMemoryAppSettingsJsonFile(fileProvider); configurationBuilder.AddPlaceholderResolver(); - // ReSharper disable once AccessToDisposedClosure configurationBuilder.AddConfigServer(defaultOptions, configureOptions, () => handler, NullLoggerFactory.Instance); IConfigurationRoot configuration = configurationBuilder.Build(); diff --git a/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.Settings.cs b/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.Settings.cs index 1cd6f664f6..d043acfc9c 100644 --- a/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.Settings.cs +++ b/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.Settings.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging.Abstractions; +// ReSharper disable AccessToDisposedClosure + namespace Steeltoe.Configuration.ConfigServer.Test; public sealed partial class ConfigServerConfigurationProviderTest @@ -65,9 +67,7 @@ public void GetConfigServerUri_NoBaseUri_Throws() using var provider = new ConfigServerConfigurationProvider(options, null, null, null, NullLoggerFactory.Instance); - // ReSharper disable AccessToDisposedClosure Action action = () => provider.BuildConfigServerUri(provider.ClientOptions, null!, null); - // ReSharper restore AccessToDisposedClosure action.Should().ThrowExactly(); } diff --git a/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.cs b/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.cs index 7b8c950a39..7b588ee87a 100644 --- a/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.cs +++ b/src/Configuration/test/ConfigServer.Test/ConfigServerConfigurationProviderTest.cs @@ -264,7 +264,6 @@ public async Task GetRequestMessage_AddsBearerToken_WhenAccessTokenUriIsSet() } """); - // ReSharper disable once AccessToDisposedClosure using var provider = new ConfigServerConfigurationProvider(options, null, null, () => handler, NullLoggerFactory.Instance); Uri requestUri = provider.BuildConfigServerUri(provider.ClientOptions, new Uri(options.Uri), null); @@ -294,7 +293,6 @@ public async Task RefreshVaultToken_Succeeds() handler.Mock.Expect(HttpMethod.Post, "http://localhost:8888/vault/v1/auth/token/renew-self").WithHeaders("X-Vault-Token", "MyVaultToken") .WithContent("{\"increment\":300}").Respond(HttpStatusCode.NoContent); - // ReSharper disable once AccessToDisposedClosure using var provider = new ConfigServerConfigurationProvider(options, null, null, () => handler, NullLoggerFactory.Instance); provider.Load(); @@ -324,7 +322,6 @@ public async Task RefreshVaultToken_With_AccessTokenUri_Succeeds() handler.Mock.Expect(HttpMethod.Post, "http://localhost:8888/vault/v1/auth/token/renew-self").WithHeaders("X-Vault-Token", "MyVaultToken") .WithHeaders("Authorization", "Bearer secret").WithContent("{\"increment\":300}").Respond(HttpStatusCode.NoContent); - // ReSharper disable once AccessToDisposedClosure using var provider = new ConfigServerConfigurationProvider(options, null, null, () => handler, NullLoggerFactory.Instance); await provider.RefreshVaultTokenAsync(provider.ClientOptions, TestContext.Current.CancellationToken); diff --git a/src/Connectors/test/Connectors.Test/CosmosDb/CosmosDbHealthContributorTest.cs b/src/Connectors/test/Connectors.Test/CosmosDb/CosmosDbHealthContributorTest.cs index 303f5c0c21..990db81109 100644 --- a/src/Connectors/test/Connectors.Test/CosmosDb/CosmosDbHealthContributorTest.cs +++ b/src/Connectors/test/Connectors.Test/CosmosDb/CosmosDbHealthContributorTest.cs @@ -116,9 +116,7 @@ public async Task Canceled_Throws() using var source = new CancellationTokenSource(); await source.CancelAsync(); - // ReSharper disable AccessToDisposedClosure Func action = async () => await healthContributor.CheckHealthAsync(source.Token); - // ReSharper restore AccessToDisposedClosure await action.Should().ThrowExactlyAsync(); } diff --git a/src/Connectors/test/Connectors.Test/MongoDb/MongoDbHealthContributorTest.cs b/src/Connectors/test/Connectors.Test/MongoDb/MongoDbHealthContributorTest.cs index abf1a00a0a..d57155154b 100644 --- a/src/Connectors/test/Connectors.Test/MongoDb/MongoDbHealthContributorTest.cs +++ b/src/Connectors/test/Connectors.Test/MongoDb/MongoDbHealthContributorTest.cs @@ -86,7 +86,6 @@ public async Task Canceled_Throws() using var source = new CancellationTokenSource(); await source.CancelAsync(); - // ReSharper disable once AccessToDisposedClosure Func action = async () => await healthContributor.CheckHealthAsync(source.Token); await action.Should().ThrowExactlyAsync(); diff --git a/src/Connectors/test/Connectors.Test/RabbitMQ/RabbitMQHealthContributorTest.cs b/src/Connectors/test/Connectors.Test/RabbitMQ/RabbitMQHealthContributorTest.cs index 7d8ee14216..7f3290395e 100644 --- a/src/Connectors/test/Connectors.Test/RabbitMQ/RabbitMQHealthContributorTest.cs +++ b/src/Connectors/test/Connectors.Test/RabbitMQ/RabbitMQHealthContributorTest.cs @@ -109,9 +109,7 @@ public async Task Canceled_Throws() using var source = new CancellationTokenSource(); await source.CancelAsync(); - // ReSharper disable AccessToDisposedClosure Func action = async () => await healthContributor.CheckHealthAsync(source.Token); - // ReSharper restore AccessToDisposedClosure await action.Should().ThrowExactlyAsync(); } diff --git a/src/Connectors/test/Connectors.Test/Redis/RedisHealthContributorTest.cs b/src/Connectors/test/Connectors.Test/Redis/RedisHealthContributorTest.cs index f2dc8540d4..aa0bcf3988 100644 --- a/src/Connectors/test/Connectors.Test/Redis/RedisHealthContributorTest.cs +++ b/src/Connectors/test/Connectors.Test/Redis/RedisHealthContributorTest.cs @@ -74,9 +74,7 @@ public async Task Canceled_Throws() using var source = new CancellationTokenSource(); await source.CancelAsync(); - // ReSharper disable AccessToDisposedClosure Func action = async () => await healthContributor.CheckHealthAsync(source.Token); - // ReSharper restore AccessToDisposedClosure await action.Should().ThrowExactlyAsync(); } diff --git a/src/Connectors/test/Connectors.Test/RelationalDatabaseHealthContributorTest.cs b/src/Connectors/test/Connectors.Test/RelationalDatabaseHealthContributorTest.cs index 267d293dac..de229c4d91 100644 --- a/src/Connectors/test/Connectors.Test/RelationalDatabaseHealthContributorTest.cs +++ b/src/Connectors/test/Connectors.Test/RelationalDatabaseHealthContributorTest.cs @@ -175,9 +175,7 @@ public async Task Canceled_Throws() using var source = new CancellationTokenSource(); await source.CancelAsync(); - // ReSharper disable AccessToDisposedClosure Func action = async () => await healthContributor.CheckHealthAsync(source.Token); - // ReSharper restore AccessToDisposedClosure await action.Should().ThrowExactlyAsync(); } diff --git a/src/Connectors/test/EntityFrameworkCore.Test/MySql/Pomelo/MySqlDbContextOptionsBuilderExtensionsTest.cs b/src/Connectors/test/EntityFrameworkCore.Test/MySql/Pomelo/MySqlDbContextOptionsBuilderExtensionsTest.cs index 17a40ea71e..320feb7679 100644 --- a/src/Connectors/test/EntityFrameworkCore.Test/MySql/Pomelo/MySqlDbContextOptionsBuilderExtensionsTest.cs +++ b/src/Connectors/test/EntityFrameworkCore.Test/MySql/Pomelo/MySqlDbContextOptionsBuilderExtensionsTest.cs @@ -88,7 +88,6 @@ public async Task Throws_for_missing_connection_string_with_version_detection() await using WebApplication app = builder.Build(); await using AsyncServiceScope scope = app.Services.CreateAsyncScope(); - // ReSharper disable once AccessToDisposedClosure Action action = () => _ = scope.ServiceProvider.GetRequiredService(); action.Should().ThrowExactly().WithMessage("Server version must be specified when no connection string is provided."); diff --git a/src/Discovery/test/Consul.Test/Discovery/TtlSchedulerTest.cs b/src/Discovery/test/Consul.Test/Discovery/TtlSchedulerTest.cs index 4799f45024..7736b6bb7d 100644 --- a/src/Discovery/test/Consul.Test/Discovery/TtlSchedulerTest.cs +++ b/src/Discovery/test/Consul.Test/Discovery/TtlSchedulerTest.cs @@ -20,7 +20,6 @@ public async Task Add_Throws_Invalid_InstanceId() var optionsMonitor = new TestOptionsMonitor(); await using var scheduler = new TtlScheduler(optionsMonitor, clientMoq.Object, NullLoggerFactory.Instance); - // ReSharper disable once AccessToDisposedClosure Action action = () => scheduler.Add(string.Empty); action.Should().ThrowExactly(); @@ -97,7 +96,6 @@ public async Task Remove_Throws_Invalid_InstanceId() var optionsMonitor = new TestOptionsMonitor(); await using var scheduler = new TtlScheduler(optionsMonitor, clientMoq.Object, NullLoggerFactory.Instance); - // ReSharper disable once AccessToDisposedClosure Func action = async () => await scheduler.RemoveAsync(string.Empty); await action.Should().ThrowExactlyAsync(); diff --git a/src/Discovery/test/Consul.Test/Registry/ConsulServiceRegistryTest.cs b/src/Discovery/test/Consul.Test/Registry/ConsulServiceRegistryTest.cs index a654543c51..0a9c15d66f 100644 --- a/src/Discovery/test/Consul.Test/Registry/ConsulServiceRegistryTest.cs +++ b/src/Discovery/test/Consul.Test/Registry/ConsulServiceRegistryTest.cs @@ -87,7 +87,6 @@ public async Task SetStatusAsync_ThrowsInvalidStatus() await using var registry = new ConsulServiceRegistry(clientMoq.Object, optionsMonitor, scheduler, NullLogger.Instance); - // ReSharper disable once AccessToDisposedClosure Func action = async () => await registry.SetStatusAsync(registration, string.Empty, TestContext.Current.CancellationToken); await action.Should().ThrowExactlyAsync(); diff --git a/src/Discovery/test/Eureka.Test/Transport/EurekaClientTest.cs b/src/Discovery/test/Eureka.Test/Transport/EurekaClientTest.cs index 0b6ece9106..af880a4275 100644 --- a/src/Discovery/test/Eureka.Test/Transport/EurekaClientTest.cs +++ b/src/Discovery/test/Eureka.Test/Transport/EurekaClientTest.cs @@ -13,8 +13,6 @@ using Steeltoe.Discovery.Eureka.Configuration; using Steeltoe.Discovery.Eureka.Transport; -// ReSharper disable AccessToDisposedClosure - namespace Steeltoe.Discovery.Eureka.Test.Transport; public sealed class EurekaClientTest diff --git a/src/Discovery/test/HttpClients.Test/DiscoveryHostApplicationBuilderExtensionsTest.cs b/src/Discovery/test/HttpClients.Test/DiscoveryHostApplicationBuilderExtensionsTest.cs index 48435d1d15..f16be05f32 100644 --- a/src/Discovery/test/HttpClients.Test/DiscoveryHostApplicationBuilderExtensionsTest.cs +++ b/src/Discovery/test/HttpClients.Test/DiscoveryHostApplicationBuilderExtensionsTest.cs @@ -51,7 +51,6 @@ public async Task AddEurekaDiscoveryClient_HostApplicationBuilder_StartsUp() using IHost host = hostBuilder.Build(); - // ReSharper disable once AccessToDisposedClosure Func action = async () => await host.StartAsync(TestContext.Current.CancellationToken); await action.Should().NotThrowAsync(); diff --git a/src/Discovery/test/HttpClients.Test/DiscoveryWebApplicationBuilderExtensionsTest.cs b/src/Discovery/test/HttpClients.Test/DiscoveryWebApplicationBuilderExtensionsTest.cs index 358958b738..1d347f30bc 100644 --- a/src/Discovery/test/HttpClients.Test/DiscoveryWebApplicationBuilderExtensionsTest.cs +++ b/src/Discovery/test/HttpClients.Test/DiscoveryWebApplicationBuilderExtensionsTest.cs @@ -73,7 +73,6 @@ public async Task AddEurekaDiscoveryClient_WorksWithGlobalServiceDiscovery() await using WebApplication host = builder.Build(); - // ReSharper disable once AccessToDisposedClosure Task resolveTask = Task.Run(() => _ = host.Services.GetServices().OfType().Single()); Func action = async () => await resolveTask.WaitAsync(5.Seconds(), TestContext.Current.CancellationToken); diff --git a/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpClientHandlerTest.cs b/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpClientHandlerTest.cs index 37589f843d..00343415b7 100644 --- a/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpClientHandlerTest.cs +++ b/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpClientHandlerTest.cs @@ -17,7 +17,6 @@ public async Task DoesNotTrackStatistics_WhenResolutionFails_WithProvidedLoadBal var handler = new DiscoveryHttpClientHandler(loadBalancer, TimeProvider.System); using var invoker = new HttpMessageInvoker(handler); - // ReSharper disable once AccessToDisposedClosure Func action = async () => _ = await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken); await action.Should().ThrowExactlyAsync(); @@ -33,7 +32,6 @@ public async Task TracksStatistics_WhenRequestsGoWrong_WithProvidedLoadBalancer( var handler = new DiscoveryHttpClientHandler(loadBalancer, TimeProvider.System); using var invoker = new HttpMessageInvoker(handler); - // ReSharper disable once AccessToDisposedClosure Func action = async () => _ = await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken); await action.Should().ThrowExactlyAsync(); diff --git a/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpDelegatingHandlerTest.cs b/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpDelegatingHandlerTest.cs index 19d55c7db3..a7cd3eb814 100644 --- a/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpDelegatingHandlerTest.cs +++ b/src/Discovery/test/HttpClients.Test/LoadBalancers/DiscoveryHttpDelegatingHandlerTest.cs @@ -55,7 +55,6 @@ public async Task DoesNotTrackStatistics_WhenRequestIsCanceled() using var invoker = new HttpMessageInvoker(handler); - // ReSharper disable once AccessToDisposedClosure Func action = async () => await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken); await action.Should().ThrowExactlyAsync(); @@ -80,7 +79,6 @@ public async Task DoesNotTrackStatistics_WhenResolutionFails_WithProvidedLoadBal using var invoker = new HttpMessageInvoker(handler); - // ReSharper disable once AccessToDisposedClosure Func action = async () => await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken); await action.Should().ThrowExactlyAsync(); diff --git a/src/Management/test/Endpoint.Test/Actuators/All/AllActuatorsTest.cs b/src/Management/test/Endpoint.Test/Actuators/All/AllActuatorsTest.cs index 1efdbebb63..c28a325a4d 100644 --- a/src/Management/test/Endpoint.Test/Actuators/All/AllActuatorsTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/All/AllActuatorsTest.cs @@ -62,7 +62,6 @@ public async Task Registers_dependent_services(bool platformIsCloudFoundry) foreach (Type middlewareType in middlewareTypes) { - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(middlewareType); action.Should().NotThrow(); @@ -72,10 +71,8 @@ public async Task Registers_dependent_services(bool platformIsCloudFoundry) { Action action = () => { - // ReSharper disable AccessToDisposedClosure _ = serviceProvider.GetRequiredService(); _ = serviceProvider.GetRequiredService(); - // ReSharper restore AccessToDisposedClosure }; action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundryActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundryActuatorTest.cs index 6a4e565aea..4e0b82d74d 100644 --- a/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundryActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundryActuatorTest.cs @@ -43,11 +43,9 @@ public async Task Registers_dependent_services() services.AddCloudFoundryActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action middlewareAction = () => serviceProvider.GetRequiredService(); middlewareAction.Should().NotThrow(); - // ReSharper disable once AccessToDisposedClosure Action providerAction = () => serviceProvider.GetRequiredService(); providerAction.Should().NotThrow(); } diff --git a/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundrySecurityMiddlewareTest.cs b/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundrySecurityMiddlewareTest.cs index 1197f57d97..44bf05c385 100644 --- a/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundrySecurityMiddlewareTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudFoundrySecurityMiddlewareTest.cs @@ -316,7 +316,6 @@ public async Task ThrowsWhenAddMethodNotCalled() WebApplicationBuilder builder = TestWebApplicationBuilderFactory.Create(); await using WebApplication app = builder.Build(); - // ReSharper disable once AccessToDisposedClosure Action action = () => app.UseCloudFoundrySecurity(); action.Should().ThrowExactly().WithMessage("Please call IServiceCollection.AddCloudFoundryActuator first."); @@ -337,7 +336,6 @@ public async Task RedactsHttpHeaders() WebApplicationBuilder builder = TestWebApplicationBuilderFactory.Create(); builder.Configuration.AddInMemoryCollection(appSettings); builder.Configuration.AddCloudFoundry(); - // ReSharper disable once AccessToDisposedClosure builder.Services.AddLogging(options => options.SetMinimumLevel(LogLevel.Trace).AddProvider(capturingLoggerProvider)); builder.Services.AddCloudFoundryActuator(); await using WebApplication app = builder.Build(); diff --git a/src/Management/test/Endpoint.Test/Actuators/DbMigrations/DbMigrationsActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/DbMigrations/DbMigrationsActuatorTest.cs index 491af47e67..4413007092 100644 --- a/src/Management/test/Endpoint.Test/Actuators/DbMigrations/DbMigrationsActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/DbMigrations/DbMigrationsActuatorTest.cs @@ -30,7 +30,6 @@ public async Task Registers_dependent_services() services.AddDbMigrationsActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Environment/EnvironmentActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Environment/EnvironmentActuatorTest.cs index 897202ec36..4afda96b82 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Environment/EnvironmentActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Environment/EnvironmentActuatorTest.cs @@ -32,7 +32,6 @@ public async Task Registers_dependent_services() services.AddEnvironmentActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Health/HealthActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Health/HealthActuatorTest.cs index 4a5e408466..cbd260f5fc 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Health/HealthActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Health/HealthActuatorTest.cs @@ -40,7 +40,6 @@ public async Task Registers_dependent_services() services.AddHealthActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs b/src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs index ad76b9eaad..68f77a7bb3 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs @@ -450,9 +450,7 @@ public async Task Propagates_cancellation() using var source = new CancellationTokenSource(); source.CancelAfter(1.Seconds()); - // ReSharper disable AccessToDisposedClosure Func action = async () => await aggregator.AggregateAsync(contributors, [], emptyServiceProvider, source.Token); - // ReSharper restore AccessToDisposedClosure await action.Should().ThrowExactlyAsync(); } @@ -574,7 +572,6 @@ public async Task Can_use_scoped_AspNet_health_check() builder.Services.AddHealthActuator(); await using WebApplication host = builder.Build(); - // ReSharper disable once AccessToDisposedClosure Action action = () => host.Services.GetRequiredService(); action.Should().ThrowExactly(); diff --git a/src/Management/test/Endpoint.Test/Actuators/HeapDump/HeapDumpActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/HeapDump/HeapDumpActuatorTest.cs index da6de1a61d..a8080ab2e1 100644 --- a/src/Management/test/Endpoint.Test/Actuators/HeapDump/HeapDumpActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/HeapDump/HeapDumpActuatorTest.cs @@ -29,7 +29,6 @@ public async Task Registers_dependent_services() services.AddHeapDumpActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/HttpExchanges/HttpExchangesActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/HttpExchanges/HttpExchangesActuatorTest.cs index 476a670815..3b2ca41c24 100644 --- a/src/Management/test/Endpoint.Test/Actuators/HttpExchanges/HttpExchangesActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/HttpExchanges/HttpExchangesActuatorTest.cs @@ -33,7 +33,6 @@ public async Task Registers_dependent_services() services.AddHttpExchangesActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Hypermedia/HypermediaActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Hypermedia/HypermediaActuatorTest.cs index 7325d9b4b1..243f494b93 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Hypermedia/HypermediaActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Hypermedia/HypermediaActuatorTest.cs @@ -30,7 +30,6 @@ public async Task Registers_dependent_services() services.AddHypermediaActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs index 7d7756a273..5eb8ce37eb 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Info/InfoActuatorTest.cs @@ -50,7 +50,6 @@ public async Task Registers_dependent_services() services.AddInfoActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Loggers/LoggersActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Loggers/LoggersActuatorTest.cs index 0e28b20870..be018bc879 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Loggers/LoggersActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Loggers/LoggersActuatorTest.cs @@ -33,7 +33,6 @@ public async Task Registers_dependent_services() services.AddLoggersActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Refresh/HttpVerbInConventionalRoutingTest.cs b/src/Management/test/Endpoint.Test/Actuators/Refresh/HttpVerbInConventionalRoutingTest.cs index bb571357e7..fc3370d09b 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Refresh/HttpVerbInConventionalRoutingTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Refresh/HttpVerbInConventionalRoutingTest.cs @@ -255,7 +255,6 @@ public async Task ThrowsForCallback() builder.Services.AddMvc(options => options.EnableEndpointRouting = false); await using WebApplication host = builder.Build(); - // ReSharper disable once AccessToDisposedClosure Action action = () => host.UseActuatorEndpoints(configureEndpointsCallback); action.Should().ThrowExactly().WithMessage("Customizing endpoints is only supported when using endpoint routing."); diff --git a/src/Management/test/Endpoint.Test/Actuators/Refresh/RefreshActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Refresh/RefreshActuatorTest.cs index 7ede0f15bd..377765c18c 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Refresh/RefreshActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Refresh/RefreshActuatorTest.cs @@ -31,7 +31,6 @@ public async Task Registers_dependent_services() services.AddRefreshActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/RouteMappings/RouteMappingsActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/RouteMappings/RouteMappingsActuatorTest.cs index 6c63c31926..aaa52b889c 100644 --- a/src/Management/test/Endpoint.Test/Actuators/RouteMappings/RouteMappingsActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/RouteMappings/RouteMappingsActuatorTest.cs @@ -39,7 +39,6 @@ public async Task Registers_dependent_services() services.AddRouteMappingsActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/Services/ServicesActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/Services/ServicesActuatorTest.cs index 5dfae76140..7f0f22dce2 100644 --- a/src/Management/test/Endpoint.Test/Actuators/Services/ServicesActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/Services/ServicesActuatorTest.cs @@ -35,7 +35,6 @@ public async Task Registers_dependent_services() services.AddServicesActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/Actuators/ThreadDump/ThreadDumpActuatorTest.cs b/src/Management/test/Endpoint.Test/Actuators/ThreadDump/ThreadDumpActuatorTest.cs index a6887e2ad5..0d10ceba71 100644 --- a/src/Management/test/Endpoint.Test/Actuators/ThreadDump/ThreadDumpActuatorTest.cs +++ b/src/Management/test/Endpoint.Test/Actuators/ThreadDump/ThreadDumpActuatorTest.cs @@ -27,7 +27,6 @@ public async Task Registers_dependent_services() services.AddThreadDumpActuator(); await using ServiceProvider serviceProvider = services.BuildServiceProvider(true); - // ReSharper disable once AccessToDisposedClosure Action action = () => serviceProvider.GetRequiredService(); action.Should().NotThrow(); diff --git a/src/Management/test/Endpoint.Test/SpringBootAdminClient/HostBuilderTest.cs b/src/Management/test/Endpoint.Test/SpringBootAdminClient/HostBuilderTest.cs index 81dfc18dee..8d161276df 100644 --- a/src/Management/test/Endpoint.Test/SpringBootAdminClient/HostBuilderTest.cs +++ b/src/Management/test/Endpoint.Test/SpringBootAdminClient/HostBuilderTest.cs @@ -515,7 +515,6 @@ public async Task RecoversFromSpringBootAdminServerRestarts() bool isServerOnline = false; using var handler = new DelegateToMockHttpClientHandler(); - // ReSharper disable once AccessToModifiedClosure MockedRequest registerMock = handler.Mock.When(HttpMethod.Post, "http://sba-server.com/instances").Respond(_ => isServerOnline ? new HttpResponseMessage(HttpStatusCode.OK) { diff --git a/src/Management/test/Tasks.Test/TaskHostExtensionsTest.cs b/src/Management/test/Tasks.Test/TaskHostExtensionsTest.cs index 82bb71d688..278c99f366 100644 --- a/src/Management/test/Tasks.Test/TaskHostExtensionsTest.cs +++ b/src/Management/test/Tasks.Test/TaskHostExtensionsTest.cs @@ -199,7 +199,6 @@ public async Task WebApplication_LogsErrorOnUnknownTask() WebApplicationBuilder builder = TestWebApplicationBuilderFactory.Create(args); using var capturingLoggerProvider = new CapturingLoggerProvider(category => category.StartsWith("Steeltoe.", StringComparison.Ordinal)); - // ReSharper disable once AccessToDisposedClosure builder.Services.AddLogging(options => options.AddProvider(capturingLoggerProvider)); WebApplication app = builder.Build(); diff --git a/src/Steeltoe.All.sln.DotSettings b/src/Steeltoe.All.sln.DotSettings index 7e0a2d1fc4..aceff66495 100644 --- a/src/Steeltoe.All.sln.DotSettings +++ b/src/Steeltoe.All.sln.DotSettings @@ -600,7 +600,6 @@ UseVarWhenEvident False False - False Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the Apache 2.0 License. See the LICENSE file in the project root for more information.