Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/Common/src/Common/Discovery/IDiscoveryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IDiscoveryClient
/// <summary>
/// Occurs when service instances have been fetched from the discovery server.
/// </summary>
public event EventHandler<DiscoveryInstancesFetchedEventArgs> InstancesFetched;
event EventHandler<DiscoveryInstancesFetchedEventArgs> InstancesFetched;

/// <summary>
/// Gets information used to register the local service instance (this app) to the discovery server.
Expand Down
4 changes: 0 additions & 4 deletions src/Common/test/Hosting.Test/HostBuilderWrapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public async Task WebApplicationBuilder_Wraps()
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
wrapper.ConfigureServices(services => services.AddSingleton<InjectableType>());
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");
Expand Down Expand Up @@ -65,7 +64,6 @@ public void HostApplicationBuilder_Wraps()
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
wrapper.ConfigureServices(services => services.AddSingleton<InjectableType>());
wrapper.ConfigureAppConfiguration(configurationBuilder => configurationBuilder.AddInMemoryCollection(appSettings));
// ReSharper disable once AccessToDisposedClosure
wrapper.ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(capturingLoggerProvider));
wrapper.ConfigureServices((contextWrapper, _) => contextWrapper.HostEnvironment.ApplicationName = "TestApp");

Expand Down Expand Up @@ -100,7 +98,6 @@ public void WebHostBuilder_Wraps()
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
wrapper.ConfigureServices(services => services.AddSingleton<InjectableType>());
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");
Expand Down Expand Up @@ -138,7 +135,6 @@ public void GenericHostBuilder_Wraps()
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
wrapper.ConfigureServices(services => services.AddSingleton<InjectableType>());
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<ArgumentNullException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ public async Task Canceled_Throws()
using var source = new CancellationTokenSource();
await source.CancelAsync();

// ReSharper disable AccessToDisposedClosure
Func<Task> action = async () => await healthContributor.CheckHealthAsync(source.Token);
// ReSharper restore AccessToDisposedClosure

await action.Should().ThrowExactlyAsync<TaskCanceledException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public async Task Canceled_Throws()
using var source = new CancellationTokenSource();
await source.CancelAsync();

// ReSharper disable once AccessToDisposedClosure
Func<Task> action = async () => await healthContributor.CheckHealthAsync(source.Token);

await action.Should().ThrowExactlyAsync<OperationCanceledException>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ public async Task Canceled_Throws()
using var source = new CancellationTokenSource();
await source.CancelAsync();

// ReSharper disable AccessToDisposedClosure
Func<Task> action = async () => await healthContributor.CheckHealthAsync(source.Token);
// ReSharper restore AccessToDisposedClosure

await action.Should().ThrowExactlyAsync<OperationCanceledException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public async Task Canceled_Throws()
using var source = new CancellationTokenSource();
await source.CancelAsync();

// ReSharper disable AccessToDisposedClosure
Func<Task> action = async () => await healthContributor.CheckHealthAsync(source.Token);
// ReSharper restore AccessToDisposedClosure

await action.Should().ThrowExactlyAsync<OperationCanceledException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ public async Task Canceled_Throws()
using var source = new CancellationTokenSource();
await source.CancelAsync();

// ReSharper disable AccessToDisposedClosure
Func<Task> action = async () => await healthContributor.CheckHealthAsync(source.Token);
// ReSharper restore AccessToDisposedClosure

await action.Should().ThrowExactlyAsync<OperationCanceledException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GoodDbContext>();

action.Should().ThrowExactly<InvalidOperationException>().WithMessage("Server version must be specified when no connection string is provided.");
Expand Down
2 changes: 0 additions & 2 deletions src/Discovery/test/Consul.Test/Discovery/TtlSchedulerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public async Task Add_Throws_Invalid_InstanceId()
var optionsMonitor = new TestOptionsMonitor<ConsulDiscoveryOptions>();
await using var scheduler = new TtlScheduler(optionsMonitor, clientMoq.Object, NullLoggerFactory.Instance);

// ReSharper disable once AccessToDisposedClosure
Action action = () => scheduler.Add(string.Empty);

