Skip to content

Commit

Permalink
Seal some types as if dotnet_diagnostic.CA1852.severity = warning was…
Browse files Browse the repository at this point in the history
… in effect
  • Loading branch information
Henr1k80 committed Sep 17, 2024
1 parent 957444f commit 62e2773
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public async Task CloseAsync(CancellationToken cancellationToken = default)
}
}

private class RegistrationDisposable : IDisposable
private sealed class RegistrationDisposable : IDisposable
{
private readonly Action _disposeAction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ private async Task StartProcessingAsync()
}
}

private record Entry(Func<Task> TaskFactory, bool ContinueOnCapturedContext, TaskCompletionSource<object> TaskCompletion);
private sealed record Entry(Func<Task> TaskFactory, bool ContinueOnCapturedContext, TaskCompletionSource<object> TaskCompletion);
}
4 changes: 2 additions & 2 deletions src/Polly.Core/Registry/RegistryPipelineComponentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Polly.Registry;
/// <summary>
/// Builds a <see cref="PipelineComponent"/> used by the registry.
/// </summary>
internal class RegistryPipelineComponentBuilder<TBuilder, TKey>
internal sealed class RegistryPipelineComponentBuilder<TBuilder, TKey>
where TBuilder : ResiliencePipelineBuilderBase
where TKey : notnull
{
Expand Down Expand Up @@ -75,7 +75,7 @@ private Builder CreateBuilder()
builder);
}

