Skip to content

Commit

Permalink
Make fields readonly (#1451)
Browse files Browse the repository at this point in the history
Added `readonly` modifier to private fields which are never changed.

---------

Co-authored-by: Lehonti Ramos <john@doe>
  • Loading branch information
Lehonti and Lehonti Ramos authored Aug 3, 2023
1 parent 3039291 commit 77e91d5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Polly/Caching/AsyncCachePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class AsyncCachePolicy<TResult> : AsyncPolicy<TResult>
private readonly Action<Context, string, Exception>? _onCacheGetError;
private readonly Action<Context, string, Exception>? _onCachePutError;

private IAsyncCacheProvider<TResult> _asyncCacheProvider;
private readonly IAsyncCacheProvider<TResult> _asyncCacheProvider;

internal AsyncCachePolicy(
IAsyncCacheProvider<TResult> asyncCacheProvider,
Expand Down
4 changes: 2 additions & 2 deletions src/Polly/Caching/CachePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public class CachePolicy<TResult> : Policy<TResult>, ICachePolicy<TResult>
private readonly Action<Context, string, Exception>? _onCacheGetError;
private readonly Action<Context, string, Exception>? _onCachePutError;

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

internal CachePolicy(
Expand Down
2 changes: 1 addition & 1 deletion src/Polly/Timeout/AsyncTimeoutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ protected override Task<TResult> ImplementationAsync<TResult>(
/// <typeparam name="TResult">The return type of delegates which may be executed through the policy.</typeparam>
public class AsyncTimeoutPolicy<TResult> : AsyncPolicy<TResult>, ITimeoutPolicy<TResult>
{
private readonly TimeoutStrategy _timeoutStrategy;
private Func<Context, TimeSpan> _timeoutProvider;
private TimeoutStrategy _timeoutStrategy;
private Func<Context, TimeSpan, Task, Exception, Task> _onTimeoutAsync;

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

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

internal TimeoutPolicy(
Expand Down
12 changes: 6 additions & 6 deletions src/Polly/Wrap/AsyncPolicyWrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// </summary>
public partial class AsyncPolicyWrap : AsyncPolicy, IPolicyWrap
{
private IAsyncPolicy _outer;
private IAsyncPolicy _inner;
private readonly IAsyncPolicy _outer;
private readonly IAsyncPolicy _inner;

/// <summary>
/// Returns the outer <see cref="IsPolicy"/> in this <see cref="IPolicyWrap"/>
Expand Down Expand Up @@ -61,11 +61,11 @@ 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 partial class AsyncPolicyWrap<TResult> : AsyncPolicy<TResult>, IPolicyWrap<TResult>
{
private IAsyncPolicy _outerNonGeneric;
private IAsyncPolicy _innerNonGeneric;
private readonly IAsyncPolicy _outerNonGeneric;
private readonly IAsyncPolicy _innerNonGeneric;

private IAsyncPolicy<TResult> _outerGeneric;
private IAsyncPolicy<TResult> _innerGeneric;
private readonly IAsyncPolicy<TResult> _outerGeneric;
private readonly IAsyncPolicy<TResult> _innerGeneric;

/// <summary>
/// Returns the outer <see cref="IsPolicy"/> in this <see cref="IPolicyWrap{TResult}"/>
Expand Down
12 changes: 6 additions & 6 deletions src/Polly/Wrap/PolicyWrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// </summary>
public partial class PolicyWrap : Policy, IPolicyWrap
{
private ISyncPolicy _outer;
private ISyncPolicy _inner;
private readonly ISyncPolicy _outer;
private readonly ISyncPolicy _inner;

/// <summary>
/// Returns the outer <see cref="IsPolicy"/> in this <see cref="IPolicyWrap"/>
Expand Down Expand Up @@ -54,11 +54,11 @@ protected override TResult Implementation<TResult>(Func<Context, CancellationTok
/// <typeparam name="TResult">The return type of delegates which may be executed through the policy.</typeparam>
public partial class PolicyWrap<TResult> : Policy<TResult>, IPolicyWrap<TResult>
{
private ISyncPolicy _outerNonGeneric;
private ISyncPolicy _innerNonGeneric;
private readonly ISyncPolicy _outerNonGeneric;
private readonly ISyncPolicy _innerNonGeneric;

private ISyncPolicy<TResult> _outerGeneric;
private ISyncPolicy<TResult> _innerGeneric;
private readonly ISyncPolicy<TResult> _outerGeneric;
private readonly ISyncPolicy<TResult> _innerGeneric;

/// <summary>
/// Returns the outer <see cref="IsPolicy"/> in this <see cref="IPolicyWrap{TResult}"/>
Expand Down

0 comments on commit 77e91d5

Please sign in to comment.