action.Should().ThrowExactly<ArgumentException>();
Expand Down Expand Up @@ -97,7 +96,6 @@ public async Task Remove_Throws_Invalid_InstanceId()
var optionsMonitor = new TestOptionsMonitor<ConsulDiscoveryOptions>();
await using var scheduler = new TtlScheduler(optionsMonitor, clientMoq.Object, NullLoggerFactory.Instance);

// ReSharper disable once AccessToDisposedClosure
Func<Task> action = async () => await scheduler.RemoveAsync(string.Empty);

await action.Should().ThrowExactlyAsync<ArgumentException>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public async Task SetStatusAsync_ThrowsInvalidStatus()

await using var registry = new ConsulServiceRegistry(clientMoq.Object, optionsMonitor, scheduler, NullLogger<ConsulServiceRegistry>.Instance);

// ReSharper disable once AccessToDisposedClosure
Func<Task> action = async () => await registry.SetStatusAsync(registration, string.Empty, TestContext.Current.CancellationToken);

await action.Should().ThrowExactlyAsync<ArgumentException>();
Expand Down
2 changes: 0 additions & 2 deletions src/Discovery/test/Eureka.Test/Transport/EurekaClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public async Task AddEurekaDiscoveryClient_HostApplicationBuilder_StartsUp()

using IHost host = hostBuilder.Build();

// ReSharper disable once AccessToDisposedClosure
Func<Task> action = async () => await host.StartAsync(TestContext.Current.CancellationToken);

await action.Should().NotThrowAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public async Task AddEurekaDiscoveryClient_WorksWithGlobalServiceDiscovery()

await using WebApplication host = builder.Build();

// ReSharper disable once AccessToDisposedClosure
Task<EurekaDiscoveryClient> resolveTask = Task.Run(() => _ = host.Services.GetServices<IDiscoveryClient>().OfType<EurekaDiscoveryClient>().Single());

Func<Task> action = async () => await resolveTask.WaitAsync(5.Seconds(), TestContext.Current.CancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Task> action = async () => _ = await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken);

await action.Should().ThrowExactlyAsync<DataException>();
Expand All @@ -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<Task> action = async () => _ = await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken);

await action.Should().ThrowExactlyAsync<HttpRequestException>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public async Task DoesNotTrackStatistics_WhenRequestIsCanceled()

using var invoker = new HttpMessageInvoker(handler);

// ReSharper disable once AccessToDisposedClosure
Func<Task> action = async () => await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken);

await action.Should().ThrowExactlyAsync<OperationCanceledException>();
Expand All @@ -80,7 +79,6 @@ public async Task DoesNotTrackStatistics_WhenResolutionFails_WithProvidedLoadBal

using var invoker = new HttpMessageInvoker(handler);

// ReSharper disable once AccessToDisposedClosure
Func<Task> action = async () => await invoker.SendAsync(httpRequestMessage, TestContext.Current.CancellationToken);

await action.Should().ThrowExactlyAsync<DataException>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -72,10 +71,8 @@ public async Task Registers_dependent_services(bool platformIsCloudFoundry)
{
Action action = () =>
{
// ReSharper disable AccessToDisposedClosure
_ = serviceProvider.GetRequiredService<CloudFoundryEndpointMiddleware>();
_ = serviceProvider.GetRequiredService<PermissionsProvider>();
// ReSharper restore AccessToDisposedClosure
};

action.Should().NotThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CloudFoundryEndpointMiddleware>();
middlewareAction.Should().NotThrow();

// ReSharper disable once AccessToDisposedClosure
Action providerAction = () => serviceProvider.GetRequiredService<PermissionsProvider>();
providerAction.Should().NotThrow();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvalidOperationException>().WithMessage("Please call IServiceCollection.AddCloudFoundryActuator first.");
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DbMigrationsEndpointMiddleware>();

action.Should().NotThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnvironmentEndpointMiddleware>();

action.Should().NotThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HealthEndpointMiddleware>();

action.Should().NotThrow();
Expand Down
Loading