Skip to content

Commit

Permalink
Fix IDE1006
Browse files Browse the repository at this point in the history
Fix public API file

Remove breaking changes from PublicAPI.Shipped.txt

Move suppressions above summary comments

Remove S3872
  • Loading branch information
iamdmitrij committed May 16, 2024
1 parent 261129b commit fdcb37f
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 146 deletions.
4 changes: 2 additions & 2 deletions src/Polly/Caching/ContextualTtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ContextualTtl : ITtlStrategy
/// </summary>
public static readonly string SlidingExpirationKey = "ContextualTtlSliding";

private static readonly Ttl _noTtl = new(TimeSpan.Zero, false);
private static readonly Ttl NoTtl = new(TimeSpan.Zero, false);

/// <summary>
/// Gets the TimeSpan for which to keep an item about to be cached, which may be influenced by data in the execution context.
Expand All @@ -29,7 +29,7 @@ public Ttl GetTtl(Context context, object? result)
{
if (!context.ContainsKey(TimeSpanKey))
{
return _noTtl;
return NoTtl;
}

bool sliding = false;
Expand Down
2 changes: 2 additions & 0 deletions src/Polly/Caching/NonSlidingTtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ namespace Polly.Caching;
/// </summary>
public abstract class NonSlidingTtl : ITtlStrategy
{
#pragma warning disable IDE1006
/// <summary>
/// The absolute expiration time for cache items, represented by this strategy.
/// </summary>
protected readonly DateTimeOffset absoluteExpirationTime;
#pragma warning restore IDE1006

/// <summary>
/// Initializes a new instance of the <see cref="NonSlidingTtl"/> class.
Expand Down
6 changes: 3 additions & 3 deletions src/Polly/Caching/RelativeTtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Polly.Caching;
/// </summary>
public class RelativeTtl : ITtlStrategy
{
private readonly TimeSpan ttl;
private readonly TimeSpan _ttl;

/// <summary>
/// Initializes a new instance of the <see cref="RelativeTtl"/> class.
Expand All @@ -19,7 +19,7 @@ public RelativeTtl(TimeSpan ttl)
throw new ArgumentOutOfRangeException(nameof(ttl), "The ttl for items to cache must be greater than zero.");
}

this.ttl = ttl;
_ttl = ttl;
}

/// <summary>
Expand All @@ -28,5 +28,5 @@ public RelativeTtl(TimeSpan ttl)
/// <param name="context">The execution context.</param>
/// <param name="result">The execution result.</param>
/// <returns>A <see cref="Ttl"/> representing the remaining Ttl of the cached item.</returns>
public Ttl GetTtl(Context context, object? result) => new(ttl);
public Ttl GetTtl(Context context, object? result) => new(_ttl);
}
6 changes: 3 additions & 3 deletions src/Polly/Caching/SlidingTtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Polly.Caching;
/// </summary>
public class SlidingTtl : ITtlStrategy
{
private readonly Ttl ttl;
private readonly Ttl _ttl;

/// <summary>
/// Initializes a new instance of the <see cref="SlidingTtl"/> class.
Expand All @@ -19,7 +19,7 @@ public SlidingTtl(TimeSpan slidingTtl)
throw new ArgumentOutOfRangeException(nameof(slidingTtl), "The ttl for items to cache must be greater than zero.");
}

ttl = new Ttl(slidingTtl, true);
_ttl = new Ttl(slidingTtl, true);
}

