Skip to content

Commit ed3d603

Browse files
Formatting tweaks (#3018)
- Add trailing commas. - Use primary constructors. - Use `is` instead of `==`. - Simplify some pattern matching.
1 parent 8fd8fc0 commit ed3d603

14 files changed

Lines changed: 38 additions & 51 deletions

bench/Polly.Core.Benchmarks/PredicateBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class PredicateBenchmark
1919
{ Exception: IOException } => PredicateResult.True(),
2020
{ Exception: InvalidOperationException } => PredicateResult.False(),
2121
_ => PredicateResult.False(),
22-
}
22+
},
2323
};
2424

2525
private readonly RetryStrategyOptions<HttpResponseMessage> _builder = new()

bench/Polly.Core.Benchmarks/Utils/Helper.CircuitBreaker.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public static object CreateCircuitBreaker(PollyVersion technology)
5656
{
5757
{ Exception: InvalidOperationException } => PredicateResult.True(),
5858
{ Result: string result } when result == Failure => PredicateResult.True(),
59-
_ => PredicateResult.False()
60-
}
59+
_ => PredicateResult.False(),
60+
},
6161
});
6262
}),
6363
_ => throw new NotSupportedException()
@@ -81,5 +81,4 @@ protected internal override async ValueTask<Outcome<TResult>> ExecuteCore<TResul
8181
return result;
8282
}
8383
}
84-
8584
}

bench/Polly.Core.Benchmarks/Utils/Helper.MultipleStrategies.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static partial class Helper
1919
.AddConcurrencyLimiter(new ConcurrencyLimiterOptions
2020
{
2121
QueueLimit = 10,
22-
PermitLimit = 10
22+
PermitLimit = 10,
2323
})
2424
.AddTimeout(TimeSpan.FromSeconds(10))
2525
.AddRetry(new()
@@ -31,8 +31,8 @@ internal static partial class Helper
3131
{
3232
{ Exception: InvalidOperationException } => PredicateResult.True(),
3333
{ Result: string result } when result == Failure => PredicateResult.True(),
34-
_ => PredicateResult.False()
35-
}
34+
_ => PredicateResult.False(),
35+
},
3636
})
3737
.AddTimeout(TimeSpan.FromSeconds(1))
3838
.AddCircuitBreaker(new()
@@ -45,8 +45,8 @@ internal static partial class Helper
4545
{
4646
{ Exception: InvalidOperationException } => PredicateResult.True(),
4747
{ Result: string result } when result == Failure => PredicateResult.True(),
48-
_ => PredicateResult.False()
49-
}
48+
_ => PredicateResult.False(),
49+
},
5050
});
5151

5252
if (telemetry)
@@ -63,7 +63,7 @@ public static ResiliencePipeline CreateNonGenericStrategyPipeline(bool telemetry
6363
.AddConcurrencyLimiter(new ConcurrencyLimiterOptions
6464
{
6565
QueueLimit = 10,
66-
PermitLimit = 10
66+
PermitLimit = 10,
6767
})
6868
.AddTimeout(TimeSpan.FromSeconds(10))
6969
.AddRetry(new()
@@ -75,7 +75,7 @@ public static ResiliencePipeline CreateNonGenericStrategyPipeline(bool telemetry
7575
{
7676
{ Exception: InvalidOperationException } => PredicateResult.True(),
7777
{ Result: string result } when result == Failure => PredicateResult.True(),
78-
_ => PredicateResult.False()
78+
_ => PredicateResult.False(),
7979
}
8080
})
8181
.AddTimeout(TimeSpan.FromSeconds(1))
@@ -89,8 +89,8 @@ public static ResiliencePipeline CreateNonGenericStrategyPipeline(bool telemetry
8989
{
9090
{ Exception: InvalidOperationException } => PredicateResult.True(),
9191
{ Result: string result } when result == Failure => PredicateResult.True(),
92-
_ => PredicateResult.False()
93-
}
92+
_ => PredicateResult.False(),
93+
},
9494
});
9595

9696
if (telemetry)

