diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj index dfc96196a1..27b8d665ce 100644 --- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj +++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj @@ -54,7 +54,7 @@ - + diff --git a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs index 175a32efc7..83d7d8efa8 100644 --- a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs +++ b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs @@ -25,6 +25,7 @@ using CommunityToolkit.Maui.Sample.ViewModels.Views.AvatarView; using CommunityToolkit.Maui.Sample.Views.Popups; using CommunityToolkit.Maui.Storage; +using Microsoft.Extensions.Http.Resilience; using Microsoft.Extensions.Logging; using Polly; @@ -57,7 +58,7 @@ public static MauiApp CreateMauiApp() }); builder.Services.AddHttpClient() - .AddTransientHttpErrorPolicy(policyBuilder => policyBuilder.WaitAndRetryAsync(3, SleepDurationProvider)); + .AddStandardResilienceHandler(options => options.Retry = new MobileHttpRetryStrategyOptions()); builder.Services.AddSingleton(); @@ -69,8 +70,6 @@ public static MauiApp CreateMauiApp() #endif return builder.Build(); - - static TimeSpan SleepDurationProvider(int attemptNumber) => TimeSpan.FromSeconds(Math.Pow(2, attemptNumber)); } static void RegisterViewsAndViewModels(in IServiceCollection services) @@ -216,4 +215,15 @@ static IServiceCollection AddTransientWithShellRoute(this ISe { return services.AddTransientWithShellRoute(AppShell.GetPageRoute()); } + + sealed class MobileHttpRetryStrategyOptions : HttpRetryStrategyOptions + { + public MobileHttpRetryStrategyOptions() + { + BackoffType = DelayBackoffType.Exponential; + MaxRetryAttempts = 3; + UseJitter = true; + Delay = TimeSpan.FromSeconds(2); + } + } } \ No newline at end of file diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/IconTintColorBehaviorViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/IconTintColorBehaviorViewModel.cs index 37f41c82dc..af7a053ffb 100644 --- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/IconTintColorBehaviorViewModel.cs +++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/IconTintColorBehaviorViewModel.cs @@ -10,7 +10,7 @@ public partial class IconTintColorBehaviorViewModel : BaseViewModel static readonly IEnumerator toggleableColorsEnumerator = new List { Colors.Red, Colors.Green, null }.GetEnumerator(); - [ObservableProperty] + [ObservableProperty] string toggleableImageSource = shieldImageFileName; [ObservableProperty] @@ -36,6 +36,6 @@ void ChangeColor() toggleableColorsEnumerator.MoveNext(); } - ToggleableIconTintColor = toggleableColorsEnumerator.Current; + ToggleableIconTintColor = toggleableColorsEnumerator.Current; } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.ios.cs b/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.ios.cs index d20471dddb..fa1b4a373d 100644 --- a/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.ios.cs +++ b/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.ios.cs @@ -22,7 +22,7 @@ Task InternalStartListeningAsync(CultureInfo culture, CancellationToken cancella audioEngine = new AVAudioEngine(); liveSpeechRequest = new SFSpeechAudioBufferRecognitionRequest(); - + InitializeAvAudioSession(out _); var node = audioEngine.InputNode; diff --git a/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.macos.cs b/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.macos.cs index 92e838f84b..4de08efa1c 100644 --- a/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.macos.cs +++ b/src/CommunityToolkit.Maui.Core/Essentials/SpeechToText/SpeechToTextImplementation.macos.cs @@ -22,7 +22,7 @@ Task InternalStartListeningAsync(CultureInfo culture, CancellationToken cancella audioEngine = new AVAudioEngine(); liveSpeechRequest = new SFSpeechAudioBufferRecognitionRequest(); - + InitializeAvAudioSession(out var audioSession); var mode = audioSession.AvailableModes.Contains(AVAudioSession.ModeMeasurement) @@ -52,7 +52,7 @@ Task InternalStartListeningAsync(CultureInfo culture, CancellationToken cancella { throw new Exception(error.LocalizedDescription); } - + cancellationToken.ThrowIfCancellationRequested(); var currentIndex = 0; diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.macios.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.macios.cs index f90e0eec4e..c59c9f7418 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.macios.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.macios.cs @@ -83,7 +83,7 @@ public static ValueTask GetImageStream(IList points, Size imageS { throw new InvalidOperationException("Unable to generate image. No Lines Found"); } - + return GetUIImage(points, (context, offset) => { foreach (var line in lines) diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs index 6816775f1b..df46825863 100644 --- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs @@ -63,7 +63,7 @@ public override void ViewDidDisappear(bool animated) overlayView.RemoveFromSuperview(); overlayView.Dispose(); } - + base.ViewDidDisappear(animated); } diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.android.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.android.cs index 3cc8968ad3..a9f028e8b7 100644 --- a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.android.cs +++ b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.android.cs @@ -115,7 +115,7 @@ or PlaybackStateCompat.StateSkippingToQueueItem if (playbackState is IPlayer.StateReady) { MediaElement.Duration = TimeSpan.FromMilliseconds(Player.Duration < 0 ? 0 : Player.Duration); - MediaElement.Position = TimeSpan.FromMilliseconds(Player.CurrentPosition < 0 ? 0: Player.CurrentPosition); + MediaElement.Position = TimeSpan.FromMilliseconds(Player.CurrentPosition < 0 ? 0 : Player.CurrentPosition); } } diff --git a/src/CommunityToolkit.Maui/Behaviors/AnimationBehavior.shared.cs b/src/CommunityToolkit.Maui/Behaviors/AnimationBehavior.shared.cs index 6e45205fac..fb50a1cdc1 100644 --- a/src/CommunityToolkit.Maui/Behaviors/AnimationBehavior.shared.cs +++ b/src/CommunityToolkit.Maui/Behaviors/AnimationBehavior.shared.cs @@ -26,8 +26,8 @@ public class AnimationBehavior : EventToCommandBehavior /// Gets the Command that allows the triggering of the animation. /// /// - /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter" - /// + /// has a of Command<CancellationToken> which requires a as a CommandParameter. See and for more information on passing a into as a CommandParameter" + /// public Command AnimateCommand => (Command)GetValue(AnimateCommandProperty); /// diff --git a/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs b/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs index 70bb229359..bbc6fca461 100644 --- a/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs +++ b/src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs @@ -250,7 +250,7 @@ public IList StyleClass /// TaskCompletionSource IAsynchronousHandler.HandlerCompleteTCS => popupDismissedTaskCompletionSource; - + /// bool IResourcesProvider.IsResourcesCreated => resources is not null;