Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CA1062 warning. Composite(Draft) #2176

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
48dad38
Preparation
Zombach Jul 4, 2024
0073c4d
part#1
Zombach Jul 4, 2024
aa35d32
part
Zombach Jul 4, 2024
6d9696d
part 2
Zombach Jul 4, 2024
2e1672d
fix test
Zombach Jul 5, 2024
6d527b7
fix test
Zombach Jul 5, 2024
0ce4c83
fix sa11028
Zombach Jul 5, 2024
3a30257
Merge pull request #1 from Zombach/zombach/remove-warning-ca1062-vali…
Zombach Jul 5, 2024
4842e91
Merge branch 'App-vNext:main' into zombach/remove-warning-ca1062-vali…
Zombach Jul 5, 2024
dd58bf0
fix test
Zombach Jul 5, 2024
467806c
fix test
Zombach Jul 5, 2024
f9de7bd
fix test
Zombach Jul 5, 2024
542f1f4
fix test
Zombach Jul 5, 2024
9ba403b
Add test
Zombach Jul 9, 2024
07dd8b0
fix conflict
Zombach Jul 9, 2024
08d7dff
Merge branch 'App-vNext:main' into zombach/remove-warning-ca1062-vali…
Zombach Jul 9, 2024
32f92a7
fix before conflict
Zombach Jul 9, 2024
05e1774
fix Tests
Zombach Jul 9, 2024
53d9da4
fix test
Zombach Jul 9, 2024
4175e27
fix test
Zombach Jul 9, 2024
45de0fd
upd tests
Zombach Jul 9, 2024
5cdbeb6
fix tests
Zombach Jul 10, 2024
d936445
Merge branch 'App-vNext:main' into zombach/remove-warning-ca1062-vali…
Zombach Jul 10, 2024
55fa740
is null
Zombach Jul 11, 2024
b2b09b6
Merge branch 'zombach/remove-warning-ca1062-validate-arguments-public…
Zombach Jul 11, 2024
3ba2e3e
Merge branch 'App-vNext:main' into zombach/remove-warning-ca1062-vali…
Zombach Jul 11, 2024
541a275
Merge branch 'App-vNext:main' into zombach/remove-warning-ca1062-vali…
Zombach Jul 12, 2024
8aaa745
Update test
Zombach Jul 12, 2024
4117a31
update test
Zombach Jul 12, 2024
fd79fda
update test
Zombach Jul 12, 2024
8716c88
Merge branch 'main' into zombach/remove-warning-ca1062-validate-argum…
Zombach Jul 13, 2024
7add285
remove space
Zombach Jul 15, 2024
ee4bb01
Add test
Zombach Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Polly/Bulkhead/AsyncBulkheadPolicy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#nullable enable

namespace Polly.Bulkhead;

#pragma warning disable CA1062 // Validate arguments of public methods // Temporary stub

/// <summary>
/// A bulkhead-isolation policy which can be applied to delegates.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Polly/Bulkhead/BulkheadPolicy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#nullable enable

namespace Polly.Bulkhead;

#pragma warning disable CA1062 // Validate arguments of public methods // Temporary stub

/// <summary>
/// A bulkhead-isolation policy which can be applied to delegates.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Polly/Caching/AsyncCachePolicy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#nullable enable
namespace Polly.Caching;

#pragma warning disable CA1062 // Validate arguments of public methods

/// <summary>
/// A cache policy that can be applied to the results of delegate executions.
/// </summary>
Expand Down Expand Up @@ -119,4 +121,3 @@ protected override Task<TResult> ImplementationAsync(Func<Context, CancellationT
_onCachePutError,
cancellationToken);
}

89 changes: 67 additions & 22 deletions src/Polly/Caching/AsyncCacheSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheProvider"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheKeyStrategy"/> is <see langword="null"/>.</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null) =>
CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError);
public static AsyncCachePolicy CacheAsync(
IAsyncCacheProvider cacheProvider,
TimeSpan ttl,
ICacheKeyStrategy cacheKeyStrategy,
Action<Context, string, Exception>? onCacheError = null)
{
if (cacheKeyStrategy is null)
{
throw new ArgumentNullException(nameof(cacheKeyStrategy));
}

return CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError);

Check warning on line 59 in src/Polly/Caching/AsyncCacheSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/Caching/AsyncCacheSyntax.cs#L59

Added line #L59 was not covered by tests
}

