Skip to content
Merged
Changes from all commits
Commits
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
17 changes: 7 additions & 10 deletions Shared.Results/PolicyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
{
private enum LogType { Retry, Final }

public static readonly EventHandler<String> Log;

Check warning on line 13 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

Non-nullable field 'Log' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 13 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

Non-nullable field 'Log' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 13 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

Non-nullable field 'Log' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 13 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

Non-nullable field 'Log' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

public static IAsyncPolicy<T> CreatePolicy<T>(int retryCount = 5, TimeSpan? retryDelay = null, string policyTag = "",
Func<T, Boolean>? shouldRetry = null,
Func<Exception, bool> shouldRetryException = null) where T : ResultBase

Check warning on line 17 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

Cannot convert null literal to non-nullable reference type.

Check warning on line 17 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Windows

Cannot convert null literal to non-nullable reference type.

Check warning on line 17 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

Cannot convert null literal to non-nullable reference type.

Check warning on line 17 in Shared.Results/PolicyFactory.cs

View workflow job for this annotation

GitHub Actions / Build and Test Pull Requests - Linux

Cannot convert null literal to non-nullable reference type.
{
Func<T, Boolean> retryCondition = shouldRetry ?? (ShouldRetry);
Func<Exception, Boolean> retryExceptionCondition = shouldRetryException ?? (ShouldRetryException);
Expand Down Expand Up @@ -89,16 +89,13 @@

string message = FormatResultMessage(result);

switch (type)
String logMessage = type switch
{
case LogType.Retry:
Log(null, ($"{policyTag} - Retry {retryCount} due to error: {message}. Waiting before retrying..."));
break;

case LogType.Final:
string retryMessage = retryCount > 0 ? $" after {retryCount} retries." : "";
Log(null, ($"{policyTag} - {message}{retryMessage}"));
break;
}
LogType.Retry => $"{policyTag} - Retry {retryCount} due to error: {message}. Waiting before retrying...",
LogType.Final => $"{policyTag} - {message}{(retryCount > 0 ? $" after {retryCount} retries." : "")}",
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
};

Log(null, logMessage);
}
}
Loading