/// <summary>
Expand All @@ -29,5 +29,5 @@ public SlidingTtl(TimeSpan slidingTtl)
/// <param name="result">The execution result.</param>
/// <returns>A <see cref="Ttl"/> representing the remaining Ttl of the cached item.</returns>
public Ttl GetTtl(Context context, object? result) =>
ttl;
_ttl;
}
12 changes: 6 additions & 6 deletions src/Polly/CircuitBreaker/AdvancedCircuitController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AdvancedCircuitController(

public override void OnCircuitReset(Context context)
{
using var _ = TimedLock.Lock(_lock);
using var _ = TimedLock.Lock(Lock);

// Is only null during initialization of the current class
// as the variable is not set, before the base class calls
Expand All @@ -41,9 +41,9 @@ public override void OnCircuitReset(Context context)

public override void OnActionSuccess(Context context)
{
using var _ = TimedLock.Lock(_lock);
using var _ = TimedLock.Lock(Lock);

switch (_circuitState)
switch (InternalCircuitState)
{
case CircuitState.HalfOpen:
OnCircuitReset(context);
Expand All @@ -65,11 +65,11 @@ public override void OnActionSuccess(Context context)

public override void OnActionFailure(DelegateResult<TResult> outcome, Context context)
{
using var _ = TimedLock.Lock(_lock);
using var _ = TimedLock.Lock(Lock);

_lastOutcome = outcome;
LastOutcome = outcome;

switch (_circuitState)
switch (InternalCircuitState)
{
case CircuitState.HalfOpen:
Break_NeedsLock(context);
Expand Down
30 changes: 15 additions & 15 deletions src/Polly/CircuitBreaker/AsyncCircuitBreakerPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
/// </summary>
public class AsyncCircuitBreakerPolicy : AsyncPolicy, ICircuitBreakerPolicy
{
internal readonly ICircuitController<EmptyStruct> _breakerController;
internal readonly ICircuitController<EmptyStruct> BreakerController;

internal AsyncCircuitBreakerPolicy(
PolicyBuilder policyBuilder,
ICircuitController<EmptyStruct> breakerController)
: base(policyBuilder) =>
_breakerController = breakerController;
BreakerController = breakerController;

/// <summary>
/// Gets the state of the underlying circuit.
/// </summary>
public CircuitState CircuitState => _breakerController.CircuitState;
public CircuitState CircuitState => BreakerController.CircuitState;

/// <summary>
/// Gets the last exception handled by the circuit-breaker.
/// <remarks>This will be null if no exceptions have been handled by the circuit-breaker since the circuit last closed.</remarks>
/// </summary>
public Exception LastException => _breakerController.LastException;
public Exception LastException => BreakerController.LastException;

/// <summary>
/// Isolates (opens) the circuit manually, and holds it in this state until a call to <see cref="Reset()"/> is made.
/// </summary>
public void Isolate() =>
_breakerController.Isolate();
BreakerController.Isolate();

/// <summary>
/// Closes the circuit, and resets any statistics controlling automated circuit-breaking.
/// </summary>
public void Reset() =>
_breakerController.Reset();
BreakerController.Reset();

/// <inheritdoc/>
protected override async Task<TResult> ImplementationAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken,
Expand All @@ -48,7 +48,7 @@ await AsyncCircuitBreakerEngine.ImplementationAsync<EmptyStruct>(
continueOnCapturedContext,
ExceptionPredicates,
ResultPredicates<EmptyStruct>.None,
_breakerController).ConfigureAwait(continueOnCapturedContext);
BreakerController).ConfigureAwait(continueOnCapturedContext);
return result;
}
}
Expand All @@ -59,42 +59,42 @@ await AsyncCircuitBreakerEngine.ImplementationAsync<EmptyStruct>(
/// <typeparam name="TResult">The return type of delegates which may be executed through the policy.</typeparam>
public class AsyncCircuitBreakerPolicy<TResult> : AsyncPolicy<TResult>, ICircuitBreakerPolicy<TResult>
{
internal readonly ICircuitController<TResult> _breakerController;
internal readonly ICircuitController<TResult> BreakerController;

internal AsyncCircuitBreakerPolicy(
PolicyBuilder<TResult> policyBuilder,
ICircuitController<TResult> breakerController)
: base(policyBuilder) =>
_breakerController = breakerController;
BreakerController = breakerController;

/// <summary>
/// Gets the state of the underlying circuit.
/// </summary>
public CircuitState CircuitState => _breakerController.CircuitState;
public CircuitState CircuitState => BreakerController.CircuitState;

/// <summary>
/// Gets the last exception handled by the circuit-breaker.
/// <remarks>This will be null if no exceptions have been handled by the circuit-breaker since the circuit last closed.</remarks>
/// </summary>
public Exception LastException => _breakerController.LastException;
public Exception LastException => BreakerController.LastException;

/// <summary>
/// Gets the last result returned from a user delegate which the circuit-breaker handled.
/// <remarks>This will be default(<typeparamref name="TResult"/>) if no results have been handled by the circuit-breaker since the circuit last closed, or if the last event handled by the circuit was an exception.</remarks>
/// </summary>
public TResult LastHandledResult => _breakerController.LastHandledResult;
public TResult LastHandledResult => BreakerController.LastHandledResult;

/// <summary>
/// Isolates (opens) the circuit manually, and holds it in this state until a call to <see cref="Reset()"/> is made.
/// </summary>
public void Isolate() =>
_breakerController.Isolate();
BreakerController.Isolate();

/// <summary>
/// Closes the circuit, and resets any statistics controlling automated circuit-breaking.
/// </summary>
public void Reset() =>
_breakerController.Reset();
BreakerController.Reset();

/// <inheritdoc/>
[DebuggerStepThrough]
Expand All @@ -107,5 +107,5 @@ protected override Task<TResult> ImplementationAsync(Func<Context, CancellationT
continueOnCapturedContext,
ExceptionPredicates,
ResultPredicates,
_breakerController);
BreakerController);
}
30 changes: 15 additions & 15 deletions src/Polly/CircuitBreaker/CircuitBreakerPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
/// </summary>
public class CircuitBreakerPolicy : Policy, ICircuitBreakerPolicy
{
internal readonly ICircuitController<EmptyStruct> _breakerController;
internal readonly ICircuitController<EmptyStruct> BreakerController;

internal CircuitBreakerPolicy(
PolicyBuilder policyBuilder,
ICircuitController<EmptyStruct> breakerController)
: base(policyBuilder) =>
_breakerController = breakerController;
BreakerController = breakerController;

/// <summary>
/// Gets the state of the underlying circuit.
/// </summary>
public CircuitState CircuitState => _breakerController.CircuitState;
public CircuitState CircuitState => BreakerController.CircuitState;

/// <summary>
/// Gets the last exception handled by the circuit-breaker.
/// <remarks>This will be null if no exceptions have been handled by the circuit-breaker since the circuit last closed.</remarks>
/// </summary>
public Exception LastException => _breakerController.LastException;
public Exception LastException => BreakerController.LastException;

/// <summary>
/// Isolates (opens) the circuit manually, and holds it in this state until a call to <see cref="Reset()"/> is made.
/// </summary>
public void Isolate() =>
_breakerController.Isolate();
BreakerController.Isolate();

/// <summary>
/// Closes the circuit, and resets any statistics controlling automated circuit-breaking.
/// </summary>
public void Reset() =>
_breakerController.Reset();
BreakerController.Reset();

/// <inheritdoc/>
[DebuggerStepThrough]
Expand All @@ -47,7 +47,7 @@ protected override TResult Implementation<TResult>(Func<Context, CancellationTok
cancellationToken,
ExceptionPredicates,
ResultPredicates<EmptyStruct>.None,
_breakerController);
BreakerController);
return result;
}
}
Expand All @@ -58,42 +58,42 @@ protected override TResult Implementation<TResult>(Func<Context, CancellationTok
/// <typeparam name="TResult">The type of the result.</typeparam>
public class CircuitBreakerPolicy<TResult> : Policy<TResult>, ICircuitBreakerPolicy<TResult>
{
internal readonly ICircuitController<TResult> _breakerController;
internal readonly ICircuitController<TResult> BreakerController;

internal CircuitBreakerPolicy(
PolicyBuilder<TResult> policyBuilder,
ICircuitController<TResult> breakerController)
: base(policyBuilder) =>
_breakerController = breakerController;
BreakerController = breakerController;

/// <summary>
/// Gets the state of the underlying circuit.
/// </summary>
public CircuitState CircuitState => _breakerController.CircuitState;
public CircuitState CircuitState => BreakerController.CircuitState;

/// <summary>
/// Gets the last exception handled by the circuit-breaker.
/// <remarks>This will be null if no exceptions have been handled by the circuit-breaker since the circuit last closed, or if the last event handled by the circuit was a handled <typeparamref name="TResult"/> value.</remarks>
/// </summary>
public Exception LastException => _breakerController.LastException;
public Exception LastException => BreakerController.LastException;

/// <summary>
/// Gets the last result returned from a user delegate which the circuit-breaker handled.
/// <remarks>This will be default(<typeparamref name="TResult"/>) if no results have been handled by the circuit-breaker since the circuit last closed, or if the last event handled by the circuit was an exception.</remarks>
/// </summary>
public TResult LastHandledResult => _breakerController.LastHandledResult;
public TResult LastHandledResult => BreakerController.LastHandledResult;

/// <summary>
/// Isolates (opens) the circuit manually, and holds it in this state until a call to <see cref="Reset()"/> is made.
/// </summary>
public void Isolate() =>
_breakerController.Isolate();
BreakerController.Isolate();

/// <summary>
/// Closes the circuit, and resets any statistics controlling automated circuit-breaking.
/// </summary>
public void Reset() =>
_breakerController.Reset();
BreakerController.Reset();

/// <inheritdoc/>
[DebuggerStepThrough]
Expand All @@ -104,5 +104,5 @@ protected override TResult Implementation(Func<Context, CancellationToken, TResu
cancellationToken,
ExceptionPredicates,
ResultPredicates,
_breakerController);
BreakerController);
}
Loading

0 comments on commit fdcb37f

Please sign in to comment.