/// <summary>
/// <para>Builds an <see cref="AsyncPolicy" /> that will function like a result cache for delegate executions returning a result.</para>
Expand All @@ -62,26 +73,37 @@
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheProvider"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="ttlStrategy"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheKeyStrategy"/> is <see langword="null"/>.</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
public static AsyncCachePolicy CacheAsync(
IAsyncCacheProvider cacheProvider,
ITtlStrategy ttlStrategy,
ICacheKeyStrategy cacheKeyStrategy,
Action<Context, string, Exception>? onCacheError = null)
{
if (cacheProvider == null)
if (cacheProvider is null)
{
throw new ArgumentNullException(nameof(cacheProvider));
}

if (ttlStrategy == null)
if (ttlStrategy is null)
{
throw new ArgumentNullException(nameof(ttlStrategy));
}

if (cacheKeyStrategy == null)
if (cacheKeyStrategy is null)
{
throw new ArgumentNullException(nameof(cacheKeyStrategy));
}

Action<Context, string> emptyDelegate = (_, _) => { };

return new AsyncCachePolicy(cacheProvider, ttlStrategy, cacheKeyStrategy.GetCacheKey, emptyDelegate, emptyDelegate, emptyDelegate, onCacheError, onCacheError);
return new AsyncCachePolicy(
cacheProvider,
ttlStrategy,
cacheKeyStrategy.GetCacheKey,
emptyDelegate,
emptyDelegate,
emptyDelegate,
onCacheError, onCacheError);

Check warning on line 106 in src/Polly/Caching/AsyncCacheSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/Caching/AsyncCacheSyntax.cs#L99-L106

Added lines #L99 - L106 were not covered by tests
}

/// <summary>
Expand All @@ -97,7 +119,10 @@
/// <returns>The policy instance.</returns>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheProvider"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheKeyStrategy"/> is <see langword="null"/>.</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null) =>
public static AsyncCachePolicy CacheAsync(
IAsyncCacheProvider cacheProvider,
TimeSpan ttl, Func<Context, string> cacheKeyStrategy,
Action<Context, string, Exception>? onCacheError = null) =>
CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy, onCacheError);

/// <summary>
Expand All @@ -114,19 +139,23 @@
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheProvider"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="ttlStrategy"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="cacheKeyStrategy"/> is <see langword="null"/>.</exception>
public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception>? onCacheError = null)
public static AsyncCachePolicy CacheAsync(
IAsyncCacheProvider cacheProvider,
ITtlStrategy ttlStrategy,
Func<Context, string> cacheKeyStrategy,
Action<Context, string, Exception>? onCacheError = null)
{
if (cacheProvider == null)
if (cacheProvider is null)
{
throw new ArgumentNullException(nameof(cacheProvider));
}

if (ttlStrategy == null)
if (ttlStrategy is null)
{
throw new ArgumentNullException(nameof(ttlStrategy));
}

if (cacheKeyStrategy == null)
if (cacheKeyStrategy is null)
{
throw new ArgumentNullException(nameof(cacheKeyStrategy));
}
Expand Down Expand Up @@ -221,8 +250,16 @@
Action<Context, string> onCacheMiss,
Action<Context, string> onCachePut,
Action<Context, string, Exception>? onCacheGetError,
Action<Context, string, Exception>? onCachePutError) =>
CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError);
Action<Context, string, Exception>? onCachePutError)
{
if (cacheKeyStrategy is null)
{
throw new ArgumentNullException(nameof(cacheKeyStrategy));
}

return CacheAsync(cacheProvider, new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss,
onCachePut, onCacheGetError, onCachePutError);

Check warning on line 261 in src/Polly/Caching/AsyncCacheSyntax.cs

View check run for this annotation

Codecov / codecov/patch

src/Polly/Caching/AsyncCacheSyntax.cs#L260-L261

Added lines #L260 - L261 were not covered by tests
}

/// <summary>
/// <para>Builds an <see cref="AsyncPolicy" /> that will function like a result cache for delegate executions returning a result.</para>
Expand Down Expand Up @@ -253,8 +290,16 @@
Action<Context, string> onCacheMiss,
Action<Context, string> onCachePut,
Action<Context, string, Exception>? onCacheGetError,
Action<Context, string, Exception>? onCachePutError) =>
CacheAsync(cacheProvider, ttlStrategy, cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError);
Action<Context, string, Exception>? onCachePutError)
{
if (cacheKeyStrategy is null)
{
throw new ArgumentNullException(nameof(cacheKeyStrategy));
}

return CacheAsync(cacheProvider, ttlStrategy, cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut,
onCacheGetError, onCachePutError);
}

/// <summary>
/// <para>Builds an <see cref="AsyncPolicy" /> that will function like a result cache for delegate executions returning a result.</para>
Expand Down Expand Up @@ -318,32 +363,32 @@
Action<Context, string, Exception>? onCacheGetError,
Action<Context, string, Exception>? onCachePutError)
{
if (cacheProvider == null)
if (cacheProvider is null)
{
throw new ArgumentNullException(nameof(cacheProvider));
}

if (ttlStrategy == null)
if (ttlStrategy is null)
{
throw new ArgumentNullException(nameof(ttlStrategy));
}

if (cacheKeyStrategy == null)
if (cacheKeyStrategy is null)
{
throw new ArgumentNullException(nameof(cacheKeyStrategy));
}

if (onCacheGet == null)
if (onCacheGet is null)
{
throw new ArgumentNullException(nameof(onCacheGet));
}

if (onCacheMiss == null)
if (onCacheMiss is null)
{
throw new ArgumentNullException(nameof(onCacheMiss));
}

if (onCachePut == null)
if (onCachePut is null)
{
throw new ArgumentNullException(nameof(onCachePut));
}
Expand Down
Loading