bench/Polly.Core.Benchmarks/Utils/Helper.Retry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public static object CreateRetry(PollyVersion technology)
2525
{
2626
{ Exception: InvalidOperationException } => PredicateResult.True(),
2727
{ Result: string result } when result == Failure => PredicateResult.True(),
28-
_ => PredicateResult.False()
28+
_ => PredicateResult.False(),
2929
},
30-
OnRetry = _ => default
30+
OnRetry = _ => default,
3131
});
3232
}),
33-
_ => throw new NotSupportedException()
33+
_ => throw new NotSupportedException(),
3434
};
3535
}
3636
}

src/Polly.Core/Utils/Pipeline/BridgeComponentBase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
namespace Polly.Utils.Pipeline;
22

3-
internal abstract class BridgeComponentBase : PipelineComponent
3+
internal abstract class BridgeComponentBase(object strategy) : PipelineComponent
44
{
5-
private readonly object _strategy;
6-
7-
protected BridgeComponentBase(object strategy) => _strategy = strategy;
5+
private readonly object _strategy = strategy;
86

97
public override ValueTask DisposeAsync()
108
{

src/Snippets/Docs/Chaos.Outcome.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void OutcomeUsage()
5454
ShouldHandle = static args => args.Outcome switch
5555
{
5656
{ Result.StatusCode: HttpStatusCode.InternalServerError } => PredicateResult.True(),
57-
_ => PredicateResult.False()
57+
_ => PredicateResult.False(),
5858
},
5959
BackoffType = DelayBackoffType.Exponential,
6060
UseJitter = true,

src/Snippets/Docs/Extensibility.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public static void DelegateUsage()
1515
ShouldHandle = args => args.Outcome switch
1616
{
1717
{ Exception: InvalidOperationException } => PredicateResult.True(),
18-
{ Result: string result } when result == "Failure" => PredicateResult.True(),
19-
{ Result: int result } when result == -1 => PredicateResult.True(),
20-
_ => PredicateResult.False()
18+
{ Result: string result } when result is "Failure" => PredicateResult.True(),
19+
{ Result: int result } when result is -1 => PredicateResult.True(),
20+
_ => PredicateResult.False(),
2121
},
2222
})
2323
.Build();
@@ -30,11 +30,11 @@ public static void DelegateUsage()
3030
{
3131
{ Exception: InvalidOperationException } => PredicateResult.True(),
3232
{ Result: { } result } when result == "Failure" => PredicateResult.True(),
33-
_ => PredicateResult.False()
33+
_ => PredicateResult.False(),
3434
},
3535
})
3636
.Build();
3737

38-
#endregion;
38+
#endregion
3939
}
4040
}

src/Snippets/Docs/HttpClientIntegrations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static class HttpClientIntegrations
1919
{ Exception: HttpRequestException } => PredicateResult.True(),
2020
{ Result.StatusCode: HttpStatusCode.RequestTimeout } => PredicateResult.True(),
2121
{ Result.StatusCode: >= HttpStatusCode.InternalServerError } => PredicateResult.True(),
22-
_ => PredicateResult.False()
22+
_ => PredicateResult.False(),
2323
};
2424

2525
private static RetryStrategyOptions<HttpResponseMessage> GetRetryOptions() =>

src/Snippets/Docs/Migration.Retry.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ public static void Retry_V8()
183183
ShouldHandle = static args => args.Outcome switch
184184
{
185185
{ Exception: SomeExceptionType } => PredicateResult.True(),
186-
{ Result: { StatusCode: HttpStatusCode.InternalServerError } } => PredicateResult.True(),
187-
_ => PredicateResult.False()
186+
{ Result.StatusCode: HttpStatusCode.InternalServerError } => PredicateResult.True(),
187+
_ => PredicateResult.False(),
188188
},
189189
MaxRetryAttempts = 3,
190190
})

src/Snippets/Docs/ResilienceStrategies.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void ShouldHandleManual()
3232
{ Exception: HttpRequestException } => PredicateResult.True(),
3333
{ Exception: TimeoutRejectedException } => PredicateResult.True(), // You can handle multiple exceptions
3434
{ Result: HttpResponseMessage response } when !response.IsSuccessStatusCode => PredicateResult.True(),
35-
_ => PredicateResult.False()
35+
_ => PredicateResult.False(),
3636
}
3737
};
3838

0 commit comments

Comments
 (0)