Skip to content

Commit c6187fb

Browse files
committed
enable some nullables
1 parent 7e988d6 commit c6187fb

File tree

5 files changed

+49
-44
lines changed

5 files changed

+49
-44
lines changed

src/Polly/Caching/AsyncCacheSyntax.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
namespace Polly;
1+
#nullable enable
2+
namespace Polly;
23

34
public partial class Policy
45
{
@@ -13,7 +14,7 @@ public partial class Policy
1314
/// <param name="onCacheError">Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.</param>
1415
/// <returns>The policy instance.</returns>
1516
/// <exception cref="ArgumentNullException">cacheProvider</exception>
16-
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
17+
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception>? onCacheError = null)
1718
=> CacheAsync(cacheProvider, new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);
1819

1920
/// <summary>
@@ -28,7 +29,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim
2829
/// <returns>The policy instance.</returns>
2930
/// <exception cref="ArgumentNullException">cacheProvider</exception>
3031
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
31-
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
32+
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception>? onCacheError = null)
3233
=> CacheAsync(cacheProvider, ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);
3334

3435
/// <summary>
@@ -44,7 +45,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITt
4445
/// <returns>The policy instance.</returns>
4546
/// <exception cref="ArgumentNullException">cacheProvider</exception>
4647
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
47-
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
48+
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
4849
=> CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError);
4950

5051
/// <summary>
@@ -61,7 +62,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim
6162
/// <exception cref="ArgumentNullException">cacheProvider</exception>
6263
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
6364
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
64-
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
65+
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
6566
{
6667
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
6768
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));
@@ -86,7 +87,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITt
8687
/// <returns>The policy instance.</returns>
8788
/// <exception cref="ArgumentNullException">cacheProvider</exception>
8889
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
89-
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
90+
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
9091
=> CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy, onCacheError);
9192

9293
/// <summary>
@@ -103,7 +104,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim
103104
/// <exception cref="ArgumentNullException">cacheProvider</exception>
104105
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
105106
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
106-
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
107+
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
107108
{
108109
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
109110
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));

src/Polly/Caching/CacheSyntax.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
namespace Polly;
1+
#nullable enable
2+
namespace Polly;
23

34
public partial class Policy
45
{
@@ -13,7 +14,7 @@ public partial class Policy
1314
/// <param name="onCacheError">Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.</param>
1415
/// <returns>The policy instance.</returns>
1516
/// <exception cref="ArgumentNullException">cacheProvider</exception>
16-
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
17+
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception>? onCacheError = null)
1718
=> Cache(cacheProvider, new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);
1819

1920
/// <summary>
@@ -28,7 +29,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl,
2829
/// <returns>The policy instance.</returns>
2930
/// <exception cref="ArgumentNullException">cacheProvider</exception>
3031
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
31-
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
32+
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception>? onCacheError = null)
3233
=> Cache(cacheProvider, ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError);
3334

3435
/// <summary>
@@ -44,7 +45,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy t
4445
/// <returns>The policy instance.</returns>
4546
/// <exception cref="ArgumentNullException">cacheProvider</exception>
4647
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
47-
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
48+
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
4849
=> Cache(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError);
4950

5051
/// <summary>
@@ -61,7 +62,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl,
6162
/// <exception cref="ArgumentNullException">cacheProvider</exception>
6263
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
6364
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
64-
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
65+
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
6566
{
6667
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
6768
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));
@@ -86,7 +87,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy t
8687
/// <returns>The policy instance.</returns>
8788
/// <exception cref="ArgumentNullException">cacheProvider</exception>
8889
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
89-
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
90+
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
9091
=> Cache(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy, onCacheError);
9192

9293
/// <summary>
@@ -103,7 +104,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl,
103104
/// <exception cref="ArgumentNullException">cacheProvider</exception>
104105
/// <exception cref="ArgumentNullException">ttlStrategy</exception>
105106
/// <exception cref="ArgumentNullException">cacheKeyStrategy</exception>
106-
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
107+
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
107108
{
108109
if (cacheProvider == null) throw new ArgumentNullException(nameof(cacheProvider));
109110
if (ttlStrategy == null) throw new ArgumentNullException(nameof(ttlStrategy));

0 commit comments

Comments
 (0)