Skip to content

Commit

Permalink
Remove redundant branch
Browse files Browse the repository at this point in the history
- Remove redundant branch because when the key is null it uses the default key, which is what `CurrentValue` does anyway.
- Assert that the correct options instance is retrieved.
  • Loading branch information
martincostello committed Sep 18, 2024
1 parent bb45edf commit 47fe32c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ internal AddResiliencePipelineContext(ConfigureBuilderContext<TKey> registryCont
public TOptions GetOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TOptions>(string? name = null)
{
var monitor = ServiceProvider.GetRequiredService<IOptionsMonitor<TOptions>>();

return name == null ? monitor.CurrentValue : monitor.Get(name);
return monitor.Get(name);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public void AddResiliencePipeline_EnsureReloadable(string? name)

if (name == null)
{
services.Configure<ReloadableStrategyOptions>(configuration);
services.Configure<ReloadableStrategyOptions>(configuration)
.Configure<ReloadableStrategyOptions>(options => options.Name = name);
}
else
{
services.Configure<ReloadableStrategyOptions>(name, configuration);
services.Configure<ReloadableStrategyOptions>(name, configuration)
.Configure<ReloadableStrategyOptions>(name, options => options.Name = name);
}

services.Configure<TelemetryOptions>(options => options.TelemetryListeners.Add(fakeListener));
Expand All @@ -43,6 +45,7 @@ public void AddResiliencePipeline_EnsureReloadable(string? name)
var options = context.GetOptions<ReloadableStrategyOptions>(name);
options.Should().NotBeNull();
options.Name.Should().Be(name);
context.EnableReloads<ReloadableStrategyOptions>(name);
Expand Down Expand Up @@ -119,6 +122,8 @@ protected override ValueTask<Outcome<TResult>> ExecuteCore<TResult, TState>(
public class ReloadableStrategyOptions : ResilienceStrategyOptions
{
public string Tag { get; set; } = string.Empty;

public string? Name { get; set; }

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / windows-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / windows-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / windows-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / windows-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / windows-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / windows-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / macos-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check warning on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / build-docs

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check warning on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / build-docs

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check warning on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / build-docs

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check warning on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / build-docs

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.

Check failure on line 126 in test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

'ReloadableResiliencePipelineTests.ReloadableStrategyOptions.Name' hides inherited member 'ResilienceStrategyOptions.Name'. Use the new keyword if hiding was intended.
}

private class ReloadableConfiguration : ConfigurationProvider, IConfigurationSource
Expand Down

0 comments on commit 47fe32c

Please sign in to comment.