Skip to content

Commit

Permalink
Make DebuggerStepThrough attributes consistent
Browse files Browse the repository at this point in the history
... and add missing intellisense
reisenberger committed Jan 31, 2018

Verified

This commit was signed with the committer’s verified signature.
Byron Sebastian Thiel
1 parent 5ea7541 commit 919e371
Showing 6 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Polly.Shared/Caching/CachePolicy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Polly.Utilities;
@@ -51,6 +52,7 @@ internal CachePolicy(
/// <param name="context">Execution context that is passed to the exception policy; defines the cache key to use in cache lookup.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The value returned by the action, or the cache.</returns>
[DebuggerStepThrough]
public override TResult ExecuteInternal<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
{
return CacheEngine.Implementation<TResult>(
2 changes: 2 additions & 0 deletions src/Polly.Shared/Caching/CachePolicyAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -43,6 +44,7 @@ internal CachePolicy(
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="continueOnCapturedContext">Whether to continue on a captured synchronization context.</param>
/// <returns>The value returned by the action, or the cache.</returns>
[DebuggerStepThrough]
public override Task<TResult> ExecuteAsyncInternal<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
{
return CacheEngine.ImplementationAsync<TResult>(
2 changes: 2 additions & 0 deletions src/Polly.Shared/Fallback/FallbackPolicy.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;

namespace Polly.Fallback
@@ -22,6 +23,7 @@ internal FallbackPolicy(Action<Action<Context, CancellationToken>, Context, Canc
/// <param name="context">Execution context that is passed to the exception policy; defines the cache key to use in cache lookup.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The value returned by the action, or the cache.</returns>
[DebuggerStepThrough]
public override TResult ExecuteInternal<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
{
throw new InvalidOperationException($"You have executed the generic .Execute<{nameof(TResult)}> method on a non-generic {nameof(FallbackPolicy)}. A non-generic {nameof(FallbackPolicy)} only defines a fallback action which returns void; it can never return a substitute {nameof(TResult)} value. To use {nameof(FallbackPolicy)} to provide fallback {nameof(TResult)} values you must define a generic fallback policy {nameof(FallbackPolicy)}<{nameof(TResult)}>. For example, define the policy as Policy<{nameof(TResult)}>.Handle<Whatever>.Fallback<{nameof(TResult)}>(/* some {nameof(TResult)} value or Func<..., {nameof(TResult)}> */);");
2 changes: 1 addition & 1 deletion src/Polly.Shared/Policy.cs
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ public void Execute(Action<Context> action, Context context)
}

/// <summary>
///
/// Executes the specified action within the policy
/// </summary>
/// <param name="action"></param>
/// <param name="cancellationToken"></param>
2 changes: 2 additions & 0 deletions src/Polly.Shared/Wrap/PolicyWrap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading;
using Polly.Utilities;

@@ -37,6 +38,7 @@ internal PolicyWrap(Action<Action<Context, CancellationToken>, Context, Cancella
/// <param name="context">Execution context that is passed to the exception policy; defines the cache key to use in cache lookup.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The value returned by the action, or the cache.</returns>
[DebuggerStepThrough]
public override TResult ExecuteInternal<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
{
return PolicyWrapEngine.Implementation<TResult>(
2 changes: 2 additions & 0 deletions src/Polly.Shared/Wrap/PolicyWrapAsync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Polly.Utilities;
@@ -23,6 +24,7 @@ internal PolicyWrap(Func<Func<Context, CancellationToken, Task>, Context, Cancel
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="continueOnCapturedContext">Whether to continue on a captured synchronization context.</param>
/// <returns>The value returned by the action, or the cache.</returns>
[DebuggerStepThrough]
public override Task<TResult> ExecuteAsyncInternal<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
{
return PolicyWrapEngine.ImplementationAsync<TResult>(

0 comments on commit 919e371

Please sign in to comment.