private record Builder(
private sealed record Builder(
Func<PipelineComponent> ComponentFactory,
List<CancellationToken> ReloadTokens,
ResilienceStrategyTelemetry Telemetry,
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/Simmy/Fault/ChaosFaultStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Polly.Simmy.Fault;

internal class ChaosFaultStrategy : ChaosStrategy
internal sealed class ChaosFaultStrategy : ChaosStrategy
{
private readonly ResilienceStrategyTelemetry _telemetry;

Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/Simmy/Outcomes/ChaosOutcomeStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Polly.Simmy.Outcomes;

internal class ChaosOutcomeStrategy<T> : ChaosStrategy<T>
internal sealed class ChaosOutcomeStrategy<T> : ChaosStrategy<T>
{
private readonly ResilienceStrategyTelemetry _telemetry;
private readonly Func<OnOutcomeInjectedArguments<T>, ValueTask>? _onOutcomeInjected;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Utils.Pipeline;

internal class ComponentWithDisposeCallbacks : PipelineComponent
internal sealed class ComponentWithDisposeCallbacks : PipelineComponent
{
private readonly List<Action> _callbacks;

Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Core/Utils/Pipeline/ExternalComponent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Polly.Utils.Pipeline;

[DebuggerDisplay("{Component}")]
internal class ExternalComponent : PipelineComponent
internal sealed class ExternalComponent : PipelineComponent
{
public ExternalComponent(PipelineComponent component) => Component = component;

Expand Down
8 changes: 4 additions & 4 deletions src/Polly.Core/Utils/Pipeline/ReloadableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ private void DisposeRegistration()
_tokenSource.Dispose();
}

internal record ReloadFailedArguments(Exception Exception);
internal sealed record ReloadFailedArguments(Exception Exception);

internal record DisposedFailedArguments(Exception Exception);
internal sealed record DisposedFailedArguments(Exception Exception);

#pragma warning disable S2094 // Classes should not be empty
#pragma warning disable S3253 // Constructor and destructor declarations should not be redundant
internal record OnReloadArguments();
internal sealed record OnReloadArguments();
#pragma warning restore S3253 // Constructor and destructor declarations should not be redundant
#pragma warning restore S2094 // Classes should not be empty

internal record Entry(PipelineComponent Component, List<CancellationToken> ReloadTokens, ResilienceStrategyTelemetry Telemetry);
internal sealed record Entry(PipelineComponent Component, List<CancellationToken> ReloadTokens, ResilienceStrategyTelemetry Telemetry);
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private static void AddResiliencePipelineBuilder(this IServiceCollection service
});
}

private class RegistryMarker<TKey>
private sealed class RegistryMarker<TKey>
{
public static readonly ServiceDescriptor ServiceDescriptor = ServiceDescriptor.Singleton(new RegistryMarker<TKey>());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Polly.Extensions/Telemetry/ResilienceTelemetryTags.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.Telemetry;

internal class ResilienceTelemetryTags
internal static class ResilienceTelemetryTags
{
public const string EventName = "event.name";

Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Caching/AsyncGenericCacheProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Polly.Caching;
/// Provides a strongly-typed wrapper over a non-generic CacheProviderAsync.
/// </summary>
/// <typeparam name="TCacheFormat">The type of the objects in the cache.</typeparam>
internal class AsyncGenericCacheProvider<TCacheFormat> : IAsyncCacheProvider<TCacheFormat>
internal sealed class AsyncGenericCacheProvider<TCacheFormat> : IAsyncCacheProvider<TCacheFormat>
{
private readonly IAsyncCacheProvider _wrappedCacheProvider;

Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Caching/GenericCacheProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Polly.Caching;
/// Provides a strongly-typed wrapper over a non-generic CacheProvider.
/// </summary>
/// <typeparam name="TCacheFormat">The type of the objects in the cache.</typeparam>
internal class GenericCacheProvider<TCacheFormat> : ISyncCacheProvider<TCacheFormat>
internal sealed class GenericCacheProvider<TCacheFormat> : ISyncCacheProvider<TCacheFormat>
{
private readonly ISyncCacheProvider _wrappedCacheProvider;

Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Caching/GenericTtlStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Polly.Caching;
/// <summary>
/// Represents a strongly-typed <see cref="ITtlStrategy"/> wrapper of a non-generic strategy.
/// </summary>
internal class GenericTtlStrategy<TResult> : ITtlStrategy<TResult>
internal sealed class GenericTtlStrategy<TResult> : ITtlStrategy<TResult>
{
private readonly ITtlStrategy _wrappedTtlStrategy;

Expand Down
2 changes: 1 addition & 1 deletion src/Polly/CircuitBreaker/AdvancedCircuitController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.CircuitBreaker;

internal class AdvancedCircuitController<TResult> : CircuitStateController<TResult>
internal sealed class AdvancedCircuitController<TResult> : CircuitStateController<TResult>
{
private const short NumberOfWindows = 10;
internal static readonly long ResolutionOfCircuitTimer = TimeSpan.FromMilliseconds(20).Ticks;
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/CircuitBreaker/AsyncCircuitBreakerEngine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.CircuitBreaker;

internal class AsyncCircuitBreakerEngine
internal static class AsyncCircuitBreakerEngine
{
internal static async Task<TResult> ImplementationAsync<TResult>(
Func<Context, CancellationToken, Task<TResult>> action,
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/CircuitBreaker/CircuitBreakerEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Polly.CircuitBreaker;

internal class CircuitBreakerEngine
internal static class CircuitBreakerEngine
{
internal static TResult Implementation<TResult>(
Func<Context, CancellationToken, TResult> action,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.CircuitBreaker;

internal class ConsecutiveCountCircuitController<TResult> : CircuitStateController<TResult>
internal sealed class ConsecutiveCountCircuitController<TResult> : CircuitStateController<TResult>
{
private readonly int _exceptionsAllowedBeforeBreaking;
private int _consecutiveFailureCount;
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/CircuitBreaker/HealthCount.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Polly.CircuitBreaker;

internal class HealthCount
internal sealed class HealthCount
{
public int Successes { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/Polly/CircuitBreaker/RollingHealthMetrics.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#nullable enable
namespace Polly.CircuitBreaker;

internal class RollingHealthMetrics : IHealthMetrics
internal sealed class RollingHealthMetrics : IHealthMetrics
{
private readonly long _samplingDuration;
private readonly long _windowDuration;
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/CircuitBreaker/SingleHealthMetrics.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#nullable enable
namespace Polly.CircuitBreaker;

internal class SingleHealthMetrics : IHealthMetrics
internal sealed class SingleHealthMetrics : IHealthMetrics
{
private readonly long _samplingDuration;

Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Fallback/AsyncFallbackEngine.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#nullable enable
namespace Polly.Fallback;

internal class AsyncFallbackEngine
internal static class AsyncFallbackEngine
{
internal static async Task<TResult> ImplementationAsync<TResult>(
Func<Context, CancellationToken, Task<TResult>> action,
Expand Down
4 changes: 2 additions & 2 deletions src/Polly/Utilities/TimedLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void Dispose()
#if DEBUG
// (In Debug mode, we make it a class so that we can add a finalizer
// in order to detect when the object is not freed.)
private class Sentinel
private sealed class Sentinel
{
#if NETSTANDARD2_0
~Sentinel()
Expand All @@ -85,7 +85,7 @@ private class Sentinel
#endif
}

internal class LockTimeoutException : Exception
internal sealed class LockTimeoutException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="LockTimeoutException"/> class.
Expand Down

0 comments on commit 62e2773

Please sign in to comment.