diff --git a/.editorconfig b/.editorconfig index ee3eb6c5..20db31bc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -266,7 +266,7 @@ dotnet_diagnostic.SA1006.severity = error dotnet_diagnostic.SA1007.severity = error dotnet_diagnostic.SA1008.severity = error dotnet_diagnostic.SA1009.severity = error -dotnet_diagnostic.SA1010.severity = error +dotnet_diagnostic.SA1010.severity = none dotnet_diagnostic.SA1011.severity = error dotnet_diagnostic.SA1012.severity = error dotnet_diagnostic.SA1013.severity = error diff --git a/Sample/SextantSample.Avalonia/App.xaml.cs b/Sample/SextantSample.Avalonia/App.xaml.cs index 5cd570d4..dd84a8ee 100644 --- a/Sample/SextantSample.Avalonia/App.xaml.cs +++ b/Sample/SextantSample.Avalonia/App.xaml.cs @@ -2,6 +2,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using MsBox.Avalonia; using Sextant; using Sextant.Avalonia; using SextantSample.Avalonia.Views; @@ -32,11 +33,9 @@ public override void OnFrameworkInitializationCompleted() .GetService() .PushPage(new HomeViewModel()); - Interactions.ErrorMessage.RegisterHandler(context => - MessageBox.Avalonia - .MessageBoxManager - .GetMessageBoxStandardWindow("Notification", context.Input.ToString()) - .Show()); + Interactions.ErrorMessage.RegisterHandler(async context => + await MessageBoxManager.GetMessageBoxStandard("Notification", context.Input.ToString()) + .ShowAsync()); new Window { Content = Locator.Current.GetNavigationView() }.Show(); base.OnFrameworkInitializationCompleted(); diff --git a/Sample/SextantSample.Avalonia/SextantSample.Avalonia.csproj b/Sample/SextantSample.Avalonia/SextantSample.Avalonia.csproj index 9c720780..27e09bd3 100644 --- a/Sample/SextantSample.Avalonia/SextantSample.Avalonia.csproj +++ b/Sample/SextantSample.Avalonia/SextantSample.Avalonia.csproj @@ -1,22 +1,26 @@ - - - Exe - netcoreapp3.1 - - - - - - - - %(Filename) - - - Designer - - - - - - + + + Exe + net7.0 + preview + + + + + + + + + + %(Filename) + + + Designer + + + + + + + diff --git a/Sample/SextantSample.Core/FirstModalNavigationViewModel.cs b/Sample/SextantSample.Core/FirstModalNavigationViewModel.cs index aa5d57c3..590b6cc5 100644 --- a/Sample/SextantSample.Core/FirstModalNavigationViewModel.cs +++ b/Sample/SextantSample.Core/FirstModalNavigationViewModel.cs @@ -1,15 +1,9 @@ -using System; -using Sextant; +using Sextant; namespace SextantSample.ViewModels { - public class FirstModalNavigationViewModel : ViewModelBase + public class FirstModalNavigationViewModel(IViewStackService viewStackService) : ViewModelBase(viewStackService) { - public FirstModalNavigationViewModel(IViewStackService viewStackService) - : base(viewStackService) - { - - } public override string Id => nameof(FirstModalNavigationViewModel); } } diff --git a/Sample/SextantSample.Core/Interactions.cs b/Sample/SextantSample.Core/Interactions.cs index d2974b08..979fb90b 100644 --- a/Sample/SextantSample.Core/Interactions.cs +++ b/Sample/SextantSample.Core/Interactions.cs @@ -5,6 +5,6 @@ namespace SextantSample.ViewModels { public static class Interactions { - public static readonly Interaction ErrorMessage = new Interaction(); + public static readonly Interaction ErrorMessage = new(); } } diff --git a/Sample/SextantSample.Core/SextantSample.ViewModels.csproj b/Sample/SextantSample.Core/SextantSample.ViewModels.csproj index 8ca4e604..0f94f8f0 100644 --- a/Sample/SextantSample.Core/SextantSample.ViewModels.csproj +++ b/Sample/SextantSample.Core/SextantSample.ViewModels.csproj @@ -3,6 +3,7 @@ netstandard2.0;net6.0;net7.0;net8.0 AnyCPU;x64 + preview diff --git a/Sample/SextantSample.Maui/Platforms/Android/AndroidManifest.xml b/Sample/SextantSample.Maui/Platforms/Android/AndroidManifest.xml index 7570ff62..0f8b33b6 100644 --- a/Sample/SextantSample.Maui/Platforms/Android/AndroidManifest.xml +++ b/Sample/SextantSample.Maui/Platforms/Android/AndroidManifest.xml @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Sample/SextantSample.Maui/SextantSample.Maui.csproj b/Sample/SextantSample.Maui/SextantSample.Maui.csproj index e328bf52..91412765 100644 --- a/Sample/SextantSample.Maui/SextantSample.Maui.csproj +++ b/Sample/SextantSample.Maui/SextantSample.Maui.csproj @@ -33,14 +33,11 @@ - - - @@ -58,6 +55,10 @@ + + + + @@ -68,13 +69,13 @@ - + - + - + @@ -106,7 +107,7 @@ - + diff --git a/Sample/SextantSample.WPF/MainWindow.xaml b/Sample/SextantSample.WPF/MainWindow.xaml index c37d150a..cec26402 100644 --- a/Sample/SextantSample.WPF/MainWindow.xaml +++ b/Sample/SextantSample.WPF/MainWindow.xaml @@ -1,8 +1,11 @@ - + diff --git a/Sample/SextantSample.WPF/SextantSample.WPF.csproj b/Sample/SextantSample.WPF/SextantSample.WPF.csproj index ce263e56..37b93937 100644 --- a/Sample/SextantSample.WPF/SextantSample.WPF.csproj +++ b/Sample/SextantSample.WPF/SextantSample.WPF.csproj @@ -2,13 +2,13 @@ WinExe - net5.0-windows + net8.0-windows true - - + + diff --git a/Sample/SextantSample.sln b/Sample/SextantSample.sln index e99004c6..ae381f1d 100644 --- a/Sample/SextantSample.sln +++ b/Sample/SextantSample.sln @@ -14,7 +14,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sextant.XamForms", "..\src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SextantSample.ViewModels", "SextantSample.Core\SextantSample.ViewModels.csproj", "{5818A5AF-3FF6-4E68-80FC-604D4AEF156C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SextantSample.WPF", "SextantSample.WPF\SextantSample.WPF.csproj", "{B3804254-BA2D-4ECF-9A71-8685843A546F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SextantSample.WPF", "SextantSample.WPF\SextantSample.WPF.csproj", "{B3804254-BA2D-4ECF-9A71-8685843A546F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SextantSample.Maui", "SextantSample.Maui\SextantSample.Maui.csproj", "{7CABE10D-4CDE-4012-9385-6E49EE2E492F}" EndProject @@ -293,38 +293,48 @@ Global {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|iPhone.Build.0 = Release|Any CPU {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|iPhoneSimulator.Build.0 = Release|Any CPU + {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|x64.ActiveCfg = Release|x64 + {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|x64.Build.0 = Release|x64 {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Ad-Hoc|x64.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|Any CPU.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|iPhone.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|iPhone.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|x64.ActiveCfg = Release|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.AppStore|x64.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|iPhone.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|iPhone.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|x64.ActiveCfg = Debug|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Debug|x64.Build.0 = Debug|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|Any CPU.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|iPhone.ActiveCfg = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|iPhone.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|x64.ActiveCfg = Release|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Release|x64.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|Any CPU.ActiveCfg = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|Any CPU.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|iPhone.ActiveCfg = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|iPhone.Build.0 = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|iPhoneSimulator.Build.0 = Release|Any CPU - {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|x64.ActiveCfg = Release|x64 - {5818A5AF-3FF6-4E68-80FC-604D4AEF156C}.Sample Release|x64.Build.0 = Release|x64 + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|x64.ActiveCfg = Release|Any CPU + {B3804254-BA2D-4ECF-9A71-8685843A546F}.Sample Release|x64.Build.0 = Release|Any CPU {7CABE10D-4CDE-4012-9385-6E49EE2E492F}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU {7CABE10D-4CDE-4012-9385-6E49EE2E492F}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU {7CABE10D-4CDE-4012-9385-6E49EE2E492F}.Ad-Hoc|Any CPU.Deploy.0 = Debug|Any CPU diff --git a/Sample/SextantSample/SextantSample.csproj b/Sample/SextantSample/SextantSample.csproj index 1f3b0e31..2e7312a8 100644 --- a/Sample/SextantSample/SextantSample.csproj +++ b/Sample/SextantSample/SextantSample.csproj @@ -3,11 +3,10 @@ netstandard2.0 AnyCPU;x64 + preview - - diff --git a/src/Benchmarks/Sextant.Benchmarks.csproj b/src/Benchmarks/Sextant.Benchmarks.csproj index 8c1446b6..7d23521c 100644 --- a/src/Benchmarks/Sextant.Benchmarks.csproj +++ b/src/Benchmarks/Sextant.Benchmarks.csproj @@ -1,16 +1,16 @@  false - net461;netcoreapp2.0 + net462;net8.0 AnyCPU pdbonly true Exe + enable ;1591;1701;1702;1705;CA1822 - diff --git a/src/Directory.build.props b/src/Directory.build.props index 28bf6a2a..e0eaea7e 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -41,14 +41,14 @@ - - + + - + - + @@ -63,7 +63,7 @@ - + diff --git a/src/Sextant.Avalonia/DependencyResolverMixins.cs b/src/Sextant.Avalonia/DependencyResolverMixins.cs index 976f163b..fccb231e 100644 --- a/src/Sextant.Avalonia/DependencyResolverMixins.cs +++ b/src/Sextant.Avalonia/DependencyResolverMixins.cs @@ -44,12 +44,11 @@ public static IView GetNavigationView( string? contract = null) { var view = dependencyResolver.GetService(contract ?? "NavigationView"); - if (view is null) + return view switch { - throw new InvalidOperationException("NavigationView not registered."); - } - - return view; + null => throw new InvalidOperationException("NavigationView not registered."), + _ => view + }; } } } diff --git a/src/Sextant.Avalonia/Navigation.cs b/src/Sextant.Avalonia/Navigation.cs index 8e332926..179c1c7e 100644 --- a/src/Sextant.Avalonia/Navigation.cs +++ b/src/Sextant.Avalonia/Navigation.cs @@ -9,7 +9,7 @@ using System.Reactive.Linq; using Avalonia.Animation; -using Avalonia.ReactiveUI; +using Avalonia.Controls; using DynamicData.Aggregation; using DynamicData.Binding; @@ -62,7 +62,7 @@ public Navigation() /// /// Gets the control responsible for rendering the current view. /// - public TransitioningContentControl Control { get; } = new TransitioningContentControl(); + public TransitioningContentControl Control { get; } = new(); /// /// Toggles the animations. diff --git a/src/Sextant.Avalonia/NavigationView.cs b/src/Sextant.Avalonia/NavigationView.cs index ce4d0dfe..d11b9837 100644 --- a/src/Sextant.Avalonia/NavigationView.cs +++ b/src/Sextant.Avalonia/NavigationView.cs @@ -21,10 +21,10 @@ namespace Sextant.Avalonia /// /// The implementation for Avalonia. /// - public sealed partial class NavigationView : ContentControl, IStyleable, IView + public sealed partial class NavigationView : ContentControl, IView { - private readonly Navigation _modalNavigation = new Navigation(); - private readonly Navigation _pageNavigation = new Navigation(); + private readonly Navigation _modalNavigation = new(); + private readonly Navigation _pageNavigation = new(); /// /// Initializes a new instance of the class. @@ -62,11 +62,6 @@ public NavigationView() }; } - /// - /// Gets the style key of a . - /// - Type IStyleable.StyleKey => typeof(ContentControl); - /// /// Gets or sets the scheduler used by the . /// @@ -80,6 +75,18 @@ public NavigationView() /// public IObservable PagePopped { get; } = Observable.Never(); + /// + /// Gets the type by which the element is styled. + /// + /// + /// Usually controls are styled by their own type, but there are instances where you want + /// an element to be styled by its base type, e.g. creating SpecialButton that + /// derives from Button and adds extra functionality but is still styled as a regular + /// Button. Override this property to change the style for a control class, returning the + /// type that you wish the elements to be styled as. + /// + protected override Type StyleKeyOverride => typeof(ContentControl); + /// public IObservable PushPage( IViewModel viewModel, @@ -129,14 +136,9 @@ public IObservable PopModal() private IViewFor LocateView(IViewModel viewModel, string? contract) { - var view = ViewLocator.ResolveView(viewModel, contract); - if (view is null) - { - throw new InvalidOperationException( + var view = ViewLocator.ResolveView(viewModel, contract) ?? throw new InvalidOperationException( $"No view could be located for type '{viewModel.GetType().FullName}', " + $"contract '{contract}'. Be sure Splat has an appropriate registration."); - } - view.ViewModel = viewModel; return view; } diff --git a/src/Sextant.Avalonia/Sextant.Avalonia.csproj b/src/Sextant.Avalonia/Sextant.Avalonia.csproj index 473aa83e..49427874 100644 --- a/src/Sextant.Avalonia/Sextant.Avalonia.csproj +++ b/src/Sextant.Avalonia/Sextant.Avalonia.csproj @@ -1,17 +1,17 @@  - netstandard2.0;net5.0 + netstandard2.0;net6.0;net7.0;net8.0 Sextant.Avalonia Sextant.Avalonia Sextant.Avalonia enable - latest + preview - - - + + + diff --git a/src/Sextant.Mocks/Sextant.Mocks.csproj b/src/Sextant.Mocks/Sextant.Mocks.csproj index cbcf952c..bb4aee02 100644 --- a/src/Sextant.Mocks/Sextant.Mocks.csproj +++ b/src/Sextant.Mocks/Sextant.Mocks.csproj @@ -2,7 +2,7 @@ netstandard2.0;net6.0;net7.0;net8.0 - $(TargetFrameworks);net461; + $(TargetFrameworks);net462; false enable latest diff --git a/src/Sextant.Tests/API/ApiApprovalTests.cs b/src/Sextant.Tests/API/ApiApprovalTests.cs index 35fccce9..6054d884 100644 --- a/src/Sextant.Tests/API/ApiApprovalTests.cs +++ b/src/Sextant.Tests/API/ApiApprovalTests.cs @@ -6,7 +6,6 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using Sextant.APITests; -using VerifyXunit; using Xunit; namespace Sextant.Tests @@ -15,7 +14,6 @@ namespace Sextant.Tests /// Tests to make sure that the API matches the approved ones. /// [ExcludeFromCodeCoverage] - [UsesVerify] public class ApiApprovalTests { /// diff --git a/src/Sextant.Tests/API/ApiExtensions.cs b/src/Sextant.Tests/API/ApiExtensions.cs index 8892847b..bedd4e32 100644 --- a/src/Sextant.Tests/API/ApiExtensions.cs +++ b/src/Sextant.Tests/API/ApiExtensions.cs @@ -17,7 +17,6 @@ namespace Sextant.APITests; /// A helper for doing API approvals. /// [ExcludeFromCodeCoverage] -[UsesVerify] public static class ApiExtensions { /// diff --git a/src/Sextant.XamForms.Tests/API/ApiApprovalTests.SextantXamForms.net6.0.approved.txt b/src/Sextant.XamForms.Tests/API/ApiApprovalTests.SextantXamForms.net6.0.approved.txt index 3132831b..61c0e003 100644 --- a/src/Sextant.XamForms.Tests/API/ApiApprovalTests.SextantXamForms.net6.0.approved.txt +++ b/src/Sextant.XamForms.Tests/API/ApiApprovalTests.SextantXamForms.net6.0.approved.txt @@ -31,13 +31,15 @@ namespace Sextant.XamForms Device = 0, NavigationService = 1, } - public class NavigationView : Xamarin.Forms.NavigationPage, Sextant.IView, Splat.IEnableLogger + public class NavigationView : Xamarin.Forms.NavigationPage, Sextant.IView, Splat.IEnableLogger, System.IDisposable { public NavigationView() { } public NavigationView(System.Reactive.Concurrency.IScheduler mainScheduler, System.Reactive.Concurrency.IScheduler backgroundScheduler, ReactiveUI.IViewLocator viewLocator) { } public NavigationView(System.Reactive.Concurrency.IScheduler mainScheduler, System.Reactive.Concurrency.IScheduler backgroundScheduler, ReactiveUI.IViewLocator viewLocator, Xamarin.Forms.Page rootPage) { } public System.Reactive.Concurrency.IScheduler MainThreadScheduler { get; } public System.IObservable PagePopped { get; } + public void Dispose() { } + protected virtual void Dispose(bool disposing) { } public System.IObservable PopModal() { } public System.IObservable PopPage(bool animate) { } public System.IObservable PopToRootPage(bool animate) { } diff --git a/src/Sextant.XamForms.Tests/Sextant.XamForms.Tests.csproj b/src/Sextant.XamForms.Tests/Sextant.XamForms.Tests.csproj index 233056bf..9edd34f0 100644 --- a/src/Sextant.XamForms.Tests/Sextant.XamForms.Tests.csproj +++ b/src/Sextant.XamForms.Tests/Sextant.XamForms.Tests.csproj @@ -11,7 +11,6 @@ - diff --git a/src/Sextant.XamForms/Behaviors/NavigationPageSystemPopBehavior.cs b/src/Sextant.XamForms/Behaviors/NavigationPageSystemPopBehavior.cs index 679f22c0..68be1441 100644 --- a/src/Sextant.XamForms/Behaviors/NavigationPageSystemPopBehavior.cs +++ b/src/Sextant.XamForms/Behaviors/NavigationPageSystemPopBehavior.cs @@ -13,17 +13,12 @@ namespace Sextant.XamForms /// /// Represents a that intercepts the backwards navigation. /// - public sealed class NavigationPageSystemPopBehavior : BehaviorBase + /// + /// Initializes a new instance of the class. + /// + /// A value indicating whether the back button was pressed. + public sealed class NavigationPageSystemPopBehavior(IObservable navigationSource) : BehaviorBase { - private readonly IObservable _navigationSource; - - /// - /// Initializes a new instance of the class. - /// - /// A value indicating whether the back button was pressed. - public NavigationPageSystemPopBehavior(IObservable navigationSource) => - _navigationSource = navigationSource; - /// protected override void OnAttachedTo(NavigationPage bindable) { @@ -36,7 +31,7 @@ protected override void OnAttachedTo(NavigationPage bindable) }, x => bindable.Popped += x, x => bindable.Popped -= x) - .WithLatestFrom(_navigationSource, (navigated, navigationSource) => (navigated, navigationSource)) + .WithLatestFrom(navigationSource, (navigated, navigationSource) => (navigated, navigationSource)) .Where(result => result.navigationSource == NavigationSource.Device) .Select(x => x.navigated) .Subscribe(navigated => diff --git a/src/Sextant.XamForms/NavigationView.cs b/src/Sextant.XamForms/NavigationView.cs index 89333b6f..e0c23e57 100644 --- a/src/Sextant.XamForms/NavigationView.cs +++ b/src/Sextant.XamForms/NavigationView.cs @@ -18,14 +18,13 @@ namespace Sextant.XamForms /// /// The main navigation view. /// - public class NavigationView : NavigationPage, IView, IEnableLogger + public class NavigationView : NavigationPage, IView, IEnableLogger, IDisposable { - private readonly ISubject _navigationSource = - new BehaviorSubject(NavigationSource.Device); - + private readonly BehaviorSubject _navigationSource = new(NavigationSource.Device); private readonly IScheduler _backgroundScheduler; private readonly IViewLocator _viewLocator; private readonly IFullLogger _logger; + private bool _disposedValue; /// /// Initializes a new instance of the class. @@ -198,6 +197,32 @@ public IObservable PushPage( .ToObservable(); }); + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + + /// + /// Releases unmanaged and - optionally - managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + _navigationSource.Dispose(); + } + + _disposedValue = true; + } + } + private static void SetPageTitle(Page page, string resourceKey) => // var title = Localize.GetString(resourceKey); @@ -206,15 +231,9 @@ private static void SetPageTitle(Page page, string resourceKey) => private Page LocatePageFor(object viewModel, string? contract) { - var view = _viewLocator.ResolveView(viewModel, contract); - - if (view is null) - { - throw new InvalidOperationException( + var view = _viewLocator.ResolveView(viewModel, contract) ?? throw new InvalidOperationException( $"No view could be located for type '{viewModel.GetType().FullName}', contract '{contract}'. Be sure Splat has an appropriate registration."); - } - - if (!(view is Page page)) + if (view is not Page page) { throw new InvalidOperationException( $"Resolved view '{view.GetType().FullName}' for type '{viewModel.GetType().FullName}', contract '{contract}' is not a Page."); diff --git a/src/Sextant.XamForms/Sextant.XamForms.csproj b/src/Sextant.XamForms/Sextant.XamForms.csproj index 5fa79b1e..eaa9f40e 100644 --- a/src/Sextant.XamForms/Sextant.XamForms.csproj +++ b/src/Sextant.XamForms/Sextant.XamForms.csproj @@ -1,12 +1,12 @@  - netstandard2.0;net6.0;net7.0 + netstandard2.0;net6.0;net7.0;net8.0 Sextant.XamForms Sextant.XamForms Sextant.XamForms enable - latest + preview diff --git a/src/Sextant/Platforms/mac/SextantExtensions.cs b/src/Sextant/Platforms/mac/SextantExtensions.cs index 2eb978a9..ddf98a68 100644 --- a/src/Sextant/Platforms/mac/SextantExtensions.cs +++ b/src/Sextant/Platforms/mac/SextantExtensions.cs @@ -22,10 +22,7 @@ public static class SextantExtensions /// The sextant. public static void Initialize(this Sextant sextant) { - if (sextant is null) - { - throw new ArgumentNullException(nameof(sextant)); - } + ArgumentNullException.ThrowIfNull(sextant); sextant.MutableLocator.RegisterViewStackService(); } diff --git a/src/Sextant/Platforms/net4/SextantExtensions.cs b/src/Sextant/Platforms/net4/SextantExtensions.cs index 2eb978a9..b11ec829 100644 --- a/src/Sextant/Platforms/net4/SextantExtensions.cs +++ b/src/Sextant/Platforms/net4/SextantExtensions.cs @@ -4,10 +4,6 @@ // See the LICENSE file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Reactive.Concurrency; -using System.Text; -using Splat; namespace Sextant { diff --git a/src/Sextant/Platforms/uikit-common/SextantExtensions.cs b/src/Sextant/Platforms/uikit-common/SextantExtensions.cs index 3b9e5b61..30c661cb 100644 --- a/src/Sextant/Platforms/uikit-common/SextantExtensions.cs +++ b/src/Sextant/Platforms/uikit-common/SextantExtensions.cs @@ -4,9 +4,7 @@ // See the LICENSE file in the project root for full license information. using System; -using System.Collections.Generic; using System.Reactive.Concurrency; -using System.Text; using Splat; namespace Sextant diff --git a/src/Sextant/Sextant.csproj b/src/Sextant/Sextant.csproj index b66b581c..a05d7eae 100644 --- a/src/Sextant/Sextant.csproj +++ b/src/Sextant/Sextant.csproj @@ -6,7 +6,7 @@ Sextant Sextant enable - latest + preview @@ -16,7 +16,7 @@ - + diff --git a/src/global.json b/src/global.json index d9af7e6d..5832575b 100644 --- a/src/global.json +++ b/src/global.json @@ -1,8 +1,7 @@ { "sdk": { "version": "8.0.10", - "rollForward": "latestMinor", - "allowPrerelease": true + "rollForward": "latestFeature" }, "msbuild-sdks": { "MSBuild.Sdk.Extras": "3.0.44"