Skip to content

Commit

Permalink
Fix IDE0044 warnings (App-vNext#1928)
Browse files Browse the repository at this point in the history
Co-authored-by: Baranyai Máté <[email protected]>
  • Loading branch information
baranyaimate and Baranyai Máté authored Jan 26, 2024
1 parent 0e134b5 commit 6bb905f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/Polly/Bulkhead/AsyncBulkheadPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AsyncBulkheadPolicy : AsyncPolicy, IBulkheadPolicy
private readonly SemaphoreSlim _maxParallelizationSemaphore;
private readonly SemaphoreSlim _maxQueuedActionsSemaphore;
private readonly int _maxQueueingActions;
private Func<Context, Task> _onBulkheadRejectedAsync;
private readonly Func<Context, Task> _onBulkheadRejectedAsync;

internal AsyncBulkheadPolicy(
int maxParallelization,
Expand Down Expand Up @@ -55,7 +55,7 @@ public class AsyncBulkheadPolicy<TResult> : AsyncPolicy<TResult>, IBulkheadPolic
private readonly SemaphoreSlim _maxParallelizationSemaphore;
private readonly SemaphoreSlim _maxQueuedActionsSemaphore;
private readonly int _maxQueueingActions;
private Func<Context, Task> _onBulkheadRejectedAsync;
private readonly Func<Context, Task> _onBulkheadRejectedAsync;

internal AsyncBulkheadPolicy(
int maxParallelization,
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Caching/CachePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class CachePolicy<TResult> : Policy<TResult>, ICachePolicy<TResult>

private readonly ISyncCacheProvider<TResult> _syncCacheProvider;
private readonly ITtlStrategy<TResult> _ttlStrategy;
private Func<Context, string> _cacheKeyStrategy;
private readonly Func<Context, string> _cacheKeyStrategy;

internal CachePolicy(
ISyncCacheProvider<TResult> syncCacheProvider,
Expand Down
8 changes: 4 additions & 4 deletions src/Polly/Fallback/AsyncFallbackPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Polly.Fallback;
/// </summary>
public class AsyncFallbackPolicy : AsyncPolicy, IFallbackPolicy
{
private Func<Exception, Context, Task> _onFallbackAsync;
private Func<Exception, Context, CancellationToken, Task> _fallbackAction;
private readonly Func<Exception, Context, Task> _onFallbackAsync;
private readonly Func<Exception, Context, CancellationToken, Task> _fallbackAction;

internal AsyncFallbackPolicy(PolicyBuilder policyBuilder, Func<Exception, Context, Task> onFallbackAsync,
Func<Exception, Context, CancellationToken, Task> fallbackAction)
Expand Down Expand Up @@ -54,8 +54,8 @@ protected override Task<TResult> ImplementationAsync<TResult>(Func<Context, Canc
/// <typeparam name="TResult">The return type of delegates which may be executed through the policy.</typeparam>
public class AsyncFallbackPolicy<TResult> : AsyncPolicy<TResult>, IFallbackPolicy<TResult>
{
private Func<DelegateResult<TResult>, Context, Task> _onFallbackAsync;
private Func<DelegateResult<TResult>, Context, CancellationToken, Task<TResult>> _fallbackAction;
private readonly Func<DelegateResult<TResult>, Context, Task> _onFallbackAsync;
private readonly Func<DelegateResult<TResult>, Context, CancellationToken, Task<TResult>> _fallbackAction;

internal AsyncFallbackPolicy(
PolicyBuilder<TResult> policyBuilder,
Expand Down
8 changes: 4 additions & 4 deletions src/Polly/Fallback/FallbackPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Polly.Fallback;
/// </summary>
public class FallbackPolicy : Policy, IFallbackPolicy
{
private Action<Exception, Context> _onFallback;
private Action<Exception, Context, CancellationToken> _fallbackAction;
private readonly Action<Exception, Context> _onFallback;
private readonly Action<Exception, Context, CancellationToken> _fallbackAction;

internal FallbackPolicy(
PolicyBuilder policyBuilder,
Expand Down Expand Up @@ -50,8 +50,8 @@ protected override TResult Implementation<TResult>(Func<Context, CancellationTok
/// </summary>
public class FallbackPolicy<TResult> : Policy<TResult>, IFallbackPolicy<TResult>
{
private Action<DelegateResult<TResult>, Context> _onFallback;
private Func<DelegateResult<TResult>, Context, CancellationToken, TResult> _fallbackAction;
private readonly Action<DelegateResult<TResult>, Context> _onFallback;
private readonly Func<DelegateResult<TResult>, Context, CancellationToken, TResult> _fallbackAction;

internal FallbackPolicy(
PolicyBuilder<TResult> policyBuilder,
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Polly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<MutationScore>70</MutationScore>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);IDE0011;SA1501;S103;IDE0055;SA1111;IDE0066;S3872;SA1127;SA1128;SA1402;SA1513;SA1414;S3215;S2955</NoWarn>
<NoWarn>$(NoWarn);IDE0044;IDE1006;CA1062;S107;CA1068;S4039;SA1121;CA1000;CA1063;SA1113;CA1031;CA1051;CA1200</NoWarn>
<NoWarn>$(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;SA1121;CA1000;CA1063;SA1113;CA1031;CA1051;CA1200</NoWarn>
<NoWarn>$(NoWarn);SA1629;SA1612;CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;IDE0250;S109;SA1618;SA1407;CA1033</NoWarn>
<NoWarn>$(NoWarn);SA1515;S4023;CA1010;IDE0063;S2681;S3442;S3880;CA1064;SA1110;SA1203;SA1649;SA1625;SA1623;SA1118</NoWarn>
<NoWarn>$(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246</NoWarn>
Expand Down
4 changes: 2 additions & 2 deletions src/Polly/Timeout/AsyncTimeoutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ protected override Task<TResult> ImplementationAsync<TResult>(
public class AsyncTimeoutPolicy<TResult> : AsyncPolicy<TResult>, ITimeoutPolicy<TResult>
{
private readonly TimeoutStrategy _timeoutStrategy;
private Func<Context, TimeSpan> _timeoutProvider;
private Func<Context, TimeSpan, Task, Exception, Task> _onTimeoutAsync;
private readonly Func<Context, TimeSpan> _timeoutProvider;
private readonly Func<Context, TimeSpan, Task, Exception, Task> _onTimeoutAsync;

internal AsyncTimeoutPolicy(
Func<Context, TimeSpan> timeoutProvider,
Expand Down
8 changes: 4 additions & 4 deletions src/Polly/Timeout/TimeoutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
public class TimeoutPolicy : Policy, ITimeoutPolicy
{
private readonly TimeoutStrategy _timeoutStrategy;
private Func<Context, TimeSpan> _timeoutProvider;
private Action<Context, TimeSpan, Task, Exception> _onTimeout;
private readonly Func<Context, TimeSpan> _timeoutProvider;
private readonly Action<Context, TimeSpan, Task, Exception> _onTimeout;

internal TimeoutPolicy(
Func<Context, TimeSpan> timeoutProvider,
Expand Down Expand Up @@ -37,8 +37,8 @@ protected override TResult Implementation<TResult>(Func<Context, CancellationTok
public class TimeoutPolicy<TResult> : Policy<TResult>, ITimeoutPolicy<TResult>
{
private readonly TimeoutStrategy _timeoutStrategy;
private Func<Context, TimeSpan> _timeoutProvider;
private Action<Context, TimeSpan, Task, Exception> _onTimeout;
private readonly Func<Context, TimeSpan> _timeoutProvider;
private readonly Action<Context, TimeSpan, Task, Exception> _onTimeout;

internal TimeoutPolicy(
Func<Context, TimeSpan> timeoutProvider,
Expand Down
16 changes: 8 additions & 8 deletions src/Polly/Utilities/TimedLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static TimedLock Lock(object o, TimeSpan timeout)
if (!Monitor.TryEnter(o, timeout))
{
#if DEBUG
GC.SuppressFinalize(tl.leakDetector);
GC.SuppressFinalize(tl._leakDetector);
#endif
throw new LockTimeoutException();
}
Expand All @@ -42,24 +42,24 @@ private static TimedLock Lock(object o, TimeSpan timeout)
#if DEBUG
private TimedLock(object o)
{
target = o;
leakDetector = new Sentinel();
_target = o;
_leakDetector = new Sentinel();
}
#else
private TimedLock(object o) => target = o;
private TimedLock(object o) => _target = o;
#endif
private object target;
private readonly object _target;

public void Dispose()
{
Monitor.Exit(target);
Monitor.Exit(_target);

// It's a bad error if someone forgets to call Dispose,
// so in Debug builds, we put a finalizer in to detect
// the error. If Dispose is called, we suppress the
// finalizer.
#if DEBUG
GC.SuppressFinalize(leakDetector);
GC.SuppressFinalize(_leakDetector);
#endif
}

Expand All @@ -78,7 +78,7 @@ private class Sentinel
#endif
}
}
private Sentinel leakDetector;
private readonly Sentinel _leakDetector;
#endif
}

Expand Down

0 comments on commit 6bb905f

Please sign in to comment.