File tree Expand file tree Collapse file tree 3 files changed +23
-13
lines changed
src/AsyncAwaitBestPractices.UnitTests Expand file tree Collapse file tree 3 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 3838 </ItemGroup >
3939
4040 <ItemGroup >
41- <PackageReference Include =" Microsoft.Extensions.Http.Polly " Version =" 8.0 .0" />
41+ <PackageReference Include =" Microsoft.Extensions.Http.Resilience " Version =" 8.4 .0" />
4242 <PackageReference Include =" Refit.HttpClientFactory" Version =" 7.0.0" />
4343 <PackageReference Include =" CommunityToolkit.Maui.Markup" Version =" 4.0.0" />
4444 <PackageReference Include =" CommunityToolkit.Mvvm" Version =" 8.2.2" />
45- <PackageReference Include =" CommunityToolkit.Maui" Version =" 7.0.0" />
46- <PackageReference Include =" Microsoft.Maui.Controls" Version =" 8.0.3" />
45+ <PackageReference Include =" CommunityToolkit.Maui" Version =" 8.0.1" />
46+ <PackageReference Include =" Microsoft.Maui.Controls" Version =" 8.0.20" />
47+ <PackageReference Include =" Microsoft.Maui.Controls.Compatibility" Version =" 8.0.20" />
4748 </ItemGroup >
4849
4950 <ItemGroup >
Original file line number Diff line number Diff line change 11using CommunityToolkit . Maui ;
22using CommunityToolkit . Maui . Markup ;
3+ using Microsoft . Extensions . Http . Resilience ;
34using Polly ;
45using Refit ;
56
67[ assembly: XamlCompilation ( XamlCompilationOptions . Compile ) ]
78namespace HackerNews ;
89
9- public class MauiProgram
10+ public static class MauiProgram
1011{
1112 public static MauiApp CreateMauiApp ( )
1213 {
@@ -32,14 +33,22 @@ public static MauiApp CreateMauiApp()
3233
3334 builder . Services . AddRefitClient < IHackerNewsAPI > ( )
3435 . ConfigureHttpClient ( client => client . BaseAddress = new Uri ( "https://hacker-news.firebaseio.com/v0" ) )
35- . AddTransientHttpErrorPolicy ( builder => builder . WaitAndRetryAsync ( 3 , ExponentialBackoff ) ) ;
36+ . AddStandardResilienceHandler ( options => options . Retry = new MobileHttpRetryStrategyOptions ( ) ) ;
3637
3738 // Pages + View Models
3839 builder . Services . AddTransientWithShellRoute < NewsPage , NewsViewModel > ( $ "//{ nameof ( NewsPage ) } ") ;
39-
40-
40+
4141 return builder . Build ( ) ;
42-
43- static TimeSpan ExponentialBackoff ( int attemptNumber ) => TimeSpan . FromSeconds ( Math . Pow ( 2 , attemptNumber ) ) ;
42+ }
43+
44+ sealed class MobileHttpRetryStrategyOptions : HttpRetryStrategyOptions
45+ {
46+ public MobileHttpRetryStrategyOptions ( )
47+ {
48+ BackoffType = DelayBackoffType . Exponential ;
49+ MaxRetryAttempts = 3 ;
50+ UseJitter = true ;
51+ Delay = TimeSpan . FromMilliseconds ( 2 ) ;
52+ }
4453 }
4554}
Original file line number Diff line number Diff line change 55 <IsPackable >false</IsPackable >
66 </PropertyGroup >
77 <ItemGroup >
8- <PackageReference Include =" NUnit" Version =" 4.0.1 " />
8+ <PackageReference Include =" NUnit" Version =" 4.1.0 " />
99 <PackageReference Include =" NUnit3TestAdapter" Version =" 4.5.0" >
1010 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1111 <PrivateAssets >all</PrivateAssets >
1212 </PackageReference >
13- <PackageReference Include =" NUnit.Analyzers" Version =" 3.10 .0" >
13+ <PackageReference Include =" NUnit.Analyzers" Version =" 4.1 .0" >
1414 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
1515 <PrivateAssets >all</PrivateAssets >
1616 </PackageReference >
17- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.8 .0" />
17+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.9 .0" />
1818 <PackageReference Include =" Microsoft.NETFramework.ReferenceAssemblies" Version =" 1.0.3" PrivateAssets =" All" />
19- <PackageReference Include =" coverlet.collector" Version =" 6.0.0 " PrivateAssets =" All" />
19+ <PackageReference Include =" coverlet.collector" Version =" 6.0.2 " PrivateAssets =" All" />
2020 </ItemGroup >
2121 <ItemGroup >
2222 <ProjectReference Include =" ..\AsyncAwaitBestPractices.MVVM\AsyncAwaitBestPractices.MVVM.csproj" />
You can’t perform that action at this time.
0 commit comments