From b5a984c13834d460d0d6595c00dea87a53c6b218 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 01:19:28 -0600 Subject: [PATCH 01/14] : : chore: .net8 yak shaving turn the world upside down +semver: minor --- .build/AirframeBuild.cs | 74 +- Airframe.sln | 32 +- analyzers.ruleset | 2 +- .../Performance/ContentPageBaseBenchmark.cs | 35 - .../Performance/ContentViewBaseBenchmark.cs | 34 - .../Performance/ListViewBaseBenchmark.cs | 34 - .../Performance/Mocks/TestContentView.cs | 6 - benchmarks/Performance/Mocks/TestPage.cs | 6 - benchmarks/Performance/Mocks/TestViewCell.cs | 8 - benchmarks/Performance/Performance.csproj | 4 +- .../Performance/ViewCellBaseBenchmark.cs | 34 - directory.build.props | 18 +- src/Apple/Apple.csproj | 2 +- src/Composition/ApplicationBase.cs | 83 -- src/Controls/Controls.csproj | 44 - src/Controls/Controls.csproj.DotSettings | 5 - .../appkit/ApplicationDelegateBase.cs | 67 -- .../appkit/UserNotificationExtensions.cs | 59 -- .../Platforms/appkit/ViewControllerBase.cs | 128 --- .../Platforms/appkit/WindowControllerBase.cs | 42 - .../Platforms/apple-common/ControlBase.cs | 16 - .../Platforms/apple-common/ImageViewBase.cs | 17 - .../Platforms/apple-common/ViewBase.cs | 16 - src/Controls/Platforms/uikit/AlertViews.cs | 62 -- .../uikit/ApplicationDelegateBase.cs | 62 -- .../Platforms/uikit/CollectionViewBase.cs | 56 -- .../Platforms/uikit/CollectionViewCellBase.cs | 17 - .../uikit/CollectionViewControllerBase.cs | 71 -- .../Platforms/uikit/IosBackgroundOperation.cs | 49 - src/Controls/Platforms/uikit/TableViewBase.cs | 49 - .../Platforms/uikit/TableViewCellBase.cs | 72 -- .../uikit/TableViewControllerBase.cs | 133 --- .../Platforms/uikit/ViewControllerBase.cs | 128 --- src/Controls/Rocket.Surgery.Airframe.xml | 694 --------------- src/Controls/Rocket.Surgery.ReactiveUI.xml | 838 ------------------ src/Core/Connectivity/ConnectionProfile.cs | 11 + src/Core/Connectivity/INetworkState.cs | 56 ++ src/Core/Connectivity/NetworkAccess.cs | 11 + .../Connectivity/NetworkStateChangedEvent.cs | 64 ++ src/Core/Core.csproj | 3 +- src/Core/Navigation/ArgumentExtensions.cs | 168 ++++ src/Core/Navigation/Arguments.cs | 6 + src/Core/Navigation/ArgumentsBase.cs | 203 +++++ src/Core/Navigation/IArguments.cs | 68 ++ src/Core/Navigation/IDestructible.cs | 12 + src/Core/Navigation/IInitialize.cs | 13 + src/Core/Navigation/INavigated.cs | 19 + src/Core/Navigation/INavigator.cs | 52 ++ src/Core/Navigation/NavigationException.cs | 8 + src/Data/Data.csproj | 9 +- src/Forms/ExceptionHandler.cs | 19 - src/Forms/Forms.csproj | 28 - src/Forms/Forms.csproj.DotSettings | 5 - src/Forms/Pages/ContentPageBase.cs | 100 --- src/Forms/SchedulerProvider.cs | 36 - src/Forms/Views/ContentViewBase.cs | 61 -- src/Forms/Views/ReactiveCollectionView.cs | 25 - src/Forms/Views/ReactiveListView.cs | 48 - src/Forms/Views/ViewCellBase.cs | 78 -- .../MicrosoftDependencyInjection.csproj | 2 +- src/Popup/Popup.csproj | 25 - src/Popup/PopupPageBase.cs | 114 --- src/Shiny/ReactiveShinyStartup.cs | 114 --- src/Shiny/Settings/Setting.cs | 53 -- src/Shiny/Settings/SettingsProvider.cs | 91 -- src/Shiny/Shiny.csproj | 23 - src/Synthetic/Synthetic.csproj | 6 +- src/Timers/Timers.csproj | 2 +- src/ViewModels/IInitializable.cs | 46 - src/ViewModels/INetworkAware.cs | 4 +- src/ViewModels/IViewModel.cs | 19 - src/ViewModels/InitializableViewModel.cs | 66 -- src/ViewModels/NavigableViewModelBase.cs | 94 +- src/ViewModels/ViewModelBase.cs | 32 +- src/ViewModels/ViewModels.csproj | 22 +- test/Airframe.Tests/Airframe.Tests.csproj | 10 +- .../BaseExceptionHandlerStub.cs | 20 - test/Airframe.Tests/NoExceptionHandlerStub.cs | 24 + .../SchedulerProviderFixture.cs | 36 +- test/Airframe.Tests/TestBase.cs | 4 +- .../Composition.Tests.csproj | 5 +- .../Composition.Tests/CompositionRootTests.cs | 23 +- test/Composition.Tests/DryIocModuleTests.cs | 17 +- .../IRegistrarExtensionTests.cs | 55 +- test/Composition.Tests/TestModule.cs | 14 +- test/Composition.Tests/TestView.cs | 19 +- test/Composition.Tests/TestViewModel.cs | 12 +- .../ConnectivityChangedEventFixture.cs | 27 + .../ConnectivityChangedEventTests.cs | 76 ++ .../ConnectivityInterfaceTests.cs | 103 +++ .../Connectivity/NetworkStateMock.cs | 22 + test/Core.Tests/Core.Tests.csproj | 15 - test/Data.Tests/Data.Tests.csproj | 2 - .../MicrosoftDependencyInjection.Tests.csproj | 17 - test/Shiny.Tests/ReactiveShinyStartupTests.cs | 28 - test/Shiny.Tests/TestStartup.cs | 21 - test/Timers.Tests/DecrementTimerFixture.cs | 3 +- test/Timers.Tests/DecrementTimerTests.cs | 2 +- test/Timers.Tests/DivisibleTimerFixture.cs | 2 +- test/Timers.Tests/DivisibleTimerTests.cs | 2 +- test/Timers.Tests/IncrementTimerFixture.cs | 2 +- test/Timers.Tests/IncrementTimerTests.cs | 2 +- test/Timers.Tests/Timers.Tests.csproj | 3 - .../NavigableViewModelTests.cs | 6 +- .../TestNavigationViewModel.cs | 19 +- .../TestNavigationViewModelFixture.cs | 2 +- test/ViewModels.Tests/TestViewModel.cs | 4 +- test/ViewModels.Tests/TestViewModelFixture.cs | 2 +- test/ViewModels.Tests/ViewModelTests.cs | 2 +- test/ViewModels.Tests/ViewModels.Tests.csproj | 2 - test/directory.build.props | 21 +- 111 files changed, 1208 insertions(+), 4229 deletions(-) delete mode 100644 benchmarks/Performance/ContentPageBaseBenchmark.cs delete mode 100644 benchmarks/Performance/ContentViewBaseBenchmark.cs delete mode 100644 benchmarks/Performance/ListViewBaseBenchmark.cs delete mode 100644 benchmarks/Performance/Mocks/TestContentView.cs delete mode 100644 benchmarks/Performance/Mocks/TestPage.cs delete mode 100644 benchmarks/Performance/Mocks/TestViewCell.cs delete mode 100644 benchmarks/Performance/ViewCellBaseBenchmark.cs delete mode 100644 src/Composition/ApplicationBase.cs delete mode 100644 src/Controls/Controls.csproj delete mode 100644 src/Controls/Controls.csproj.DotSettings delete mode 100644 src/Controls/Platforms/appkit/ApplicationDelegateBase.cs delete mode 100644 src/Controls/Platforms/appkit/UserNotificationExtensions.cs delete mode 100644 src/Controls/Platforms/appkit/ViewControllerBase.cs delete mode 100644 src/Controls/Platforms/appkit/WindowControllerBase.cs delete mode 100644 src/Controls/Platforms/apple-common/ControlBase.cs delete mode 100644 src/Controls/Platforms/apple-common/ImageViewBase.cs delete mode 100644 src/Controls/Platforms/apple-common/ViewBase.cs delete mode 100644 src/Controls/Platforms/uikit/AlertViews.cs delete mode 100644 src/Controls/Platforms/uikit/ApplicationDelegateBase.cs delete mode 100644 src/Controls/Platforms/uikit/CollectionViewBase.cs delete mode 100644 src/Controls/Platforms/uikit/CollectionViewCellBase.cs delete mode 100644 src/Controls/Platforms/uikit/CollectionViewControllerBase.cs delete mode 100644 src/Controls/Platforms/uikit/IosBackgroundOperation.cs delete mode 100644 src/Controls/Platforms/uikit/TableViewBase.cs delete mode 100644 src/Controls/Platforms/uikit/TableViewCellBase.cs delete mode 100644 src/Controls/Platforms/uikit/TableViewControllerBase.cs delete mode 100644 src/Controls/Platforms/uikit/ViewControllerBase.cs delete mode 100644 src/Controls/Rocket.Surgery.Airframe.xml delete mode 100644 src/Controls/Rocket.Surgery.ReactiveUI.xml create mode 100644 src/Core/Connectivity/ConnectionProfile.cs create mode 100644 src/Core/Connectivity/INetworkState.cs create mode 100644 src/Core/Connectivity/NetworkAccess.cs create mode 100644 src/Core/Connectivity/NetworkStateChangedEvent.cs create mode 100644 src/Core/Navigation/ArgumentExtensions.cs create mode 100644 src/Core/Navigation/Arguments.cs create mode 100644 src/Core/Navigation/ArgumentsBase.cs create mode 100644 src/Core/Navigation/IArguments.cs create mode 100644 src/Core/Navigation/IDestructible.cs create mode 100644 src/Core/Navigation/IInitialize.cs create mode 100644 src/Core/Navigation/INavigated.cs create mode 100644 src/Core/Navigation/INavigator.cs create mode 100644 src/Core/Navigation/NavigationException.cs delete mode 100644 src/Forms/ExceptionHandler.cs delete mode 100644 src/Forms/Forms.csproj delete mode 100644 src/Forms/Forms.csproj.DotSettings delete mode 100644 src/Forms/Pages/ContentPageBase.cs delete mode 100644 src/Forms/SchedulerProvider.cs delete mode 100644 src/Forms/Views/ContentViewBase.cs delete mode 100644 src/Forms/Views/ReactiveCollectionView.cs delete mode 100644 src/Forms/Views/ReactiveListView.cs delete mode 100644 src/Forms/Views/ViewCellBase.cs delete mode 100644 src/Popup/Popup.csproj delete mode 100644 src/Popup/PopupPageBase.cs delete mode 100644 src/Shiny/ReactiveShinyStartup.cs delete mode 100644 src/Shiny/Settings/Setting.cs delete mode 100644 src/Shiny/Settings/SettingsProvider.cs delete mode 100644 src/Shiny/Shiny.csproj delete mode 100644 src/ViewModels/IInitializable.cs delete mode 100644 src/ViewModels/IViewModel.cs delete mode 100644 src/ViewModels/InitializableViewModel.cs delete mode 100644 test/Airframe.Tests/BaseExceptionHandlerStub.cs create mode 100644 test/Airframe.Tests/NoExceptionHandlerStub.cs create mode 100644 test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs create mode 100644 test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs create mode 100644 test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs create mode 100644 test/Core.Tests/Connectivity/NetworkStateMock.cs delete mode 100644 test/Shiny.Tests/ReactiveShinyStartupTests.cs delete mode 100644 test/Shiny.Tests/TestStartup.cs diff --git a/.build/AirframeBuild.cs b/.build/AirframeBuild.cs index e45885bf8..9581453a4 100644 --- a/.build/AirframeBuild.cs +++ b/.build/AirframeBuild.cs @@ -21,50 +21,58 @@ [NuGetVerbosityMapping] [EnsureGitHooks(GitHook.CommitMsg)] public partial class AirframeBuild : NukeBuild, - ICanClean, - ICanRestoreWithMsBuild, - ICanTestWithDotNetCoreNoBuild, - ICanPackWithMsBuild, - ICanUpdateReadme, - IHaveDataCollector, - IHaveConfiguration, - IGenerateCodeCoverageReport, - IGenerateCodeCoverageSummary, - IGenerateCodeCoverageBadges, - ICanLint + ICanRestoreWithDotNetCore, + ICanBuildWithDotNetCore, + ICanTestWithDotNetCore, + ICanPackWithDotNetCore, + IHaveDataCollector, + ICanClean, + ICanLintStagedFiles, + ICanDotNetFormat, + IHavePublicApis, + ICanUpdateReadme, + IGenerateCodeCoverageReport, + IGenerateCodeCoverageSummary, + IGenerateCodeCoverageBadges, + ICanRegenerateBuildConfiguration, + IHaveConfiguration + { /// - /// Support plugins are available for: - /// - JetBrains ReSharper https://nuke.build/resharper - /// - JetBrains Rider https://nuke.build/rider - /// - Microsoft VisualStudio https://nuke.build/visualstudio - /// - Microsoft VSCode https://nuke.build/vscode + /// Support plugins are available for: + /// - JetBrains ReSharper https://nuke.build/resharper + /// - JetBrains Rider https://nuke.build/rider + /// - Microsoft VisualStudio https://nuke.build/visualstudio + /// - Microsoft VSCode https://nuke.build/vscode /// public static int Main() => Execute(x => x.Default); - [OptionalGitRepository] - public GitRepository? GitRepository { get; } - - [ComputedGitVersion] public GitVersion GitVersion { get; } = null!; - - private Target Default => _ => _ + public Target Default => definition => definition .DependsOn(Restore) .DependsOn(Build) .DependsOn(Test) .DependsOn(Pack); - public Target Build => _ => _.Inherit(x => x.NetBuild); + public Target Build => definition => definition.Inherit(x => x.CoreBuild); + + public Target Pack => definition => definition.Inherit(x => x.CorePack) + .DependsOn(Clean) + .After(Test); + + public Target Clean => definition => definition.Inherit(x => x.Clean); + public Target Restore => definition => definition.Inherit(x => x.CoreRestore); + public Target Test => definition => definition.Inherit(x => x.CoreTest); + + [Solution(GenerateProjects = true)] + private Solution Solution { get; } = null!; + + Nuke.Common.ProjectModel.Solution IHaveSolution.Solution => Solution; + + [OptionalGitRepository] + public GitRepository? GitRepository { get; } - public Target Pack => _ => _ - .Inherit(x => x.NetPack) - .DependsOn(Clean); - public Target Clean => _ => _.Inherit(x => x.Clean); - public Target Restore => _ => _.Inherit(x => x.NetRestore); - public Target Test => _ => _.Inherit(x => x.CoreTest); - public Target BuildVersion => _ => _ - .Inherit(x => x.BuildVersion) - .Before(Default) - .Before(Clean); + [ComputedGitVersion] + public GitVersion GitVersion { get; } = null!; [Parameter("Configuration to build")] public Configuration Configuration { get; } = IsLocalBuild ? Configuration.Debug : Configuration.Release; diff --git a/Airframe.sln b/Airframe.sln index 0b65fe44c..c07530443 100644 --- a/Airframe.sln +++ b/Airframe.sln @@ -16,10 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{843C3844-B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViewModels", "src\ViewModels\ViewModels.csproj", "{CA4B6910-402D-40C3-99C6-8DF8E3ABF041}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controls", "src\Controls\Controls.csproj", "{F717BFF2-0DD5-453D-AB60-1CA85D7FCB87}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "src\Forms\Forms.csproj", "{94F40576-6748-40AB-A541-ED6A45035796}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuspec", ".nuspec", "{0FF56E4B-1F2D-4839-B857-9C878FC2F55B}" ProjectSection(SolutionItems) = preProject .nuspec/Controls.nuspec = .nuspec/Controls.nuspec @@ -38,8 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuspec", ".nuspec", "{0FF5 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ".build", ".build\.build.csproj", "{8322904C-5A48-4A92-A5EA-2AF91F8C4595}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Popup", "src\Popup\Popup.csproj", "{16FCCE0B-9C29-48D2-8CE7-0DC1D616B602}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composition", "src\Composition\Composition.csproj", "{36A9DAA0-FCD4-41A3-A046-C755937CA701}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composition.Tests", "test\Composition.Tests\Composition.Tests.csproj", "{D8A98936-BA4C-44A9-BD39-34DCBEF665C9}" @@ -56,8 +50,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Timers", "src\Timers\Timers EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Airframe.Tests", "test\Airframe.Tests\Airframe.Tests.csproj", "{4C29DC6C-1251-4B3F-8F2C-447F24230E56}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shiny", "src\Shiny\Shiny.csproj", "{DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{0AF062D9-82F6-4384-B01A-137DF8A880D1}" ProjectSection(SolutionItems) = preProject EndProjectSection @@ -121,6 +113,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{F9E0EB .husky/commit-msg = .husky/commit-msg EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{3AB63C21-EA38-4EC8-BECC-FC10CFFC5195}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -131,20 +125,8 @@ Global {CA4B6910-402D-40C3-99C6-8DF8E3ABF041}.Debug|Any CPU.Build.0 = Debug|Any CPU {CA4B6910-402D-40C3-99C6-8DF8E3ABF041}.Release|Any CPU.ActiveCfg = Release|Any CPU {CA4B6910-402D-40C3-99C6-8DF8E3ABF041}.Release|Any CPU.Build.0 = Release|Any CPU - {F717BFF2-0DD5-453D-AB60-1CA85D7FCB87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F717BFF2-0DD5-453D-AB60-1CA85D7FCB87}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F717BFF2-0DD5-453D-AB60-1CA85D7FCB87}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F717BFF2-0DD5-453D-AB60-1CA85D7FCB87}.Release|Any CPU.Build.0 = Release|Any CPU - {94F40576-6748-40AB-A541-ED6A45035796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {94F40576-6748-40AB-A541-ED6A45035796}.Debug|Any CPU.Build.0 = Debug|Any CPU - {94F40576-6748-40AB-A541-ED6A45035796}.Release|Any CPU.ActiveCfg = Release|Any CPU - {94F40576-6748-40AB-A541-ED6A45035796}.Release|Any CPU.Build.0 = Release|Any CPU {8322904C-5A48-4A92-A5EA-2AF91F8C4595}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8322904C-5A48-4A92-A5EA-2AF91F8C4595}.Release|Any CPU.ActiveCfg = Release|Any CPU - {16FCCE0B-9C29-48D2-8CE7-0DC1D616B602}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {16FCCE0B-9C29-48D2-8CE7-0DC1D616B602}.Debug|Any CPU.Build.0 = Debug|Any CPU - {16FCCE0B-9C29-48D2-8CE7-0DC1D616B602}.Release|Any CPU.ActiveCfg = Release|Any CPU - {16FCCE0B-9C29-48D2-8CE7-0DC1D616B602}.Release|Any CPU.Build.0 = Release|Any CPU {36A9DAA0-FCD4-41A3-A046-C755937CA701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {36A9DAA0-FCD4-41A3-A046-C755937CA701}.Debug|Any CPU.Build.0 = Debug|Any CPU {36A9DAA0-FCD4-41A3-A046-C755937CA701}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -177,10 +159,6 @@ Global {4C29DC6C-1251-4B3F-8F2C-447F24230E56}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C29DC6C-1251-4B3F-8F2C-447F24230E56}.Release|Any CPU.ActiveCfg = Release|Any CPU {4C29DC6C-1251-4B3F-8F2C-447F24230E56}.Release|Any CPU.Build.0 = Release|Any CPU - {DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F}.Release|Any CPU.Build.0 = Release|Any CPU {F1D890A7-A606-4659-BC44-643B6D54B66C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F1D890A7-A606-4659-BC44-643B6D54B66C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1D890A7-A606-4659-BC44-643B6D54B66C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -219,10 +197,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {CA4B6910-402D-40C3-99C6-8DF8E3ABF041} = {BC256BE7-7896-4159-BB31-9F3D22860391} - {F717BFF2-0DD5-453D-AB60-1CA85D7FCB87} = {BC256BE7-7896-4159-BB31-9F3D22860391} - {94F40576-6748-40AB-A541-ED6A45035796} = {BC256BE7-7896-4159-BB31-9F3D22860391} - {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} - {16FCCE0B-9C29-48D2-8CE7-0DC1D616B602} = {BC256BE7-7896-4159-BB31-9F3D22860391} {36A9DAA0-FCD4-41A3-A046-C755937CA701} = {BC256BE7-7896-4159-BB31-9F3D22860391} {D8A98936-BA4C-44A9-BD39-34DCBEF665C9} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {D42E447B-522C-48E6-82A9-B24780BC7A35} = {BC256BE7-7896-4159-BB31-9F3D22860391} @@ -231,7 +205,6 @@ Global {89A9A8DA-80DD-4A27-A49C-AE2F3356B59D} = {BC256BE7-7896-4159-BB31-9F3D22860391} {70DA205B-50E9-4F4D-B244-9C2E2B40A2EE} = {BC256BE7-7896-4159-BB31-9F3D22860391} {4C29DC6C-1251-4B3F-8F2C-447F24230E56} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} - {DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F} = {BC256BE7-7896-4159-BB31-9F3D22860391} {F1D890A7-A606-4659-BC44-643B6D54B66C} = {0AF062D9-82F6-4384-B01A-137DF8A880D1} {F8F14442-7FE5-41DE-8C57-3D9D0DDE246D} = {BC256BE7-7896-4159-BB31-9F3D22860391} {63623831-9DA6-4563-BC94-F9B4007CFE89} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} @@ -243,6 +216,7 @@ Global {6813747B-13DB-4144-AB19-22C84E734517} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {9FF05512-3C79-4FF9-8006-1313E2AF8A65} = {6813747B-13DB-4144-AB19-22C84E734517} {F9E0EBA5-5737-440E-8F30-20CCFC207E9E} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} + {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {3AB63C21-EA38-4EC8-BECC-FC10CFFC5195} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8F0DF64A-C8D5-41DF-B4C9-5C70526644DF} diff --git a/analyzers.ruleset b/analyzers.ruleset index 659255176..9dd486aa6 100644 --- a/analyzers.ruleset +++ b/analyzers.ruleset @@ -117,7 +117,7 @@ - + diff --git a/benchmarks/Performance/ContentPageBaseBenchmark.cs b/benchmarks/Performance/ContentPageBaseBenchmark.cs deleted file mode 100644 index b96adf2a9..000000000 --- a/benchmarks/Performance/ContentPageBaseBenchmark.cs +++ /dev/null @@ -1,35 +0,0 @@ -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Jobs; -using ReactiveUI.XamForms; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - [SimpleJob(RuntimeMoniker.NetCoreApp31)] - [MemoryDiagnoser] - [MarkdownExporterAttribute.GitHub] - public class ContentPageBaseBenchmark - { - /// - /// Creates the reactive content page. - /// - /// - [Benchmark(Baseline = true)] - public ReactiveContentPage CreateReactiveContentPage() => new ReactiveContentPage(); - - /// - /// Creates the content page. - /// - /// - [Benchmark] - public ContentPage CreateContentPage() => new ContentPage(); - - - /// - /// Creates the test content page. - /// - /// - [Benchmark] - public TestPage CreateTestContentPage() => new TestPage(); - } -} diff --git a/benchmarks/Performance/ContentViewBaseBenchmark.cs b/benchmarks/Performance/ContentViewBaseBenchmark.cs deleted file mode 100644 index 3842077f0..000000000 --- a/benchmarks/Performance/ContentViewBaseBenchmark.cs +++ /dev/null @@ -1,34 +0,0 @@ -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Jobs; -using ReactiveUI.XamForms; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - [SimpleJob(RuntimeMoniker.NetCoreApp31)] - [MemoryDiagnoser] - [MarkdownExporterAttribute.GitHub] - public class ContentViewBaseBenchmark - { - /// - /// Creates the reactive content page. - /// - /// - [Benchmark(Baseline = true)] - public ReactiveContentView CreateReactiveContentView() => new ReactiveContentView(); - - /// - /// Creates the content view. - /// - /// - [Benchmark] - public ContentView CreateContentView() => new ContentView(); - - /// - /// Creates the test content page. - /// - /// - [Benchmark] - public TestContentView CreateTestContentView() => new TestContentView(); - } -} \ No newline at end of file diff --git a/benchmarks/Performance/ListViewBaseBenchmark.cs b/benchmarks/Performance/ListViewBaseBenchmark.cs deleted file mode 100644 index dd24053cf..000000000 --- a/benchmarks/Performance/ListViewBaseBenchmark.cs +++ /dev/null @@ -1,34 +0,0 @@ -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Jobs; -using Rocket.Surgery.Airframe.Forms; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - [SimpleJob(RuntimeMoniker.NetCoreApp31)] - [MemoryDiagnoser] - [MarkdownExporterAttribute.GitHub] - public class ListViewBenchmark - { - /// - /// Creates the reactive list view. - /// - /// - [Benchmark(Baseline = true)] - public ReactiveListView CreateReactiveListView() => new ReactiveListView(); - - /// - /// Creates the reactive content page. - /// - /// - [Benchmark] - public ReactiveListView CreateReactiveListViewWithDataTemplate() => new ReactiveListView(typeof(TestContentView)); - - /// - /// Creates the list view. - /// - /// - [Benchmark] - public ListView CreateListView() => new ListView(); - } -} diff --git a/benchmarks/Performance/Mocks/TestContentView.cs b/benchmarks/Performance/Mocks/TestContentView.cs deleted file mode 100644 index 19d519015..000000000 --- a/benchmarks/Performance/Mocks/TestContentView.cs +++ /dev/null @@ -1,6 +0,0 @@ -using Rocket.Surgery.Airframe.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - public class TestContentView : ContentViewBase { } -} \ No newline at end of file diff --git a/benchmarks/Performance/Mocks/TestPage.cs b/benchmarks/Performance/Mocks/TestPage.cs deleted file mode 100644 index 84766d0b6..000000000 --- a/benchmarks/Performance/Mocks/TestPage.cs +++ /dev/null @@ -1,6 +0,0 @@ -using Rocket.Surgery.Airframe.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - public class TestPage : ContentPageBase { } -} \ No newline at end of file diff --git a/benchmarks/Performance/Mocks/TestViewCell.cs b/benchmarks/Performance/Mocks/TestViewCell.cs deleted file mode 100644 index 7df4ed8d8..000000000 --- a/benchmarks/Performance/Mocks/TestViewCell.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Rocket.Surgery.Airframe.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - public class TestViewCell : ViewCellBase - { - } -} diff --git a/benchmarks/Performance/Performance.csproj b/benchmarks/Performance/Performance.csproj index 866b269ef..b5a0900b3 100644 --- a/benchmarks/Performance/Performance.csproj +++ b/benchmarks/Performance/Performance.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net8.0 enable Exe false @@ -18,8 +18,6 @@ - - diff --git a/benchmarks/Performance/ViewCellBaseBenchmark.cs b/benchmarks/Performance/ViewCellBaseBenchmark.cs deleted file mode 100644 index f8ca5fb36..000000000 --- a/benchmarks/Performance/ViewCellBaseBenchmark.cs +++ /dev/null @@ -1,34 +0,0 @@ -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Jobs; -using ReactiveUI.XamForms; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Performance -{ - [SimpleJob(RuntimeMoniker.NetCoreApp31)] - [MemoryDiagnoser] - [MarkdownExporterAttribute.GitHub] - public class ViewCellBaseBenchmark - { - /// - /// Creates the reactive content page. - /// - /// - [Benchmark(Baseline = true)] - public ReactiveViewCell CreateReactiveViewCell() => new ReactiveViewCell(); - - /// - /// Creates the content view. - /// - /// - [Benchmark] - public ViewCell CreateViewCell() => new ViewCell(); - - /// - /// Creates the test content page. - /// - /// - [Benchmark] - public TestViewCell CreateTestViewCell() => new TestViewCell(); - } -} diff --git a/directory.build.props b/directory.build.props index 74b37fc71..1e0d02cbd 100644 --- a/directory.build.props +++ b/directory.build.props @@ -1,13 +1,13 @@ - RLittlesII - Rocket Surgeons Guild - Copyright Rodney Littles, II © 2021 - latest - - false - true - true - 1 + Rodney Littles II, Rocket Surgeons Guild contributors + Rocket Surgeons Guild + Copyright Rocket Surgeons Guild © $([System.DateTime]::Now.ToString('yyyy')) + latest + false + true + true + 1 + enable \ No newline at end of file diff --git a/src/Apple/Apple.csproj b/src/Apple/Apple.csproj index 59c9949a1..679469fa7 100644 --- a/src/Apple/Apple.csproj +++ b/src/Apple/Apple.csproj @@ -1,7 +1,7 @@ - xamarin.ios10;xamarin.mac20 + net8.0-ios;net8.0-maccatalyst Rocket.Surgery.Airframe.Apple Rocket.Surgery.Airframe.Apple latest diff --git a/src/Composition/ApplicationBase.cs b/src/Composition/ApplicationBase.cs deleted file mode 100644 index 37967304a..000000000 --- a/src/Composition/ApplicationBase.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using DryIoc; -using Splat.DryIoc; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Composition -{ - /// - /// Base application abstraction. - /// - /// - [SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - public abstract class ApplicationBase : Application - { - private readonly IPlatformRegistrar? _platformRegistrar; - private IContainer _container; - - /// - /// Initializes a new instance of the class. - /// - protected ApplicationBase() - : this(null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The platformRegistrar. - [SuppressMessage("ReSharper", "CS8618:NonNullableMember", Justification = "Consumers should be aware methods are for object construction.")] - protected ApplicationBase(IPlatformRegistrar? platformRegistrar) - { - _platformRegistrar = platformRegistrar; - Initialize(); - } - - /// - /// Gets the current application container. - /// - public static new ApplicationBase Current => (ApplicationBase)Application.Current; - - /// - /// Gets or sets the dependency inversion container. - /// - public IContainer Container { get; protected set; } - - /// - /// Initialize the . - /// - protected void Initialize() => ComposeApplicationRoot(); - - /// - /// Composes the applications composition root. - /// - protected virtual void ComposeApplicationRoot() - { - _container = CreateContainer(); - _platformRegistrar?.RegisterPlatformServices(_container); - RegisterServices(_container); - _container.UseDryIocDependencyResolver(); - Container = _container.WithNoMoreRegistrationAllowed(); - } - - /// - /// Returns a new container instance. - /// - /// The container. - protected virtual IContainer CreateContainer() => new Container(); - - /// - /// Register the platform services. - /// - /// The registrar. - protected virtual void RegisterPlatformServices(IPlatformRegistrar registrar) => - registrar?.RegisterPlatformServices(_container); - - /// - /// Registers services with the instance. - /// - /// The container. - protected abstract void RegisterServices(IContainer container); - } -} diff --git a/src/Controls/Controls.csproj b/src/Controls/Controls.csproj deleted file mode 100644 index e11656588..000000000 --- a/src/Controls/Controls.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - netstandard2.0;xamarin.ios10;xamarin.mac20 - Rocket.Surgery.Airframe - Rocket.Surgery.Airframe - latest - Rocket.Surgery.Airframe - ReactiveUI base platform abstractions. - true - - - - Rocket.Surgery.Airframe.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Controls/Controls.csproj.DotSettings b/src/Controls/Controls.csproj.DotSettings deleted file mode 100644 index 10b31b879..000000000 --- a/src/Controls/Controls.csproj.DotSettings +++ /dev/null @@ -1,5 +0,0 @@ - - True - True - True - True \ No newline at end of file diff --git a/src/Controls/Platforms/appkit/ApplicationDelegateBase.cs b/src/Controls/Platforms/appkit/ApplicationDelegateBase.cs deleted file mode 100644 index 733269782..000000000 --- a/src/Controls/Platforms/appkit/ApplicationDelegateBase.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using AppKit; -using DryIoc; -using Foundation; -using Splat.DryIoc; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// - public abstract class ApplicationDelegateBase : NSApplicationDelegate - { - private IContainer _container; - - /// - /// Gets or sets the dependency inversion container. - /// - public IContainer Container { get; protected set; } - - /// - public override void DidFinishLaunching(NSNotification notification) - { - base.DidFinishLaunching(notification); - - ComposeDelegate(); - } - - /// - public override void WillTerminate(NSNotification notification) - { - DecomposeDelegate(); - base.WillTerminate(notification); - } - - /// - /// Composes the and registers services. - /// - protected virtual void ComposeDelegate() - { - _container = CreateContainer(); - RegisterServices(_container); - _container.UseDryIocDependencyResolver(); - Container = _container.WithNoMoreRegistrationAllowed(); - } - - /// - /// Returns a new container instance. - /// - /// The container. - protected virtual IContainer CreateContainer() => new Container(); - - /// - /// Decomposes the and registers services. - /// - protected virtual void DecomposeDelegate() => ((Container)Container)?.Dispose(); - - /// - /// Registers services with the instance. - /// - /// The container. - protected abstract void RegisterServices(IContainer container); - } -} diff --git a/src/Controls/Platforms/appkit/UserNotificationExtensions.cs b/src/Controls/Platforms/appkit/UserNotificationExtensions.cs deleted file mode 100644 index ffd9292be..000000000 --- a/src/Controls/Platforms/appkit/UserNotificationExtensions.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Reactive.Linq; -using Foundation; -using static AppKit.NSApplication; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Observable extensions for user notification. - /// - public static class UserNotificationExtensions - { - private static readonly NSUserNotificationCenter UserNotificationCenter; - - static UserNotificationExtensions() - { - UserNotificationCenter = NSUserNotificationCenter.DefaultUserNotificationCenter; - - // Make sure the notification fires even if the app is TopMost - NSUserNotificationCenter.DefaultUserNotificationCenter.ShouldPresentNotification = (c, n) => true; - } - - /// - /// Notifies the user. - /// - /// The source type. - /// The sender. - /// The title. - /// The informative text. - /// The source observable. - public static IObservable NotifyUser(this IObservable sender, string title, string informativeText) - { - var notification = new NSUserNotification - { - Title = title, - InformativeText = informativeText, - DeliveryDate = (NSDate)DateTime.Now, - SoundName = NSUserNotification.NSUserNotificationDefaultSoundName, - HasActionButton = true - }; - - UserNotificationCenter.ScheduleNotification(notification); - return sender; - } - - /// - /// Notifies the user. - /// - /// The source type. - /// The sender. - /// The factory. - /// The source observable. - public static IObservable NotifyUser(this IObservable sender, Func factory) - { - UserNotificationCenter.ScheduleNotification(factory()); - return sender; - } - } -} \ No newline at end of file diff --git a/src/Controls/Platforms/appkit/ViewControllerBase.cs b/src/Controls/Platforms/appkit/ViewControllerBase.cs deleted file mode 100644 index 2687e7303..000000000 --- a/src/Controls/Platforms/appkit/ViewControllerBase.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reactive.Subjects; -using System.Text; -using Foundation; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The type of the view model. - /// - /// - public abstract class ViewControllerBase : ReactiveViewController - where TViewModel : class, IReactiveObject - { - private readonly ISubject _appeared; - private readonly ISubject _disappeared; - private readonly ISubject _appearing; - private readonly ISubject _disappearing; - - /// - /// Initializes a new instance of the class. - /// - protected ViewControllerBase() - { - _appearing = new Subject(); - _disappearing = new Subject(); - _appeared = new Subject(); - _disappeared = new Subject(); - } - - /// - /// Gets the control binding disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - public virtual IObservable Appearing() => _appearing.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - public virtual IObservable Appeared() => _appeared.AsObservable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - public virtual IObservable Disappeared() => _disappeared.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - public virtual IObservable IsDisappearing() => _appearing.AsObservable(); - - /// - public override void ViewWillAppear() - { - base.ViewWillAppear(); - _appearing.OnNext(Unit.Default); - } - - /// - public override void ViewWillDisappear() - { - base.ViewWillDisappear(); - _disappearing.OnNext(Unit.Default); - } - - /// - public override void ViewDidAppear() - { - base.ViewDidAppear(); - _appeared.OnNext(Unit.Default); - } - - /// - public override void ViewDidDisappear() - { - base.ViewDidDisappear(); - _disappeared.OnNext(Unit.Default); - } - - /// - public override void ViewDidLoad() - { - base.ViewDidLoad(); - - Initialize(); - CreateUserInterface(); - BindControls(); - RegisterObservers(); - } - - /// - /// View lifecycle method that initializes the view controller. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected abstract void BindControls(); - - /// - /// View lifecycle method that creates the user interface. - /// - protected abstract void CreateUserInterface(); - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected abstract void RegisterObservers(); - } -} diff --git a/src/Controls/Platforms/appkit/WindowControllerBase.cs b/src/Controls/Platforms/appkit/WindowControllerBase.cs deleted file mode 100644 index 90916a3b4..000000000 --- a/src/Controls/Platforms/appkit/WindowControllerBase.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using AppKit; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The view model type. - public abstract class WindowControllerBase : ReactiveWindowController, IViewFor - where TViewModel : class, IReactiveObject - { - private TViewModel _viewModel; - - /// - /// Gets or sets the view model. - /// - /// - /// The view model. - /// - object IViewFor.ViewModel - { - get => ViewModel; - set => ViewModel = (TViewModel)value; - } - - /// - /// Gets or sets the view model. - /// - /// - /// The view model. - /// - public TViewModel ViewModel - { - get => _viewModel; - set => this.RaiseAndSetIfChanged(ref _viewModel, value); - } - } -} diff --git a/src/Controls/Platforms/apple-common/ControlBase.cs b/src/Controls/Platforms/apple-common/ControlBase.cs deleted file mode 100644 index e3cf66015..000000000 --- a/src/Controls/Platforms/apple-common/ControlBase.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The view model type. - public abstract class ControlBase : ReactiveControl - where TVieModel : class, IReactiveObject - { - } -} diff --git a/src/Controls/Platforms/apple-common/ImageViewBase.cs b/src/Controls/Platforms/apple-common/ImageViewBase.cs deleted file mode 100644 index 992022849..000000000 --- a/src/Controls/Platforms/apple-common/ImageViewBase.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The type of the view model. - /// - public abstract class ImageViewBase : ReactiveImageView - where TViewModel : class, IReactiveObject - { - } -} diff --git a/src/Controls/Platforms/apple-common/ViewBase.cs b/src/Controls/Platforms/apple-common/ViewBase.cs deleted file mode 100644 index 6bb041664..000000000 --- a/src/Controls/Platforms/apple-common/ViewBase.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The view model type. - public abstract class ViewBase : ReactiveView - where TViewModel : class, IReactiveObject - { - } -} diff --git a/src/Controls/Platforms/uikit/AlertViews.cs b/src/Controls/Platforms/uikit/AlertViews.cs deleted file mode 100644 index ec2635109..000000000 --- a/src/Controls/Platforms/uikit/AlertViews.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using GlobalToast; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Alerts. - /// - public static class AlertViews - { - /// - /// Displays a toast message. - /// - /// The ttitle for the toast message. - /// The message to display in the toast. - /// The background color of the toast. - /// The duration to display the toast. - /// The position for the toast to display. - public static void ShowToast(string title, string message, UIColor backgroundColor, double duration = 2.0, ToastPosition position = ToastPosition.Center) => Toast - .MakeToast(message) - .SetTitle(title) - .SetPosition(position) - .SetDuration(duration) - .SetAutoDismiss(true) - .Show(); - - /// - /// Displays a toast message. - /// - /// The title for the toast message. - /// The message to display in the toast. - /// The appearance. - /// The duration to display the toast. - /// The position for the toast to display. - public static void ShowToast(string title, string message, ToastAppearance appearance, double duration = 2.0, ToastPosition position = ToastPosition.Center) => Toast - .MakeToast(message) - .SetTitle(title) - .SetAppearance(appearance) - .SetPosition(position) - .SetDuration(duration) - .SetAutoDismiss(true) - .Show(); - - /// - /// Displays a toast message. - /// - /// The title for the toast message. - /// The message to display in the toast. - /// The appearance. - /// The duration to display the toast. - /// The position for the toast to display. - public static void ShowToast(string title, string message, Func appearance, double duration = 2.0, ToastPosition position = ToastPosition.Center) => Toast - .MakeToast(message) - .SetTitle(title) - .SetAppearance(appearance()) - .SetPosition(position) - .SetDuration(duration) - .SetAutoDismiss(true) - .Show(); - } -} \ No newline at end of file diff --git a/src/Controls/Platforms/uikit/ApplicationDelegateBase.cs b/src/Controls/Platforms/uikit/ApplicationDelegateBase.cs deleted file mode 100644 index 24df9601a..000000000 --- a/src/Controls/Platforms/uikit/ApplicationDelegateBase.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using DryIoc; -using Foundation; -using Splat.DryIoc; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base application delegate implementation. - /// - public abstract class ApplicationDelegateBase : UIApplicationDelegate - { - private IContainer _container; - - /// - /// Gets or sets the dependency inversion container. - /// - public IContainer Container { get; protected set; } - - /// - public override void FinishedLaunching(UIApplication application) - { - base.FinishedLaunching(application); - - ComposeDelegate(); - } - - /// - public override bool FinishedLaunching(UIApplication application, Foundation.NSDictionary launchOptions) - { - ComposeDelegate(); - - return true; - } - - /// - /// Composes the and registers services. - /// - protected virtual void ComposeDelegate() - { - _container = CreateContainer(); - RegisterServices(_container); - _container.UseDryIocDependencyResolver(); - Container = _container.WithNoMoreRegistrationAllowed(); - } - - /// - /// Returns a new container instance. - /// - /// The container. - protected virtual IContainer CreateContainer() => new Container(); - - /// - /// Registers services with the instance. - /// - /// The container. - protected abstract void RegisterServices(IContainer container); - } -} diff --git a/src/Controls/Platforms/uikit/CollectionViewBase.cs b/src/Controls/Platforms/uikit/CollectionViewBase.cs deleted file mode 100644 index 93142a503..000000000 --- a/src/Controls/Platforms/uikit/CollectionViewBase.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using CoreGraphics; -using Foundation; -using ReactiveUI; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base UICollectionView. - /// - /// The view model type. - /// - public abstract class CollectionViewBase : ReactiveCollectionView - where TViewModel : class, IReactiveObject - { - /// - /// Initializes a new instance of the class. - /// - /// The pointer. - protected CollectionViewBase(IntPtr handle) - : base(handle) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The object flag. - protected CollectionViewBase(NSObjectFlag t) - : base(t) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The coder. - protected CollectionViewBase(NSCoder coder) - : base(coder) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The frame. - /// The ui collection view layout. - protected CollectionViewBase(CGRect frame, UICollectionViewLayout layout) - : base(frame, layout) - { - } - } -} diff --git a/src/Controls/Platforms/uikit/CollectionViewCellBase.cs b/src/Controls/Platforms/uikit/CollectionViewCellBase.cs deleted file mode 100644 index 68ff124d4..000000000 --- a/src/Controls/Platforms/uikit/CollectionViewCellBase.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base UICollectionView. - /// - /// The type of the view model. - /// - public abstract class CollectionViewCellBase : ReactiveCollectionViewCell - where TViewModel : class, IReactiveObject - { - } -} diff --git a/src/Controls/Platforms/uikit/CollectionViewControllerBase.cs b/src/Controls/Platforms/uikit/CollectionViewControllerBase.cs deleted file mode 100644 index c82c2c7e8..000000000 --- a/src/Controls/Platforms/uikit/CollectionViewControllerBase.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Foundation; -using ReactiveUI; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The type of the view model. - /// - public abstract class CollectionViewControllerBase : ReactiveCollectionViewController - where TViewModel : class, IReactiveObject - { - /// - /// Initializes a new instance of the class. - /// - protected CollectionViewControllerBase() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The ui collection view layout. - protected CollectionViewControllerBase(UICollectionViewLayout withLayout) - : base(withLayout) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The pointer. - protected CollectionViewControllerBase(IntPtr handle) - : base(handle) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The object flag. - protected CollectionViewControllerBase(NSObjectFlag t) - : base(t) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The coder. - protected CollectionViewControllerBase(NSCoder coder) - : base(coder) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The bundle. - protected CollectionViewControllerBase(string nibName, NSBundle bundle) - : base(nibName, bundle) - { - } - } -} diff --git a/src/Controls/Platforms/uikit/IosBackgroundOperation.cs b/src/Controls/Platforms/uikit/IosBackgroundOperation.cs deleted file mode 100644 index 15adc40da..000000000 --- a/src/Controls/Platforms/uikit/IosBackgroundOperation.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Threading.Tasks; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Background task for iOS. - /// - /// - /// https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-techniques/ios-backgrounding-with-tasks. - /// - public class IosBackgroundOperation : IBackgroundOperation - { - /// - public async Task ExecuteInBackground(Func backgroundTask) - { - nint taskID = UIApplication.SharedApplication.BeginBackgroundTask(() => { }); - - try - { - await backgroundTask.Invoke().ConfigureAwait(false); - } - finally - { - UIApplication.SharedApplication.EndBackgroundTask(taskID); - } - } - - /// - public async Task ExecuteInBackground(Func> backgroundTask) - { - nint taskID = UIApplication.SharedApplication.BeginBackgroundTask(() => { }); - - T result = default(T); - - try - { - result = await backgroundTask.Invoke().ConfigureAwait(false); - } - finally - { - UIApplication.SharedApplication.EndBackgroundTask(taskID); - } - - return result; - } - } -} \ No newline at end of file diff --git a/src/Controls/Platforms/uikit/TableViewBase.cs b/src/Controls/Platforms/uikit/TableViewBase.cs deleted file mode 100644 index 58891e63b..000000000 --- a/src/Controls/Platforms/uikit/TableViewBase.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Reactive.Disposables; -using ReactiveUI; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base reactive . - /// - /// The type of the view model. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - public abstract class TableViewBase : ReactiveTableView - where TViewModel : class, IReactiveObject - { - /// - /// Initializes a new instance of the class. - /// - protected TableViewBase() - { - Initialize(); - BindControls(); - RegisterObservers(); - } - - /// - /// Gets the control bindings disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// View lifecycle method that initializes the view controller. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected abstract void BindControls(); - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected abstract void RegisterObservers(); - } -} \ No newline at end of file diff --git a/src/Controls/Platforms/uikit/TableViewCellBase.cs b/src/Controls/Platforms/uikit/TableViewCellBase.cs deleted file mode 100644 index 81392ac60..000000000 --- a/src/Controls/Platforms/uikit/TableViewCellBase.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive.Disposables; -using ReactiveUI; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base reactive . - /// - /// The type of the view model. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - public abstract class TableViewCellBase : ReactiveTableViewCell - where TViewModel : class, IReactiveObject - { - /// - /// Initializes a new instance of the class. - /// - /// The pointer. - protected TableViewCellBase(IntPtr handle) - : base(handle) - { - Initialize(); - CreateCellInterface(); - BindControls(); - RegisterObservers(); - SetNeedsUpdateConstraints(); - } - - /// - /// Gets the control binding disposables. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - public override void UpdateConstraints() - { - SetupCellConstraints(); - - base.UpdateConstraints(); - } - - /// - /// View lifecycle method that initializes the view controller. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected abstract void BindControls(); - - /// - /// Creates the cell interface. - /// - protected abstract void CreateCellInterface(); - - /// - /// Setups the cell constraints. - /// - protected abstract void SetupCellConstraints(); - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected abstract void RegisterObservers(); - } -} \ No newline at end of file diff --git a/src/Controls/Platforms/uikit/TableViewControllerBase.cs b/src/Controls/Platforms/uikit/TableViewControllerBase.cs deleted file mode 100644 index ab3d00098..000000000 --- a/src/Controls/Platforms/uikit/TableViewControllerBase.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reactive.Subjects; -using System.Text; -using Foundation; -using ReactiveUI; -using UIKit; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base reactive . - /// - /// The type of the view model. - /// - public abstract class TableViewControllerBase : ReactiveTableViewController - where TViewModel : class, IReactiveObject - { - private ISubject _appeared; - private ISubject _disappeared; - private ISubject _appearing; - private ISubject _disappearing; - - /// - /// Initializes a new instance of the class. - /// - protected TableViewControllerBase() - { - } - - /// - /// Gets the bindings disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - public virtual IObservable Appearing() => _appearing.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - public virtual IObservable Appeared() => _appeared.AsObservable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - public virtual IObservable Disappeared() => _disappeared.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - public virtual IObservable Disappearing() => _disappearing.AsObservable(); - - /// - public override void ViewWillAppear(bool animated) - { - base.ViewWillAppear(animated); - _appearing.OnNext(animated); - } - - /// - public override void ViewWillDisappear(bool animated) - { - base.ViewWillDisappear(animated); - _disappearing.OnNext(animated); - } - - /// - public override void ViewDidAppear(bool animated) - { - base.ViewDidAppear(animated); - _appeared.OnNext(animated); - } - - /// - public override void ViewDidDisappear(bool animated) - { - base.ViewDidDisappear(animated); - _disappeared.OnNext(animated); - } - - /// - public override void ViewDidLoad() - { - _appearing = new Subject(); - _disappearing = new Subject(); - _appeared = new Subject(); - _disappeared = new Subject(); - Initialize(); - CreateUserInterface(); - BindControls(); - RegisterObservers(); - LoadTableSource(); - } - - /// - /// View lifecycle method that initializes the view controller. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected abstract void BindControls(); - - /// - /// View lifecycle method that creates the user interface. - /// - protected abstract void CreateUserInterface(); - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected abstract void RegisterObservers(); - - /// - /// Loads the table source. - /// - protected abstract void LoadTableSource(); - } -} \ No newline at end of file diff --git a/src/Controls/Platforms/uikit/ViewControllerBase.cs b/src/Controls/Platforms/uikit/ViewControllerBase.cs deleted file mode 100644 index 5b387a7c7..000000000 --- a/src/Controls/Platforms/uikit/ViewControllerBase.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reactive.Subjects; -using System.Text; -using Foundation; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe -{ - /// - /// Base . - /// - /// The type of the view model. - /// - /// - public abstract class ViewControllerBase : ReactiveViewController - where TViewModel : class, IReactiveObject - { - private readonly ISubject _appeared; - private readonly ISubject _disappeared; - private readonly ISubject _appearing; - private readonly ISubject _disappearing; - - /// - /// Initializes a new instance of the class. - /// - protected ViewControllerBase() - { - _appearing = new Subject(); - _disappearing = new Subject(); - _appeared = new Subject(); - _disappeared = new Subject(); - } - - /// - /// Gets the control binding disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - public virtual IObservable Appearing() => _appearing.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - public virtual IObservable Appeared() => _appeared.AsObservable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - public virtual IObservable Disappeared() => _disappeared.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - public virtual IObservable IsDisappearing() => _appearing.AsObservable(); - - /// - public override void ViewWillAppear(bool animated) - { - base.ViewWillAppear(animated); - _appearing.OnNext(animated); - } - - /// - public override void ViewWillDisappear(bool animated) - { - base.ViewWillDisappear(animated); - _disappearing.OnNext(animated); - } - - /// - public override void ViewDidAppear(bool animated) - { - base.ViewDidAppear(animated); - _appeared.OnNext(animated); - } - - /// - public override void ViewDidDisappear(bool animated) - { - base.ViewDidDisappear(animated); - _disappeared.OnNext(animated); - } - - /// - public override void ViewDidLoad() - { - base.ViewDidLoad(); - - Initialize(); - CreateUserInterface(); - BindControls(); - RegisterObservers(); - } - - /// - /// View lifecycle method that initializes the view controller. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected abstract void BindControls(); - - /// - /// View lifecycle method that creates the user interface. - /// - protected abstract void CreateUserInterface(); - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected abstract void RegisterObservers(); - } -} diff --git a/src/Controls/Rocket.Surgery.Airframe.xml b/src/Controls/Rocket.Surgery.Airframe.xml deleted file mode 100644 index af479dcc4..000000000 --- a/src/Controls/Rocket.Surgery.Airframe.xml +++ /dev/null @@ -1,694 +0,0 @@ - - - - Rocket.Surgery.Airframe - - - - - Indicates that the value of the marked element could be null sometimes, - so checking for null is required before its usage. - - - [CanBeNull] object Test() => null; - - void UseTest() { - var p = Test(); - var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - } - - - - - Indicates that the value of the marked element can never be null. - - - [NotNull] object Foo() { - return null; // Warning: Possible 'null' assignment - } - - - - - Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task - and Lazy classes to indicate that the value of a collection item, of the Task.Result property - or of the Lazy.Value property can never be null. - - - public void Foo([ItemNotNull]List<string> books) - { - foreach (var book in books) { - if (book != null) // Warning: Expression is always true - Console.WriteLine(book.ToUpper()); - } - } - - - - - Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task - and Lazy classes to indicate that the value of a collection item, of the Task.Result property - or of the Lazy.Value property can be null. - - - public void Foo([ItemCanBeNull]List<string> books) - { - foreach (var book in books) - { - // Warning: Possible 'System.NullReferenceException' - Console.WriteLine(book.ToUpper()); - } - } - - - - - Indicates that the marked method builds string by the format pattern and (optional) arguments. - The parameter, which contains the format string, should be given in constructor. The format string - should be in -like form. - - - [StringFormatMethod("message")] - void ShowError(string message, params object[] args) { /* do something */ } - - void Foo() { - ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - } - - - - - Specifies which parameter of an annotated method should be treated as the format string - - - - - Use this annotation to specify a type that contains static or const fields - with values for the annotated property/field/parameter. - The specified type will be used to improve completion suggestions. - - - namespace TestNamespace - { - public class Constants - { - public static int INT_CONST = 1; - public const string STRING_CONST = "1"; - } - - public class Class1 - { - [ValueProvider("TestNamespace.Constants")] public int myField; - public void Foo([ValueProvider("TestNamespace.Constants")] string str) { } - - public void Test() - { - Foo(/*try completion here*/);// - myField = /*try completion here*/ - } - } - } - - - - - Indicates that the function argument should be a string literal and match one - of the parameters of the caller function. For example, ReSharper annotates - the parameter of . - - - void Foo(string param) { - if (param == null) - throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - } - - - - - Indicates that the method is contained in a type that implements - System.ComponentModel.INotifyPropertyChanged interface and this method - is used to notify that some property value changed. - - - The method should be non-static and conform to one of the supported signatures: - - NotifyChanged(string) - NotifyChanged(params string[]) - NotifyChanged{T}(Expression{Func{T}}) - NotifyChanged{T,U}(Expression{Func{T,U}}) - SetProperty{T}(ref T, T, string) - - - - public class Foo : INotifyPropertyChanged { - public event PropertyChangedEventHandler PropertyChanged; - - [NotifyPropertyChangedInvocator] - protected virtual void NotifyChanged(string propertyName) { ... } - - string _name; - - public string Name { - get { return _name; } - set { _name = value; NotifyChanged("LastName"); /* Warning */ } - } - } - - Examples of generated notifications: - - NotifyChanged("Property") - NotifyChanged(() => Property) - NotifyChanged((VM x) => x.Property) - SetProperty(ref myField, value, "Property") - - - - - - Describes dependency between method input and output. - - -

Function Definition Table syntax:

- - FDT ::= FDTRow [;FDTRow]* - FDTRow ::= Input => Output | Output <= Input - Input ::= ParameterName: Value [, Input]* - Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - Value ::= true | false | null | notnull | canbenull - - If the method has a single input parameter, its name could be omitted.
- Using halt (or void/nothing, which is the same) for the method output - means that the method doesn't return normally (throws or terminates the process).
- Value canbenull is only applicable for output parameters.
- You can use multiple [ContractAnnotation] for each FDT row, or use single attribute - with rows separated by semicolon. There is no notion of order rows, all rows are checked - for applicability and applied per each program state tracked by the analysis engine.
-
- - - [ContractAnnotation("=> halt")] - public void TerminationMethod() - - - [ContractAnnotation("null <= param:null")] // reverse condition syntax - public string GetName(string surname) - - - [ContractAnnotation("s:null => true")] - public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - - - // A method that returns null if the parameter is null, - // and not null if the parameter is not null - [ContractAnnotation("null => null; notnull => notnull")] - public object Transform(object data) - - - [ContractAnnotation("=> true, result: notnull; => false, result: null")] - public bool TryParse(string s, out Person result) - - -
- - - Indicates whether the marked element should be localized. - - - [LocalizationRequiredAttribute(true)] - class Foo { - string str = "my string"; // Warning: Localizable string - } - - - - - Indicates that the value of the marked type (or its derivatives) - cannot be compared using '==' or '!=' operators and Equals() - should be used instead. However, using '==' or '!=' for comparison - with null is always permitted. - - - [CannotApplyEqualityOperator] - class NoEquality { } - - class UsesNoEquality { - void Test() { - var ca1 = new NoEquality(); - var ca2 = new NoEquality(); - if (ca1 != null) { // OK - bool condition = ca1 == ca2; // Warning - } - } - } - - - - - When applied to a target attribute, specifies a requirement for any type marked - with the target attribute to implement or inherit specific type or types. - - - [BaseTypeRequired(typeof(IComponent)] // Specify requirement - class ComponentAttribute : Attribute { } - - [Component] // ComponentAttribute requires implementing IComponent interface - class MyComponent : IComponent { } - - - - - Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - so this symbol will not be reported as unused (as well as by other usage inspections). - - - - - Can be applied to attributes, type parameters, and parameters of a type assignable from . - When applied to an attribute, the decorated attribute behaves the same as . - When applied to a type parameter or to a parameter of type , indicates that the corresponding type - is used implicitly. - - - - - Specify the details of implicitly used symbol when it is marked - with or . - - - - Only entity marked with attribute considered used. - - - Indicates implicit assignment to a member. - - - - Indicates implicit instantiation of a type with fixed constructor signature. - That means any unused constructor parameters won't be reported as such. - - - - Indicates implicit instantiation of a type. - - - - Specify what is considered to be used implicitly when marked - with or . - - - - Members of entity marked with attribute are considered used. - - - Entity marked with attribute and all its members considered used. - - - - This attribute is intended to mark publicly available API - which should not be removed and so is treated as used. - - - - - Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - If the parameter is a delegate, indicates that delegate is executed while the method is executed. - If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - - - - - Indicates that a method does not make any observable state changes. - The same as System.Diagnostics.Contracts.PureAttribute. - - - [Pure] int Multiply(int x, int y) => x * y; - - void M() { - Multiply(123, 42); // Waring: Return value of pure method is not used - } - - - - - Indicates that the return value of the method invocation must be used. - - - Methods decorated with this attribute (in contrast to pure methods) might change state, - but make no sense without using their return value.
- Similarly to , this attribute - will help detecting usages of the method when the return value in not used. - Additionally, you can optionally specify a custom message, which will be used when showing warnings, e.g. - [MustUseReturnValue("Use the return value to...")]. -
-
- - - Indicates the type member or parameter of some type, that should be used instead of all other ways - to get the value of that type. This annotation is useful when you have some "context" value evaluated - and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. - - - class Foo { - [ProvidesContext] IBarService _barService = ...; - - void ProcessNode(INode node) { - DoSomething(node, node.GetGlobalServices().Bar); - // ^ Warning: use value of '_barService' field - } - } - - - - - Indicates that a parameter is a path to a file or a folder within a web project. - Path can be relative or absolute, starting from web root (~). - - - - - An extension method marked with this attribute is processed by code completion - as a 'Source Template'. When the extension method is completed over some expression, its source code - is automatically expanded like a template at call site. - - - Template method body can contain valid source code and/or special comments starting with '$'. - Text inside these comments is added as source code when the template is applied. Template parameters - can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - Use the attribute to specify macros for parameters. - - - In this example, the 'forEach' method is a source template available over all values - of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - - [SourceTemplate] - public static void forEach<T>(this IEnumerable<T> xs) { - foreach (var x in xs) { - //$ $END$ - } - } - - - - - - Allows specifying a macro for a parameter of a source template. - - - You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - is defined in the property. When applied on a method, the target - template parameter is defined in the property. To apply the macro silently - for the parameter, set the property value = -1. - - - Applying the attribute on a source template method: - - [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - public static void forEach<T>(this IEnumerable<T> collection) { - foreach (var item in collection) { - //$ $END$ - } - } - - Applying the attribute on a template method parameter: - - [SourceTemplate] - public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /*$ var $x$Id = "$newguid$" + x.ToString(); - x.DoSomething($x$Id); */ - } - - - - - - Allows specifying a macro that will be executed for a source template - parameter when the template is expanded. - - - - - Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - - - If the target parameter is used several times in the template, only one occurrence becomes editable; - other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - - - - - Identifies the target parameter of a source template if the - is applied on a template method. - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC action. If applied to a method, the MVC action name is calculated - implicitly from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area. - Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - an MVC controller. If applied to a method, the MVC controller name is calculated - implicitly from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute - for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute - for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - partial view. If applied to a method, the MVC partial view name is calculated implicitly - from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - - - - - ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template. - Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template. - Use this attribute for custom wrappers similar to - System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC view component. If applied to a method, the MVC view name is calculated implicitly - from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Controller.View(Object). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC view component name. - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC view component view. If applied to a method, the MVC view component view name is default. - - - - - ASP.NET MVC attribute. When applied to a parameter of an attribute, - indicates that this parameter is an MVC action name. - - - [ActionName("Foo")] - public ActionResult Login(string returnUrl) { - ViewBag.ReturnUrl = Url.Action("Foo"); // OK - return RedirectToAction("Bar"); // Error: Cannot resolve action - } - - - - - Razor attribute. Indicates that the marked parameter or method is a Razor section. - Use this attribute for custom wrappers similar to - System.Web.WebPages.WebPageBase.RenderSection(String). - - - - - Indicates how method, constructor invocation, or property access - over collection type affects the contents of the collection. - Use to specify the access type. - - - Using this attribute only makes sense if all collection methods are marked with this attribute. - - - public class MyStringCollection : List<string> - { - [CollectionAccess(CollectionAccessType.Read)] - public string GetFirstString() - { - return this.ElementAt(0); - } - } - class Test - { - public void Foo() - { - // Warning: Contents of the collection is never updated - var col = new MyStringCollection(); - string x = col.GetFirstString(); - } - } - - - - - Provides a value for the to define - how the collection method invocation affects the contents of the collection. - - - - Method does not use or modify content of the collection. - - - Method only reads content of the collection but does not modify it. - - - Method can change content of the collection but does not add new elements. - - - Method can add new elements to the collection. - - - - Indicates that the marked method is assertion method, i.e. it halts the control flow if - one of the conditions is satisfied. To set the condition, mark one of the parameters with - attribute. - - - - - Indicates the condition parameter of the assertion method. The method itself should be - marked by attribute. The mandatory argument of - the attribute is the assertion type. - - - - - Specifies assertion type. If the assertion method argument satisfies the condition, - then the execution continues. Otherwise, execution is assumed to be halted. - - - - Marked parameter should be evaluated to true. - - - Marked parameter should be evaluated to false. - - - Marked parameter should be evaluated to null value. - - - Marked parameter should be evaluated to not null value. - - - - Indicates that the marked method unconditionally terminates control flow execution. - For example, it could unconditionally throw exception. - - - - - Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - .Where). This annotation allows inference of [InstantHandle] annotation for parameters - of delegate type by analyzing LINQ method chains. - - - - - Indicates that IEnumerable passed as a parameter is not enumerated. - Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection. - - - static void ThrowIfNull<T>([NoEnumeration] T v, string n) where T : class - { - // custom check for null but no enumeration - } - - void Foo(IEnumerable<string> values) - { - ThrowIfNull(values, nameof(values)); - var x = values.ToList(); // No warnings about multiple enumeration - } - - - - - Indicates that the marked parameter is a regular expression pattern. - - - - - Prevents the Member Reordering feature from tossing members of the marked class. - - - The attribute must be mentioned in your member reordering patterns. - - - - - XAML attribute. Indicates the type that has ItemsSource property and should be treated - as ItemsControl-derived type, to enable inner items DataContext type resolve. - - - - - XAML attribute. Indicates the property of some BindingBase-derived type, that - is used to bind some item of ItemsControl-derived type. This annotation will - enable the DataContext type resolve for XAML bindings for such properties. - - - Property should have the tree ancestor of the ItemsControl type or - marked with the attribute. - - -
-
diff --git a/src/Controls/Rocket.Surgery.ReactiveUI.xml b/src/Controls/Rocket.Surgery.ReactiveUI.xml deleted file mode 100644 index bd78a9db6..000000000 --- a/src/Controls/Rocket.Surgery.ReactiveUI.xml +++ /dev/null @@ -1,838 +0,0 @@ - - - - Rocket.Surgery.Airframe - - - - - Extension methods associated with the IReactiveObject interface. - - https://github.com/reactiveui/ReactiveUI/blob/master/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs . - - - - Contains the state information about the current status of a Reactive Object. - - The type of the sender of the property changes. - - - - Gets an observable for when a property is changing. - - - - - Gets an observable for when the property has changed. - - - - - Gets a observable when a exception is thrown. - - - - - Raises a property changing event. - - The name of the property that is changing. - - - - Raises a property changed event. - - The name of the property that has changed. - - - - Indicates if we are currently sending change notifications. - - If change notifications are being sent. - - - - Suppress change notifications until the return value is disposed. - - A IDisposable which when disposed will re-enable change notifications. - - - - Are change notifications currently delayed. Used for Observables change notifications only. - - If the change notifications are delayed. - - - - Delay change notifications until the return value is disposed. - - A IDisposable which when disposed will re-enable change notifications. - - - - RaiseAndSetIfChanged fully implements a Setter for a read-write - property on a ReactiveObject, using CallerMemberName to raise the notification - and the ref to the backing field to set the property. - - The type of the This. - The type of the return value. - The raising the notification. - A Reference to the backing field for this - property. - The new value. - The name of the property, usually - automatically provided through the CallerMemberName attribute. - The newly set value, normally discarded. - - - - Use this method in your ReactiveObject classes when creating custom - properties where raiseAndSetIfChanged doesn't suffice. - - The sender type. - The instance of ReactiveObject on which the property has changed. - - A string representing the name of the property that has been changed. - Leave null to let the runtime set to caller member name. - - - - - Use this method in your ReactiveObject classes when creating custom - properties where raiseAndSetIfChanged doesn't suffice. - - The sender type. - The instance of ReactiveObject on which the property has changed. - - A string representing the name of the property that has been changed. - Leave null to let the runtime set to caller member name. - - - - - Filter a list of change notifications, returning the last change for each PropertyName in original order. - - - - - Maintains the state of the extension for an . - - The type of the sender. - https://github.com/reactiveui/ReactiveUI/blob/5359fd8c7ae5fd48896a16c718cd9adc00335cc8/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs#L243-L402 . - - - - - Initializes a new instance of the class. - - The sender. - - - - When this method is called, an object will not fire change - notifications (neither traditional nor Observable notifications) - until the return value is disposed. - If this method is called multiple times it will reference count - and not perform notification until all values returned are disposed. - - An object that, when disposed, reenables change - notifications. - - - - When this method is called, an object will not dispatch change - Observable notifications until the return value is disposed. - When the Disposable it will dispatched all queued notifications. - If this method is called multiple times it will reference count - and not perform notification until all values returned are disposed. - - An object that, when disposed, re-enables Observable change - notifications. - - - - Indicates that the value of the marked element could be null sometimes, - so checking for null is required before its usage. - - - [CanBeNull] object Test() => null; - - void UseTest() { - var p = Test(); - var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - } - - - - - Indicates that the value of the marked element can never be null. - - - [NotNull] object Foo() { - return null; // Warning: Possible 'null' assignment - } - - - - - Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task - and Lazy classes to indicate that the value of a collection item, of the Task.Result property - or of the Lazy.Value property can never be null. - - - public void Foo([ItemNotNull]List<string> books) - { - foreach (var book in books) { - if (book != null) // Warning: Expression is always true - Console.WriteLine(book.ToUpper()); - } - } - - - - - Can be applied to symbols of types derived from IEnumerable as well as to symbols of Task - and Lazy classes to indicate that the value of a collection item, of the Task.Result property - or of the Lazy.Value property can be null. - - - public void Foo([ItemCanBeNull]List<string> books) - { - foreach (var book in books) - { - // Warning: Possible 'System.NullReferenceException' - Console.WriteLine(book.ToUpper()); - } - } - - - - - Indicates that the marked method builds string by the format pattern and (optional) arguments. - The parameter, which contains the format string, should be given in constructor. The format string - should be in -like form. - - - [StringFormatMethod("message")] - void ShowError(string message, params object[] args) { /* do something */ } - - void Foo() { - ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - } - - - - - Specifies which parameter of an annotated method should be treated as the format string - - - - - Use this annotation to specify a type that contains static or const fields - with values for the annotated property/field/parameter. - The specified type will be used to improve completion suggestions. - - - namespace TestNamespace - { - public class Constants - { - public static int INT_CONST = 1; - public const string STRING_CONST = "1"; - } - - public class Class1 - { - [ValueProvider("TestNamespace.Constants")] public int myField; - public void Foo([ValueProvider("TestNamespace.Constants")] string str) { } - - public void Test() - { - Foo(/*try completion here*/);// - myField = /*try completion here*/ - } - } - } - - - - - Indicates that the function argument should be a string literal and match one - of the parameters of the caller function. For example, ReSharper annotates - the parameter of . - - - void Foo(string param) { - if (param == null) - throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - } - - - - - Indicates that the method is contained in a type that implements - System.ComponentModel.INotifyPropertyChanged interface and this method - is used to notify that some property value changed. - - - The method should be non-static and conform to one of the supported signatures: - - NotifyChanged(string) - NotifyChanged(params string[]) - NotifyChanged{T}(Expression{Func{T}}) - NotifyChanged{T,U}(Expression{Func{T,U}}) - SetProperty{T}(ref T, T, string) - - - - public class Foo : INotifyPropertyChanged { - public event PropertyChangedEventHandler PropertyChanged; - - [NotifyPropertyChangedInvocator] - protected virtual void NotifyChanged(string propertyName) { ... } - - string _name; - - public string Name { - get { return _name; } - set { _name = value; NotifyChanged("LastName"); /* Warning */ } - } - } - - Examples of generated notifications: - - NotifyChanged("Property") - NotifyChanged(() => Property) - NotifyChanged((VM x) => x.Property) - SetProperty(ref myField, value, "Property") - - - - - - Describes dependency between method input and output. - - -

Function Definition Table syntax:

- - FDT ::= FDTRow [;FDTRow]* - FDTRow ::= Input => Output | Output <= Input - Input ::= ParameterName: Value [, Input]* - Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - Value ::= true | false | null | notnull | canbenull - - If the method has a single input parameter, its name could be omitted.
- Using halt (or void/nothing, which is the same) for the method output - means that the method doesn't return normally (throws or terminates the process).
- Value canbenull is only applicable for output parameters.
- You can use multiple [ContractAnnotation] for each FDT row, or use single attribute - with rows separated by semicolon. There is no notion of order rows, all rows are checked - for applicability and applied per each program state tracked by the analysis engine.
-
- - - [ContractAnnotation("=> halt")] - public void TerminationMethod() - - - [ContractAnnotation("null <= param:null")] // reverse condition syntax - public string GetName(string surname) - - - [ContractAnnotation("s:null => true")] - public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - - - // A method that returns null if the parameter is null, - // and not null if the parameter is not null - [ContractAnnotation("null => null; notnull => notnull")] - public object Transform(object data) - - - [ContractAnnotation("=> true, result: notnull; => false, result: null")] - public bool TryParse(string s, out Person result) - - -
- - - Indicates whether the marked element should be localized. - - - [LocalizationRequiredAttribute(true)] - class Foo { - string str = "my string"; // Warning: Localizable string - } - - - - - Indicates that the value of the marked type (or its derivatives) - cannot be compared using '==' or '!=' operators and Equals() - should be used instead. However, using '==' or '!=' for comparison - with null is always permitted. - - - [CannotApplyEqualityOperator] - class NoEquality { } - - class UsesNoEquality { - void Test() { - var ca1 = new NoEquality(); - var ca2 = new NoEquality(); - if (ca1 != null) { // OK - bool condition = ca1 == ca2; // Warning - } - } - } - - - - - When applied to a target attribute, specifies a requirement for any type marked - with the target attribute to implement or inherit specific type or types. - - - [BaseTypeRequired(typeof(IComponent)] // Specify requirement - class ComponentAttribute : Attribute { } - - [Component] // ComponentAttribute requires implementing IComponent interface - class MyComponent : IComponent { } - - - - - Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - so this symbol will not be reported as unused (as well as by other usage inspections). - - - - - Can be applied to attributes, type parameters, and parameters of a type assignable from . - When applied to an attribute, the decorated attribute behaves the same as . - When applied to a type parameter or to a parameter of type , indicates that the corresponding type - is used implicitly. - - - - - Specify the details of implicitly used symbol when it is marked - with or . - - - - Only entity marked with attribute considered used. - - - Indicates implicit assignment to a member. - - - - Indicates implicit instantiation of a type with fixed constructor signature. - That means any unused constructor parameters won't be reported as such. - - - - Indicates implicit instantiation of a type. - - - - Specify what is considered to be used implicitly when marked - with or . - - - - Members of entity marked with attribute are considered used. - - - Entity marked with attribute and all its members considered used. - - - - This attribute is intended to mark publicly available API - which should not be removed and so is treated as used. - - - - - Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - If the parameter is a delegate, indicates that delegate is executed while the method is executed. - If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - - - - - Indicates that a method does not make any observable state changes. - The same as System.Diagnostics.Contracts.PureAttribute. - - - [Pure] int Multiply(int x, int y) => x * y; - - void M() { - Multiply(123, 42); // Waring: Return value of pure method is not used - } - - - - - Indicates that the return value of the method invocation must be used. - - - Methods decorated with this attribute (in contrast to pure methods) might change state, - but make no sense without using their return value.
- Similarly to , this attribute - will help detecting usages of the method when the return value in not used. - Additionally, you can optionally specify a custom message, which will be used when showing warnings, e.g. - [MustUseReturnValue("Use the return value to...")]. -
-
- - - Indicates the type member or parameter of some type, that should be used instead of all other ways - to get the value of that type. This annotation is useful when you have some "context" value evaluated - and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. - - - class Foo { - [ProvidesContext] IBarService _barService = ...; - - void ProcessNode(INode node) { - DoSomething(node, node.GetGlobalServices().Bar); - // ^ Warning: use value of '_barService' field - } - } - - - - - Indicates that a parameter is a path to a file or a folder within a web project. - Path can be relative or absolute, starting from web root (~). - - - - - An extension method marked with this attribute is processed by code completion - as a 'Source Template'. When the extension method is completed over some expression, its source code - is automatically expanded like a template at call site. - - - Template method body can contain valid source code and/or special comments starting with '$'. - Text inside these comments is added as source code when the template is applied. Template parameters - can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - Use the attribute to specify macros for parameters. - - - In this example, the 'forEach' method is a source template available over all values - of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - - [SourceTemplate] - public static void forEach<T>(this IEnumerable<T> xs) { - foreach (var x in xs) { - //$ $END$ - } - } - - - - - - Allows specifying a macro for a parameter of a source template. - - - You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - is defined in the property. When applied on a method, the target - template parameter is defined in the property. To apply the macro silently - for the parameter, set the property value = -1. - - - Applying the attribute on a source template method: - - [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - public static void forEach<T>(this IEnumerable<T> collection) { - foreach (var item in collection) { - //$ $END$ - } - } - - Applying the attribute on a template method parameter: - - [SourceTemplate] - public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /*$ var $x$Id = "$newguid$" + x.ToString(); - x.DoSomething($x$Id); */ - } - - - - - - Allows specifying a macro that will be executed for a source template - parameter when the template is expanded. - - - - - Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - - - If the target parameter is used several times in the template, only one occurrence becomes editable; - other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - - - - - Identifies the target parameter of a source template if the - is applied on a template method. - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC action. If applied to a method, the MVC action name is calculated - implicitly from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC area. - Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - an MVC controller. If applied to a method, the MVC controller name is calculated - implicitly from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC Master. Use this attribute - for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC model type. Use this attribute - for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - partial view. If applied to a method, the MVC partial view name is calculated implicitly - from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - - - - - ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC editor template. - Use this attribute for custom wrappers similar to - System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - - - - - ASP.NET MVC attribute. Indicates that the marked parameter is an MVC template. - Use this attribute for custom wrappers similar to - System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC view component. If applied to a method, the MVC view name is calculated implicitly - from the context. Use this attribute for custom wrappers similar to - System.Web.Mvc.Controller.View(Object). - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC view component name. - - - - - ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - is an MVC view component view. If applied to a method, the MVC view component view name is default. - - - - - ASP.NET MVC attribute. When applied to a parameter of an attribute, - indicates that this parameter is an MVC action name. - - - [ActionName("Foo")] - public ActionResult Login(string returnUrl) { - ViewBag.ReturnUrl = Url.Action("Foo"); // OK - return RedirectToAction("Bar"); // Error: Cannot resolve action - } - - - - - Razor attribute. Indicates that the marked parameter or method is a Razor section. - Use this attribute for custom wrappers similar to - System.Web.WebPages.WebPageBase.RenderSection(String). - - - - - Indicates how method, constructor invocation, or property access - over collection type affects the contents of the collection. - Use to specify the access type. - - - Using this attribute only makes sense if all collection methods are marked with this attribute. - - - public class MyStringCollection : List<string> - { - [CollectionAccess(CollectionAccessType.Read)] - public string GetFirstString() - { - return this.ElementAt(0); - } - } - class Test - { - public void Foo() - { - // Warning: Contents of the collection is never updated - var col = new MyStringCollection(); - string x = col.GetFirstString(); - } - } - - - - - Provides a value for the to define - how the collection method invocation affects the contents of the collection. - - - - Method does not use or modify content of the collection. - - - Method only reads content of the collection but does not modify it. - - - Method can change content of the collection but does not add new elements. - - - Method can add new elements to the collection. - - - - Indicates that the marked method is assertion method, i.e. it halts the control flow if - one of the conditions is satisfied. To set the condition, mark one of the parameters with - attribute. - - - - - Indicates the condition parameter of the assertion method. The method itself should be - marked by attribute. The mandatory argument of - the attribute is the assertion type. - - - - - Specifies assertion type. If the assertion method argument satisfies the condition, - then the execution continues. Otherwise, execution is assumed to be halted. - - - - Marked parameter should be evaluated to true. - - - Marked parameter should be evaluated to false. - - - Marked parameter should be evaluated to null value. - - - Marked parameter should be evaluated to not null value. - - - - Indicates that the marked method unconditionally terminates control flow execution. - For example, it could unconditionally throw exception. - - - - - Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - .Where). This annotation allows inference of [InstantHandle] annotation for parameters - of delegate type by analyzing LINQ method chains. - - - - - Indicates that IEnumerable passed as a parameter is not enumerated. - Use this annotation to suppress the 'Possible multiple enumeration of IEnumerable' inspection. - - - static void ThrowIfNull<T>([NoEnumeration] T v, string n) where T : class - { - // custom check for null but no enumeration - } - - void Foo(IEnumerable<string> values) - { - ThrowIfNull(values, nameof(values)); - var x = values.ToList(); // No warnings about multiple enumeration - } - - - - - Indicates that the marked parameter is a regular expression pattern. - - - - - Prevents the Member Reordering feature from tossing members of the marked class. - - - The attribute must be mentioned in your member reordering patterns. - - - - - XAML attribute. Indicates the type that has ItemsSource property and should be treated - as ItemsControl-derived type, to enable inner items DataContext type resolve. - - - - - XAML attribute. Indicates the property of some BindingBase-derived type, that - is used to bind some item of ItemsControl-derived type. This annotation will - enable the DataContext type resolve for XAML bindings for such properties. - - - Property should have the tree ancestor of the ItemsControl type or - marked with the attribute. - - -
-
diff --git a/src/Core/Connectivity/ConnectionProfile.cs b/src/Core/Connectivity/ConnectionProfile.cs new file mode 100644 index 000000000..645e340ab --- /dev/null +++ b/src/Core/Connectivity/ConnectionProfile.cs @@ -0,0 +1,11 @@ +namespace Rocket.Surgery.Airframe.Connectivity +{ + public enum ConnectionProfile + { + Unknown = 0, + Bluetooth = 1, + Cellular = 2, + Ethernet = 3, + WiFi = 4 + } +} \ No newline at end of file diff --git a/src/Core/Connectivity/INetworkState.cs b/src/Core/Connectivity/INetworkState.cs new file mode 100644 index 000000000..665d5d0ba --- /dev/null +++ b/src/Core/Connectivity/INetworkState.cs @@ -0,0 +1,56 @@ +using System; +using System.Reactive.Linq; + +namespace Rocket.Surgery.Airframe.Connectivity +{ + /// + /// Interface representing the Network Connectivity. + /// + public interface INetworkState : IObservable + { + /// + /// Gets an observable sequence notifying if the device has connectivity. + /// + /// + IObservable HasSignal() => + this + .Select(changedEvent => changedEvent.HasSignal()) + .DistinctUntilChanged() + .Publish() + .RefCount(); + + /// + /// Gets an observable sequence notifying that signal has degraded. + /// + /// A value indicating the signal is degraded. + IObservable SignalDegraded() => + this + .DistinctUntilChanged(changedEvent => changedEvent.NetworkAccess) + .Select(changedEvent => changedEvent.Degraded()) + .DistinctUntilChanged() + .Publish() + .RefCount(); + + /// + /// Gets an observable sequence notifying if the device has connectivity. + /// + /// + IObservable WhereHasSignal() => + this + .Where(changedEvent => changedEvent.HasSignal()) + .DistinctUntilChanged() + .Publish() + .RefCount(); + + /// + /// Gets an observable sequence notifying if the device has a signal. + /// + /// + IObservable WhereHasNoSignal() => + this + .Where(changedEvent => !changedEvent.HasSignal()) + .DistinctUntilChanged() + .Publish() + .RefCount(); + } +} \ No newline at end of file diff --git a/src/Core/Connectivity/NetworkAccess.cs b/src/Core/Connectivity/NetworkAccess.cs new file mode 100644 index 000000000..6b9ce5229 --- /dev/null +++ b/src/Core/Connectivity/NetworkAccess.cs @@ -0,0 +1,11 @@ +namespace Rocket.Surgery.Airframe.Connectivity +{ + public enum NetworkAccess + { + Unknown = 0, + None = 1, + Local = 2, + ConstrainedInternet = 3, + Internet = 4 + } +} \ No newline at end of file diff --git a/src/Core/Connectivity/NetworkStateChangedEvent.cs b/src/Core/Connectivity/NetworkStateChangedEvent.cs new file mode 100644 index 000000000..0c9ba378b --- /dev/null +++ b/src/Core/Connectivity/NetworkStateChangedEvent.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Rocket.Surgery.Airframe.Connectivity +{ + public class NetworkStateChangedEvent : EventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public NetworkStateChangedEvent(NetworkAccess access, params ConnectionProfile[] connectionProfiles) + { + NetworkAccess = access; + ConnectionProfiles = connectionProfiles; + } + + /// + /// Initializes a new instance of the class. + /// + /// The current network access. + /// + public NetworkStateChangedEvent(NetworkAccess access, IEnumerable connectionProfiles) + : this(access, connectionProfiles.ToArray()) { } + + public NetworkAccess NetworkAccess { get; } + + public IReadOnlyCollection ConnectionProfiles { get; } + + public bool HasSignal() => HasValidProfile() && HasNetworkAccess(); + + /// + /// Determines if the signal is degraded. + /// + /// + public bool Degraded() => NetworkAccess > NetworkAccess.None || ContainsProfile(ConnectionProfile.Unknown); + + /// + /// Determines if this instance has a valid connection profile. + /// + /// A value indicating a valid profile exists. + public bool HasValidProfile() => ContainsProfile( + ConnectionProfile.Bluetooth, + ConnectionProfile.Cellular, + ConnectionProfile.Ethernet, + ConnectionProfile.WiFi); + + /// + public override string ToString() => $"{nameof(NetworkAccess)}: {NetworkAccess}, " + + $"{nameof(ConnectionProfiles)}: [{string.Join(", ", ConnectionProfiles)}]"; + + private bool HasNetworkAccess() => NetworkAccess is NetworkAccess.Internet or NetworkAccess.Local or NetworkAccess.ConstrainedInternet; + + private bool ContainsProfile(params ConnectionProfile[] profiles) => + ConnectionProfiles.Join( + profiles, + instanceProfile => instanceProfile, + argumentProfile => argumentProfile, + (instanceProfile, argumentProfile) => instanceProfile == argumentProfile) + .Any(truth => truth); + } +} \ No newline at end of file diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index deb95ea20..276ca411a 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -1,11 +1,10 @@ - netstandard2.0;net6.0 + net8.0 Rocket.Surgery.Airframe.Core Rocket.Surgery.Airframe.Core Rocket.Surgery.Airframe - latest Abstractions and base implementations for Airframe. diff --git a/src/Core/Navigation/ArgumentExtensions.cs b/src/Core/Navigation/ArgumentExtensions.cs new file mode 100644 index 000000000..2350d7650 --- /dev/null +++ b/src/Core/Navigation/ArgumentExtensions.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using JetBrains.Annotations; + +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Extension methods for Navigation or Dialog parameters. +/// +/// Taken from https://github.com/PrismLibrary/Prism/blob/5b296e1d5cac8e43e8457d0241e219405b57ed47/src/Prism.Core/Common/ParametersBase.cs#L1C1-L199C2. +[EditorBrowsable(EditorBrowsableState.Never)] +public static class ArgumentExtensions +{ + /// + /// Searches for . + /// + /// The type of the parameter to return. + /// A collection of parameters to search. + /// The key of the parameter to find. + /// A matching value of if it exists. + [EditorBrowsable(EditorBrowsableState.Never)] + public static T? GetValue(this IEnumerable> parameters, string key) => + (T?)GetValue(parameters, key, typeof(T)); + + /// + /// Searches for value referenced by . + /// + /// A collection of parameters to search. + /// The key of the parameter to find. + /// The type of the parameter to return. + /// A matching value of if it exists. + /// Unable to convert the value of Type. + [EditorBrowsable(EditorBrowsableState.Never)] + public static object? GetValue(this IEnumerable> parameters, string key, Type type) + { + foreach (var kvp in parameters) + { + if (string.Compare(kvp.Key, key, StringComparison.Ordinal) == 0) + { + if (TryGetValueInternal(kvp, type, out var value)) + { + return value; + } + + throw new InvalidCastException($"Unable to convert the value of Type '{kvp.Value.GetType().FullName}' to '{type.FullName}' for the key '{key}' "); + } + } + + return GetDefault(type); + } + + /// + /// Searches for value referenced by . + /// + /// The type of the parameter to return. + /// A collection of parameters to search. + /// The key of the parameter to find. + /// The value of parameter to return. + /// Success if value is found; otherwise returns false. + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool TryGetValue(this IEnumerable> parameters, string key, out T value) + { + var type = typeof(T); + + foreach (var kvp in parameters) + { + if (string.Compare(kvp.Key, key, StringComparison.Ordinal) == 0) + { + var success = TryGetValueInternal(kvp, typeof(T), out object valueAsObject); + value = (T)valueAsObject; + return success; + } + } + + value = default; + return false; + } + + /// + /// Searches for value referenced by . + /// + /// The type of the parameter to return. + /// A collection of parameters to search. + /// The key of the parameter to find. + /// An IEnumerable{T} of all the values referenced by key. + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable GetValues(this IEnumerable> parameters, string key) + { + List values = new(); + var type = typeof(T); + + foreach (var kvp in parameters) + { + if (string.Compare(kvp.Key, key, StringComparison.Ordinal) == 0) + { + TryGetValueInternal(kvp, type, out var value); + values.Add((T)value); + } + } + + return values.AsEnumerable(); + } + + /// + /// Checks to see if key exists in parameter collection. + /// + /// IEnumerable to search. + /// The key to search the for existence. + /// true if key exists; false otherwise. + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool ContainsKey(this IEnumerable> parameters, string key) => + parameters.Any(x => string.Compare(x.Key, key, StringComparison.Ordinal) == 0); + + private static bool TryGetValueInternal(KeyValuePair kvp, Type type, out object value) + { + value = GetDefault(type); + var success = false; + if (kvp.Value == null) + { + success = true; + } + else if (kvp.Value.GetType() == type) + { + success = true; + value = kvp.Value; + } + else if (type.IsInstanceOfType(kvp.Value)) + { + success = true; + value = kvp.Value; + } + else if (type.IsEnum) + { + var valueAsString = kvp.Value.ToString(); + if (Enum.IsDefined(type, valueAsString)) + { + success = true; + value = Enum.Parse(type, valueAsString); + } + else if (int.TryParse(valueAsString, out var numericValue)) + { + success = true; + value = Enum.ToObject(type, numericValue); + } + } + + if (!success && type.GetInterface("System.IConvertible") != null) + { + success = true; + value = Convert.ChangeType(kvp.Value, type); + } + + return success; + } + + [CanBeNull] + private static object? GetDefault(Type type) + { + if (type.IsValueType) + { + return Activator.CreateInstance(type); + } + + return null; + } +} \ No newline at end of file diff --git a/src/Core/Navigation/Arguments.cs b/src/Core/Navigation/Arguments.cs new file mode 100644 index 000000000..d6f616ed8 --- /dev/null +++ b/src/Core/Navigation/Arguments.cs @@ -0,0 +1,6 @@ +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Represents a basic argument. +/// +public class Arguments(string query) : ArgumentsBase(query); \ No newline at end of file diff --git a/src/Core/Navigation/ArgumentsBase.cs b/src/Core/Navigation/ArgumentsBase.cs new file mode 100644 index 000000000..12bd72f57 --- /dev/null +++ b/src/Core/Navigation/ArgumentsBase.cs @@ -0,0 +1,203 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; + +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Represents an argument for extension. +/// +/// Taken from https://github.com/PrismLibrary/Prism/blob/5b296e1d5cac8e43e8457d0241e219405b57ed47/src/Prism.Core/Common/ParametersBase.cs#L1C1-L199C2. +public abstract class ArgumentsBase : IArguments +{ + /// + /// Initializes a new instance of the class. + /// + /// Query string to be parsed. + protected ArgumentsBase(string query) + { + if (!string.IsNullOrWhiteSpace(query)) + { + int num = query.Length; + for (int i = ((query.Length > 0) && (query[0] == '?')) + ? 1 + : 0; + i < num; + i++) + { + int startIndex = i; + int num4 = -1; + while (i < num) + { + char ch = query[i]; + if (ch == '=') + { + if (num4 < 0) + { + num4 = i; + } + } + else if (ch == '&') + { + break; + } + + i++; + } + + string key = null; + string value; + if (num4 >= 0) + { + key = query.Substring(startIndex, num4 - startIndex); + value = query.Substring(num4 + 1, (i - num4) - 1); + } + else + { + value = query.Substring(startIndex, i - startIndex); + } + + if (key != null) + { + Add(Uri.UnescapeDataString(key), Uri.UnescapeDataString(value)); + } + } + } + } + + /// + /// Gets the count, or number, of parameters in collection. + /// + public int Count => _entries.Count; + + /// + /// Gets an IEnumerable of the Keys in the collection. + /// + public IEnumerable Keys => + _entries.Select(x => x.Key); + + /// + /// Searches Parameter collection and returns value if Collection contains key. + /// Otherwise returns null. + /// + /// The key for the value to be returned. + /// The value of the parameter referenced by the key; otherwise null. + public object this[string key] + { + get + { + foreach (var entry in _entries) + { + if (string.Compare(entry.Key, key, StringComparison.Ordinal) == 0) + { + return entry.Value; + } + } + + return null; + } + } + + /// + /// Adds the key and value to the parameters collection. + /// + /// The key to reference this value in the parameters collection. + /// The value of the parameter to store. + public void Add(string key, object value) => + _entries.Add(new KeyValuePair(key, value)); + + /// + /// Checks collection for presence of key. + /// + /// The key to check in the collection. + /// true if key exists; else returns false. + public bool ContainsKey(string key) => + _entries.ContainsKey(key); + + /// + /// Gets an enumerator for the KeyValuePairs in parameter collection. + /// + /// Enumerator. + public IEnumerator> GetEnumerator() => + _entries.GetEnumerator(); + + /// + /// Returns the value of the member referenced by key. + /// + /// The type of object to be returned. + /// The key for the value to be returned. + /// Returns a matching parameter of if one exists in the Collection. + public T GetValue(string key) => + _entries.GetValue(key); + + /// + /// Returns an IEnumerable of all parameters. + /// + /// The type for the values to be returned. + /// The key for the values to be returned. + /// Returns a IEnumerable of all the instances of type . + public IEnumerable GetValues(string key) => + _entries.GetValues(key); + + /// + /// Checks to see if the parameter collection contains the value. + /// + /// The type for the values to be returned. + /// The key for the value to be returned. + /// Value of the returned parameter if it exists. + /// Returns a value indicating if the value exists. + public bool TryGetValue(string key, out T value) => + _entries.TryGetValue(key, out value); + + /// + IEnumerator IEnumerable.GetEnumerator() => + GetEnumerator(); + + /// + /// Converts parameter collection to a parameter string. + /// + /// A string representation of the parameters. + public override string ToString() + { + var queryBuilder = new StringBuilder(); + + if (_entries.Count > 0) + { + queryBuilder.Append('?'); + var first = true; + + foreach (var kvp in _entries) + { + if (!first) + { + queryBuilder.Append('&'); + } + else + { + first = false; + } + + queryBuilder.Append(Uri.EscapeDataString(kvp.Key)) + .Append('=') + .Append(Uri.EscapeDataString(kvp.Value != null + ? kvp.Value.ToString() + : string.Empty)); + } + } + + return queryBuilder.ToString(); + } + + /// + /// Adds a collection of parameters to the local parameter list. + /// + /// An IEnumerable of KeyValuePairs to add to the current parameter list. + [EditorBrowsable(EditorBrowsableState.Never)] + public void FromParameters(IEnumerable> parameters) => + _entries.AddRange(parameters); + + private readonly List> _entries = []; +} \ No newline at end of file diff --git a/src/Core/Navigation/IArguments.cs b/src/Core/Navigation/IArguments.cs new file mode 100644 index 000000000..b815cb3ef --- /dev/null +++ b/src/Core/Navigation/IArguments.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; + +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Interface representing values passed into the method execution. +/// +public interface IArguments : IEnumerable> +{ + /// + /// Gets the number of parameters contained in the . + /// + int Count { get; } + + /// + /// Gets a collection containing the keys in the . + /// + IEnumerable Keys { get; } + + /// + /// Gets the parameter associated with the specified key (legacy). + /// + /// The key of the parameter to get. + /// A matching value if it exists. + object this[string key] { get; } + + /// + /// Adds the specified key and value to the parameter collection. + /// + /// The key of the parameter to add. + /// The value of the parameter to add. + void Add(string key, object value); + + /// + /// Determines whether the contains the specified . + /// + /// The key to search the parameters for existence. + /// true if the contains a parameter with the specified key; otherwise, false. + bool ContainsKey(string key); + + /// + /// Gets the parameter associated with the specified . + /// + /// The type of the parameter to get. + /// The key of the parameter to find. + /// A matching value of if it exists. + T GetValue(string key); + + /// + /// Gets the parameter associated with the specified . + /// + /// The type of the parameter to get. + /// The key of the parameter to find. + /// An of all the values referenced by key. + IEnumerable GetValues(string key); + + /// + /// Gets the parameter associated with the specified . + /// + /// The type of the parameter to get. + /// The key of the parameter to get. + /// + /// When this method returns, contains the parameter associated with the specified key, + /// if the key is found; otherwise, the default value for the type of the value parameter. + /// + /// true if the contains a parameter with the specified key; otherwise, false. + bool TryGetValue(string key, out T value); +} \ No newline at end of file diff --git a/src/Core/Navigation/IDestructible.cs b/src/Core/Navigation/IDestructible.cs new file mode 100644 index 000000000..06f04c2fa --- /dev/null +++ b/src/Core/Navigation/IDestructible.cs @@ -0,0 +1,12 @@ +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Interface that represents an element that needs to be destroyed. +/// +public interface IDestructible +{ + /// + /// Tear down resources. + /// + void Destroy(); +} \ No newline at end of file diff --git a/src/Core/Navigation/IInitialize.cs b/src/Core/Navigation/IInitialize.cs new file mode 100644 index 000000000..ed86aad27 --- /dev/null +++ b/src/Core/Navigation/IInitialize.cs @@ -0,0 +1,13 @@ +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Interface representing an initializeable thing™. +/// +public interface IInitialize +{ + /// + /// Executed when an element is created. + /// + /// The arguments. + void OnInitialize(IArguments arguments); +} \ No newline at end of file diff --git a/src/Core/Navigation/INavigated.cs b/src/Core/Navigation/INavigated.cs new file mode 100644 index 000000000..4fc4ee24d --- /dev/null +++ b/src/Core/Navigation/INavigated.cs @@ -0,0 +1,19 @@ +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Interface representing a thing™ that can be navigated to and from. +/// +public interface INavigated +{ + /// + /// Executed when an element is navigated to. + /// + /// The arguments. + void OnNavigatedTo(IArguments arguments); + + /// + /// Executed when an element is navigated from. + /// + /// The arguments. + void OnNavigatedFrom(IArguments arguments); +} \ No newline at end of file diff --git a/src/Core/Navigation/INavigator.cs b/src/Core/Navigation/INavigator.cs new file mode 100644 index 000000000..b34c29f56 --- /dev/null +++ b/src/Core/Navigation/INavigator.cs @@ -0,0 +1,52 @@ +using System.Threading.Tasks; + +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Represents a simple navigator. +/// +public interface INavigator +{ + /// + /// Pushes a route onto the navigation. + /// + /// The route name. + /// A completion notification. + Task Push(string name); + + /// + /// Pushes a route onto the navigation. + /// + /// The view model type. + /// A completion notification. + Task Push(); + + /// + /// Pushes a route onto the navigation. + /// + /// The route name. + /// The arguments. + /// A completion notification. + Task Push(string name, IArguments arguments); + + /// + /// Pushes a route onto the navigation. + /// + /// The arguments. + /// The view model type. + /// A completion notification. + Task Push(IArguments arguments); + + /// + /// Pops a route off the navigation. + /// + /// A completion notification. + Task Pop(); + + /// + /// Pops a route off the navigation. + /// + /// The arguments. + /// A completion notification. + Task Pop(IArguments arguments); +} \ No newline at end of file diff --git a/src/Core/Navigation/NavigationException.cs b/src/Core/Navigation/NavigationException.cs new file mode 100644 index 000000000..d11c7d9c5 --- /dev/null +++ b/src/Core/Navigation/NavigationException.cs @@ -0,0 +1,8 @@ +using System; + +namespace Rocket.Surgery.Airframe.Navigation; + +/// +/// Represents a navigation error. +/// +public sealed class NavigationException : Exception; \ No newline at end of file diff --git a/src/Data/Data.csproj b/src/Data/Data.csproj index f1b1cce10..44a95ebc7 100644 --- a/src/Data/Data.csproj +++ b/src/Data/Data.csproj @@ -1,18 +1,11 @@ - netstandard2.0;net6.0 + net8.0 Rocket.Surgery.Airframe.Data Rocket.Surgery.Airframe.Data - - bin\Debug\Rocket.Surgery.Airframe.Data.xml - - - - bin\Release\Rocket.Surgery.Airframe.Data.xml - diff --git a/src/Forms/ExceptionHandler.cs b/src/Forms/ExceptionHandler.cs deleted file mode 100644 index cd9507526..000000000 --- a/src/Forms/ExceptionHandler.cs +++ /dev/null @@ -1,19 +0,0 @@ -using ReactiveUI; -using Rocket.Surgery.Airframe.Exceptions; - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// Represents the default exception handler. - /// - public class ExceptionHandler : ExceptionHandlerBase - { - /// - /// Initializes a new instance of the class. - /// - public ExceptionHandler() - : base(RxApp.MainThreadScheduler) - { - } - } -} \ No newline at end of file diff --git a/src/Forms/Forms.csproj b/src/Forms/Forms.csproj deleted file mode 100644 index f0e89f3c9..000000000 --- a/src/Forms/Forms.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - netstandard2.0;net6.0 - Rocket.Surgery.Airframe.Forms - Rocket.Surgery.Airframe.Forms - Rocket.Surgery.Airframe.Forms - latest - ReactiveUI base abstractions for Xamarin Forms. - - - - bin\Debug\Rocket.Surgery.Airframe.Forms.xml - - - - bin\Release\Rocket.Surgery.Airframe.Forms.xml - - - - - - - - - - - diff --git a/src/Forms/Forms.csproj.DotSettings b/src/Forms/Forms.csproj.DotSettings deleted file mode 100644 index 0846febe1..000000000 --- a/src/Forms/Forms.csproj.DotSettings +++ /dev/null @@ -1,5 +0,0 @@ - - True - True - True - True \ No newline at end of file diff --git a/src/Forms/Pages/ContentPageBase.cs b/src/Forms/Pages/ContentPageBase.cs deleted file mode 100644 index 9b698d730..000000000 --- a/src/Forms/Pages/ContentPageBase.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reactive.Subjects; -using ReactiveUI; -using ReactiveUI.XamForms; -using Splat; -using Xamarin.Forms; - -[assembly: XmlnsPrefix("https://schemas.rocketsurgeonsguild.com/xaml/airframe/forms", "airframe")] -[assembly: XmlnsDefinition("https://schemas.rocketsurgeonsguild.com/xaml/airframe/forms", "Rocket.Surgery.Airframe.Forms")] - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// Base ReactiveUI . - /// - /// The type of the view model. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - public abstract class ContentPageBase : ReactiveContentPage, IEnableLogger - where TViewModel : class, IReactiveObject - { - private readonly ISubject _isAppearing; - private readonly ISubject _isDisappearing; - - /// - /// Initializes a new instance of the class. - /// - [SuppressMessage("ReSharper", "VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - protected ContentPageBase() - { - _isAppearing = new Subject(); - _isDisappearing = new Subject(); - Logger = this.Log(); - Initialize(); - BindControls(); - RegisterObservers(); - } - - /// - /// Gets or sets the . - /// - public IFullLogger Logger { get; protected set; } - - /// - /// Gets the view bindings disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - protected virtual IObservable IsAppearing => _isAppearing.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - protected virtual IObservable IsDisappearing => _isDisappearing.AsObservable(); - - /// - protected override void OnAppearing() - { - _isAppearing.OnNext(Unit.Default); - base.OnAppearing(); - } - - /// - protected override void OnDisappearing() - { - _isDisappearing.OnNext(Unit.Default); - base.OnDisappearing(); - } - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected virtual void RegisterObservers() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected virtual void BindControls() - { - } - - /// - /// View lifecycle method that initializes the view. - /// - protected virtual void Initialize() - { - } - } -} diff --git a/src/Forms/SchedulerProvider.cs b/src/Forms/SchedulerProvider.cs deleted file mode 100644 index 1ce69be86..000000000 --- a/src/Forms/SchedulerProvider.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reactive.Concurrency; -using ReactiveUI; - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// A for Xamarin.Forms. - /// - public sealed class SchedulerProvider : ISchedulerProvider - { - /// - /// Initializes a new instance of the class. - /// - public SchedulerProvider() - : this(RxApp.MainThreadScheduler, RxApp.TaskpoolScheduler) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The main scheduler. - /// The background scheduler. - public SchedulerProvider(IScheduler mainThread, IScheduler backgroundThread) - { - UserInterfaceThread = mainThread; - BackgroundThread = backgroundThread; - } - - /// - public IScheduler UserInterfaceThread { get; } - - /// - public IScheduler BackgroundThread { get; } - } -} \ No newline at end of file diff --git a/src/Forms/Views/ContentViewBase.cs b/src/Forms/Views/ContentViewBase.cs deleted file mode 100644 index ac5a283b5..000000000 --- a/src/Forms/Views/ContentViewBase.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Reactive.Disposables; -using ReactiveUI; -using ReactiveUI.XamForms; -using Splat; - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// Base ReactiveUI . - /// - /// The type of the view model. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - public abstract class ContentViewBase : ReactiveContentView, IEnableLogger - where TViewModel : class, IReactiveObject - { - /// - /// Initializes a new instance of the class. - /// - [SuppressMessage("ReSharper", "VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - protected ContentViewBase() - { - Logger = this.Log(); - Initialize(); - BindControls(); - RegisterObservers(); - } - - /// - /// Gets or sets the . - /// - public IFullLogger Logger { get; protected set; } - - /// - /// Gets the view bindings disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected virtual void RegisterObservers() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected virtual void BindControls() - { - } - - /// - /// View lifecycle method that initializes the view. - /// - protected virtual void Initialize() - { - } - } -} diff --git a/src/Forms/Views/ReactiveCollectionView.cs b/src/Forms/Views/ReactiveCollectionView.cs deleted file mode 100644 index 9d3e5dd73..000000000 --- a/src/Forms/Views/ReactiveCollectionView.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// This is a that provides observable sequences around events. - /// (i.e. you can call RaiseAndSetIfChanged). - /// - /// - public class ReactiveCollectionView : CollectionView - { - /// - /// Initializes a new instance of the class. - /// - /// Type of the cell. - public ReactiveCollectionView(Type cellType) => ItemTemplate = new DataTemplate(cellType); - - /// - /// Initializes a new instance of the class. - /// - /// The load template. - public ReactiveCollectionView(Func loadTemplate) => ItemTemplate = new DataTemplate(loadTemplate); - } -} \ No newline at end of file diff --git a/src/Forms/Views/ReactiveListView.cs b/src/Forms/Views/ReactiveListView.cs deleted file mode 100644 index 3ad09ad63..000000000 --- a/src/Forms/Views/ReactiveListView.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using ReactiveUI; -using Xamarin.Forms; - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// This is a that provides observable sequences around events. - /// (i.e. you can call RaiseAndSetIfChanged). - /// - /// - /// - public class ReactiveListView : ListView - { - /// - /// Initializes a new instance of the class. - /// - /// Type of the cell. - /// The list view caching strategy. - public ReactiveListView(Type cellType, ListViewCachingStrategy listViewCachingStrategy = ListViewCachingStrategy.RecycleElement) - : base(listViewCachingStrategy) => ItemTemplate = new DataTemplate(cellType); - - /// - /// Initializes a new instance of the class. - /// - /// The load template. - /// The list view caching strategy. - public ReactiveListView(Func loadTemplate, ListViewCachingStrategy listViewCachingStrategy = ListViewCachingStrategy.RecycleElement) - : base(listViewCachingStrategy) => ItemTemplate = new DataTemplate(loadTemplate); - - /// - /// Initializes a new instance of the class. - /// - /// The list view caching strategy. - public ReactiveListView(ListViewCachingStrategy listViewCachingStrategy = ListViewCachingStrategy.RecycleElement) - : base(listViewCachingStrategy) - { - } - - /// - /// Initializes a new instance of the class. - /// - public ReactiveListView() - : this(ListViewCachingStrategy.RecycleElement) - { - } - } -} diff --git a/src/Forms/Views/ViewCellBase.cs b/src/Forms/Views/ViewCellBase.cs deleted file mode 100644 index 2785942cf..000000000 --- a/src/Forms/Views/ViewCellBase.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Reactive.Disposables; -using ReactiveUI; -using ReactiveUI.XamForms; -using Splat; - -namespace Rocket.Surgery.Airframe.Forms -{ - /// - /// Base ReactiveUI . - /// - /// The type of the view model. - /// - [SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - public abstract class ViewCellBase : ReactiveViewCell, IEnableLogger - where TViewModel : class, IReactiveObject - { - /// - /// Initializes a new instance of the class. - /// - [SuppressMessage("ReSharper", "VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - protected ViewCellBase() - { - Logger = this.Log(); - Initialize(); - BindControls(); - RegisterObservers(); - } - - /// - /// Gets or sets the . - /// - public IFullLogger Logger { get; protected set; } - - /// - /// Gets the view cell bindings. - /// - protected CompositeDisposable ViewCellBindings { get; } = new CompositeDisposable(); - - /// - /// Releases unmanaged and - optionally - managed resources. - /// - public void Dispose() => Dispose(true); - - /// - /// View lifecycle method that initializes the view. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected virtual void BindControls() - { - } - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected virtual void RegisterObservers() - { - } - - /// - /// 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 (disposing) - { - ViewCellBindings?.Dispose(); - } - } - } -} diff --git a/src/MicrosoftDependencyInjection/MicrosoftDependencyInjection.csproj b/src/MicrosoftDependencyInjection/MicrosoftDependencyInjection.csproj index 69188ea37..820656b91 100644 --- a/src/MicrosoftDependencyInjection/MicrosoftDependencyInjection.csproj +++ b/src/MicrosoftDependencyInjection/MicrosoftDependencyInjection.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net6.0 + net8.0 enable Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection diff --git a/src/Popup/Popup.csproj b/src/Popup/Popup.csproj deleted file mode 100644 index 3a51c8bef..000000000 --- a/src/Popup/Popup.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - netstandard2.0 - Rocket.Surgery.Airframe.Popup - Rocket.Surgery.Airframe.Popup - latest - Rocket.Surgery.Airframe.Popup - ReactiveUI base abstractions for Rg.Plugins.Popup - - - - bin\Debug\Rocket.Surgery.Airframe.Popup.xml - - - - bin\Release\Rocket.Surgery.Airframe.Popup.xml - - - - - - - - diff --git a/src/Popup/PopupPageBase.cs b/src/Popup/PopupPageBase.cs deleted file mode 100644 index c38df8f0a..000000000 --- a/src/Popup/PopupPageBase.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reactive.Subjects; -using ReactiveUI; -using Sextant; -using Sextant.Plugins.Popup; -using Xamarin.Forms; - -[assembly: XmlnsPrefix("https://schemas.rocketsurgeonsguild.com/xaml/airframe/popup", "popup")] -[assembly: XmlnsDefinition("https://schemas.rocketsurgeonsguild.com/xaml/airframe/popup", "Rocket.Surgery.Airframe.Popup")] - -[assembly: SuppressMessage("Microsoft.Usage", "CA2214:VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - -namespace Rocket.Surgery.Airframe.Popup -{ - /// - /// Base ReactiveUI . - /// - /// The type of the view model. - /// - public abstract class PopupPageBase : SextantPopupPage, IDisposable - where TViewModel : class, IReactiveObject, IViewModel - { - private readonly ISubject _isAppearing; - private readonly ISubject _isDisappearing; - - /// - /// Initializes a new instance of the class. - /// - [SuppressMessage("ReSharper", "VirtualMemberCallInConstructor", Justification = "Consumers should be aware methods are for object construction.")] - protected PopupPageBase() - { - _isAppearing = new Subject(); - _isDisappearing = new Subject(); - Initialize(); - BindControls(); - RegisterObservers(); - } - - /// - /// Gets the view bindings disposable. - /// - protected CompositeDisposable ViewBindings { get; } = new CompositeDisposable(); - - /// - /// Gets an observable sequence when the view is appearing. - /// - /// The appearing notification. - protected virtual IObservable IsAppearing => _isAppearing.AsObservable(); - - /// - /// Gets an observable sequence when the view is disappearing. - /// - /// The appearing notification. - protected virtual IObservable IsDisappearing => _isDisappearing.AsObservable(); - - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - protected override void OnAppearing() - { - _isAppearing.OnNext(Unit.Default); - base.OnAppearing(); - } - - /// - protected override void OnDisappearing() - { - _isDisappearing.OnNext(Unit.Default); - base.OnDisappearing(); - } - - /// - /// View lifecycle method that sets up reactive bindings. - /// - protected virtual void BindControls() - { - } - - /// - /// View lifecycle method that initializes the view. - /// - protected virtual void Initialize() - { - } - - /// - /// View lifecycle method that registers observers via subscriptions. - /// - protected virtual void RegisterObservers() - { - } - - /// - /// Disposes of the resources allocated for this instance. - /// - /// A value indicating whether or not the instance is disposing. - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - ViewBindings.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/src/Shiny/ReactiveShinyStartup.cs b/src/Shiny/ReactiveShinyStartup.cs deleted file mode 100644 index f4e2b4899..000000000 --- a/src/Shiny/ReactiveShinyStartup.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using ReactiveUI; -using Shiny; -using Splat; -using Splat.Microsoft.Extensions.DependencyInjection; - -namespace Rocket.Surgery.Airframe.Shiny -{ - /// - /// Represents an for application composition. - /// - public abstract class ReactiveShinyStartup : ShinyStartup - { - private readonly IServiceCollection _serviceCollection; - private readonly IConfigurationBuilder _configurationBuilder = new ConfigurationBuilder(); - private readonly IConfiguration _configuration; - - /// - /// Initializes a new instance of the class. - /// - protected ReactiveShinyStartup() - : this(new ServiceCollection()) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The service collection. - protected ReactiveShinyStartup(IServiceCollection serviceCollection) - : this(serviceCollection, new ConfigurationBuilder().Build()) => _serviceCollection = serviceCollection; - - /// - /// Initializes a new instance of the class. - /// - /// The service collection. - /// The configuration. - protected ReactiveShinyStartup(IServiceCollection serviceCollection, IConfiguration configuration) - { - _serviceCollection = serviceCollection; - _configuration = configuration; - } - - /// - public sealed override IServiceProvider CreateServiceProvider(IServiceCollection services) - { - foreach (var serviceDescriptor in services) - { - if (!_serviceCollection.Contains(serviceDescriptor)) - { - _serviceCollection.Add(serviceDescriptor); - } - } - - _serviceCollection.UseMicrosoftDependencyResolver(); - return _serviceCollection.BuildServiceProvider(); - } - - /// - public sealed override void ConfigureServices(IServiceCollection services, IPlatform platform) - { - ConfigureShiny(services); - ConfigureAppSettings(_serviceCollection, _configurationBuilder); - ConfigureServices(_serviceCollection); - - RegisterApplicationServices(); - } - - /// - /// Configure services with the given service collection. - /// - /// The service collection. - protected abstract void ConfigureServices(IServiceCollection services); - - /// - /// Configure with the given service collection. - /// - /// The service collection. - protected abstract void ConfigureShiny(IServiceCollection services); - - /// - /// Register core services. - /// - protected virtual void RegisterCoreServices() - { - } - - /// - /// Build your custom into the composition root. - /// - /// The configuration builder. - protected virtual void BuildConfiguration(IConfigurationBuilder configurationBuilder) - { - } - - private void RegisterApplicationServices() - { - Locator.CurrentMutable.InitializeSplat(); - Locator.CurrentMutable.InitializeReactiveUI(RegistrationNamespace.XamForms); - RegisterCoreServices(); - } - - private void ConfigureAppSettings(IServiceCollection services, IConfigurationBuilder configurationBuilder) - { - BuildConfiguration(configurationBuilder - .AddJsonFile("appsettings.json", optional: true) - .AddJsonFile("appsettings.dev.json", optional: true)); - - services.AddSingleton(_ => configurationBuilder.AddConfiguration(_configuration).Build()); - } - } -} \ No newline at end of file diff --git a/src/Shiny/Settings/Setting.cs b/src/Shiny/Settings/Setting.cs deleted file mode 100644 index eb82737a8..000000000 --- a/src/Shiny/Settings/Setting.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Reactive.Disposables; -using ReactiveUI; -using Rocket.Surgery.Airframe.Settings; - -namespace Rocket.Surgery.Airframe.Shiny.Settings -{ - /// - /// Class that represents an . - /// - /// The setting type. - public sealed class Setting : ReactiveObject, ISetting, IDisposable - { - private readonly CompositeDisposable _disposable = new CompositeDisposable(); - private T _value = default!; - - /// - /// Initializes a new instance of the class. - /// - /// The key. - /// The value. - public Setting(string key, T value) - { - Key = key; - Value = value; - } - - /// - /// Gets the default . - /// - public static ISetting Default => new Setting(nameof(Default), default!); - - /// - public string Key { get; } - - /// - public T Value - { - get => _value; - set => this.RaiseAndSetIfChanged(ref _value, value); - } - - /// - object ISetting.Value - { - get => _value; - set => this.RaiseAndSetIfChanged(ref _value, (T)value); - } - - /// - public void Dispose() => _disposable.Dispose(); - } -} \ No newline at end of file diff --git a/src/Shiny/Settings/SettingsProvider.cs b/src/Shiny/Settings/SettingsProvider.cs deleted file mode 100644 index ce6a32532..000000000 --- a/src/Shiny/Settings/SettingsProvider.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using DynamicData; -using ReactiveUI; -using Rocket.Surgery.Airframe.Settings; -using Shiny.Stores; - -namespace Rocket.Surgery.Airframe.Shiny.Settings -{ - /// - /// Represents a for . - /// - public sealed class SettingsProvider : ReactiveObject, ISettingsProvider, IDisposable - { - private readonly CompositeDisposable _garbage = new CompositeDisposable(); - - [SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "Roslyn can't read DisposeWith")] - private readonly SourceCache _settingsCache; - - /// - /// Initializes a new instance of the class. - /// - /// The shiny settings interface. - public SettingsProvider(IKeyValueStore shinySettings) - { - static void PersistSetting(ISetting setting, IKeyValueStore settings) => settings.Set(setting.Key, setting.Value); - - static void RemoveSetting(ISetting setting, IKeyValueStore settings) => settings.Remove(setting.Key); - - _settingsCache = new SourceCache(x => x.Key).DisposeWith(_garbage); - - var settingsChanged = _settingsCache - .DeferUntilLoaded() - .RefCount(); - - settingsChanged - .OnItemAdded(setting => PersistSetting(setting, shinySettings)) - .OnItemRemoved(setting => RemoveSetting(setting, shinySettings)) - .WhenPropertyChanged(x => x.Value) - .Where(x => x != null) - .Subscribe(value => PersistSetting(value.Sender, shinySettings)) - .DisposeWith(_garbage); - - _settingsCache.DisposeWith(_garbage); - } - - /// - public ISetting Get(string key) => (ISetting)_settingsCache.Lookup(key).Value; - - /// - public ISetting Get(string key, T defaultValue) - { - var optional = _settingsCache.Lookup(key); - if (optional.HasValue) - { - return (ISetting)optional.Value; - } - - _settingsCache.AddOrUpdate(new Setting(key, defaultValue)); - return (ISetting)_settingsCache.Lookup(key).Value; - } - - /// - public IObservable> Observe(string key) => - _settingsCache - .Watch(key) - .Select(x => x.Current) - .Cast>(); - - /// - public void Set(ISetting setting) => _settingsCache.AddOrUpdate(setting); - - /// - public bool Remove(string key) - { - _settingsCache.Remove(key); - return true; - } - - /// - public bool Contains(string key) => _settingsCache.Lookup(key).HasValue; - - /// - public void Clear() => _settingsCache.Clear(); - - /// - public void Dispose() => _garbage.Dispose(); - } -} \ No newline at end of file diff --git a/src/Shiny/Shiny.csproj b/src/Shiny/Shiny.csproj deleted file mode 100644 index a9c405099..000000000 --- a/src/Shiny/Shiny.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - netstandard2.0;net6.0 - Rocket.Surgery.Airframe.Shiny - Rocket.Surgery.Airframe.Shiny - - - - - - - - - - - - - - - - - diff --git a/src/Synthetic/Synthetic.csproj b/src/Synthetic/Synthetic.csproj index e45b12970..4ce40ea07 100644 --- a/src/Synthetic/Synthetic.csproj +++ b/src/Synthetic/Synthetic.csproj @@ -1,15 +1,11 @@  - netstandard2.0;net6.0 + net8.0 Rocket.Surgery.Airframe.Synthetic Rocket.Surgery.Airframe.Synthetic - - - - diff --git a/src/Timers/Timers.csproj b/src/Timers/Timers.csproj index 98dc6bcf8..748fc6dff 100644 --- a/src/Timers/Timers.csproj +++ b/src/Timers/Timers.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net6.0 + net8.0 Rocket.Surgery.Airframe.Timers Rocket.Surgery.Airframe.Timers diff --git a/src/ViewModels/IInitializable.cs b/src/ViewModels/IInitializable.cs deleted file mode 100644 index 16b971913..000000000 --- a/src/ViewModels/IInitializable.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Reactive; - -namespace Rocket.Surgery.Airframe.ViewModels -{ - /// - /// Interface representing an view model that can be initialized. - /// - /// The parameter type. - /// The result type. - public interface IInitializable - { - /// - /// Initializes the view model with the provided parameter. - /// - /// The parameter. - /// The result. - IObservable Initialize(TParam param); - } - - /// - /// Interface representing an view model that can be initialized. - /// - public interface IInitializable - { - /// - /// Initializes the view model with the provided parameter. - /// - /// A completion notification. - IObservable Initialize(); - } - - /// - /// Interface representing an view model that can be initialized. - /// - /// The parameter type. - public interface IInitializable - { - /// - /// Initializes the view model with the provided parameter. - /// - /// The parameter. - /// The result. - IObservable Initialize(TParam param); - } -} \ No newline at end of file diff --git a/src/ViewModels/INetworkAware.cs b/src/ViewModels/INetworkAware.cs index dbfe74882..2fcaa120c 100644 --- a/src/ViewModels/INetworkAware.cs +++ b/src/ViewModels/INetworkAware.cs @@ -1,5 +1,5 @@ using System; -using Xamarin.Essentials; +using Rocket.Surgery.Airframe.Connectivity; namespace Rocket.Surgery.Airframe.ViewModels { @@ -11,6 +11,6 @@ public interface INetworkAware /// /// Gets the connectivity. /// - IObservable Connectivity { get; } + IObservable Connectivity { get; } } } diff --git a/src/ViewModels/IViewModel.cs b/src/ViewModels/IViewModel.cs deleted file mode 100644 index d49a93083..000000000 --- a/src/ViewModels/IViewModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using ReactiveUI; -using Xamarin.Forms; - -[assembly: XmlnsPrefix("https://schemas.rocketsurgeonsguild.com/xaml/airframe/viewmodels", "viewmodels")] -[assembly: XmlnsDefinition("https://schemas.rocketsurgeonsguild.com/xaml/airframe/viewmodels", "Rocket.Surgery.Airframe.ViewModels")] - -namespace Rocket.Surgery.Airframe.ViewModels -{ - /// - /// Interface representation of a base ReactiveUI View Model. - /// - public interface IViewModel : IReactiveObject - { - /// - /// Gets a value indicating whether the view model is doing work. - /// - bool IsLoading { get; } - } -} \ No newline at end of file diff --git a/src/ViewModels/InitializableViewModel.cs b/src/ViewModels/InitializableViewModel.cs deleted file mode 100644 index 7450e6752..000000000 --- a/src/ViewModels/InitializableViewModel.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive; -using System.Reactive.Linq; - -[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Typed and untyped.")] - -namespace Rocket.Surgery.Airframe.ViewModels -{ - /// - /// Represents an view model that can be initialized. - /// - public abstract class InitializableViewModel : ViewModelBase, IInitializable - { - /// - IObservable IInitializable.Initialize() => Initialize(); - - /// - /// Template method for initialization. - /// - /// A completion notification. - protected virtual IObservable ExecuteInitialize() => Observable.Return(Unit.Default); - - private IObservable Initialize() => ExecuteInitialize(); - } - - /// - /// Represents an view model that can be intialized. - /// - /// The parameter type. - // ReSharper disable once SA1402 - public abstract class InitializableViewModel : InitializableViewModel, IInitializable - { - /// - IObservable IInitializable.Initialize(TParam param) => Initialize(param); - - /// - /// Template method for initialization. - /// - /// The parameter. - /// A completion notification. - protected virtual IObservable ExecuteInitialize(TParam param) => Observable.Return(Unit.Default); - - private IObservable Initialize(TParam param) => ExecuteInitialize(param); - } - - /// - /// Represents an view model that can be intialized. - /// - /// The parameter type. - /// The result type. - public abstract class InitializableViewModel : InitializableViewModel, IInitializable - { - /// - IObservable IInitializable.Initialize(TParam param) => Initialize(param); - - /// - /// Template method for initialization. - /// - /// The parameter. - /// A result. - protected virtual IObservable ExecuteInitialize(TParam param) => Observable.Empty(); - - private IObservable Initialize(TParam param) => ExecuteInitialize(param); - } -} \ No newline at end of file diff --git a/src/ViewModels/NavigableViewModelBase.cs b/src/ViewModels/NavigableViewModelBase.cs index b22580049..94dcd1e58 100644 --- a/src/ViewModels/NavigableViewModelBase.cs +++ b/src/ViewModels/NavigableViewModelBase.cs @@ -1,101 +1,69 @@ using System; -using System.Reactive; -using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; -using ReactiveUI; -using Sextant; +using Rocket.Surgery.Airframe.Navigation; namespace Rocket.Surgery.Airframe.ViewModels { /// - /// Base view model for navigation. + /// Base view model for navigation. /// - public abstract class NavigableViewModelBase : ViewModelBase, INavigable, IDestructible, IInitializable + public abstract class NavigableViewModelBase : ViewModelBase, INavigated, IDestructible, IInitialize { - private readonly ISubject _navigatedTo = new Subject(); - private readonly ISubject _navigatedFrom = new Subject(); - private readonly ISubject _navigatingTo = new Subject(); - /// /// Initializes a new instance of the class. /// - protected NavigableViewModelBase() => Initialize = ReactiveCommand.CreateFromObservable(((IInitializable)this).Initialize); + protected NavigableViewModelBase() + { + } - /// - public virtual string Id { get; } = string.Empty; + /// + void IInitialize.OnInitialize(IArguments arguments) + { + _initialize.OnNext(arguments); + _initialize.OnCompleted(); + } - /// - /// Gets the initialize command. - /// - public ReactiveCommand Initialize { get; } + /// + void INavigated.OnNavigatedTo(IArguments arguments) => _navigatedTo.OnNext(arguments); + + /// + void INavigated.OnNavigatedFrom(IArguments arguments) => _navigatedFrom.OnNext(arguments); /// - /// Gets the navigated to . + /// Gets the initial to . /// - /// The parameter. - protected IObservable NavigatedTo => _navigatedTo.AsObservable(); + /// The arguments. + protected IObservable Initialize => _initialize.AsObservable().Publish().RefCount(); /// - /// Gets the navigated from . + /// Gets the navigated to . /// - /// The parameter. - protected IObservable NavigatedFrom => _navigatedFrom.AsObservable(); + /// The arguments. + protected IObservable NavigatedTo => _navigatedTo.AsObservable().Publish().RefCount(); /// - /// Gets the navigating to . + /// Gets the navigated from . /// - /// The parameter. - protected IObservable NavigatingTo => _navigatingTo.AsObservable(); - - /// - IObservable INavigated.WhenNavigatedTo(INavigationParameter navigationParameter) => Observable.Create(observer => - { - _navigatedTo.OnNext(navigationParameter); - observer.OnNext(Unit.Default); - observer.OnCompleted(); - return Disposable.Empty; - }); - - /// - IObservable INavigated.WhenNavigatedFrom(INavigationParameter navigationParameter) => Observable.Create(observer => - { - _navigatedFrom.OnNext(navigationParameter); - observer.OnNext(Unit.Default); - observer.OnCompleted(); - return Disposable.Empty; - }); - - /// - IObservable INavigating.WhenNavigatingTo(INavigationParameter navigationParameter) => Observable.Create(observer => - { - _navigatingTo.OnNext(navigationParameter); - observer.OnNext(Unit.Default); - observer.OnCompleted(); - return Disposable.Empty; - }); + /// The arguments. + protected IObservable NavigatedFrom => _navigatedFrom.AsObservable().Publish().RefCount(); /// void IDestructible.Destroy() { Destroy(); - Garbage.Dispose(); + Dispose(); } - /// - IObservable IInitializable.Initialize() => ExecuteInitialize(); - - /// - /// Template method for initializing the view model. - /// - /// A completion notification. - protected virtual IObservable ExecuteInitialize() => Observable.Return(Unit.Default); - /// /// Template method to destroy the view model. /// protected virtual void Destroy() { } + + private readonly AsyncSubject _initialize = new AsyncSubject(); + private readonly Subject _navigatedTo = new Subject(); + private readonly Subject _navigatedFrom = new Subject(); } } \ No newline at end of file diff --git a/src/ViewModels/ViewModelBase.cs b/src/ViewModels/ViewModelBase.cs index 7daee9598..d295f4d63 100644 --- a/src/ViewModels/ViewModelBase.cs +++ b/src/ViewModels/ViewModelBase.cs @@ -1,11 +1,35 @@ -namespace Rocket.Surgery.Airframe.ViewModels +using System; +using System.Reactive.Disposables; + +namespace Rocket.Surgery.Airframe.ViewModels { /// /// Base ReactiveUI View Model. /// - public abstract class ViewModelBase : ReactiveDisposable, IViewModel + public abstract class ViewModelBase : IDisposable { - /// - public virtual bool IsLoading { get; } + /// + /// Gets the collection of disposables. + /// + protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); + + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Disposes of the garbage. + /// + /// Whether the object is disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + Garbage.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/ViewModels/ViewModels.csproj b/src/ViewModels/ViewModels.csproj index 4e4aedd42..5621d4130 100644 --- a/src/ViewModels/ViewModels.csproj +++ b/src/ViewModels/ViewModels.csproj @@ -1,32 +1,20 @@  - netstandard2.0;net6.0 + net8.0 Rocket.Surgery.Airframe.ViewModels Rocket.Surgery.Airframe.ViewModels Rocket.Surgery.Airframe.ViewModels - latest ReactiveUI base view model abstractions. - - bin\Debug\Rocket.Surgery.Airframe.ViewModels.xml - - - - bin\Release\Rocket.Surgery.Airframe.ViewModels.xml - - - - - - - - - + + + + diff --git a/test/Airframe.Tests/Airframe.Tests.csproj b/test/Airframe.Tests/Airframe.Tests.csproj index 032503c8f..2665e2a22 100644 --- a/test/Airframe.Tests/Airframe.Tests.csproj +++ b/test/Airframe.Tests/Airframe.Tests.csproj @@ -1,18 +1,14 @@ - net6.0 - false Rocket.Surgery.Airframe.Tests Rocket.Surgery.Airframe.Tests - - - - - + + + diff --git a/test/Airframe.Tests/BaseExceptionHandlerStub.cs b/test/Airframe.Tests/BaseExceptionHandlerStub.cs deleted file mode 100644 index 3f2ccd455..000000000 --- a/test/Airframe.Tests/BaseExceptionHandlerStub.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Airframe.Tests -{ - internal sealed class BaseExceptionHandlerStub : IObserver - { - public static readonly BaseExceptionHandlerStub Instance = new BaseExceptionHandlerStub(); - - public void OnCompleted() - { - } - - public void OnError(Exception error) - { - } - - /// - public void OnNext(Exception exception) {} - } -} \ No newline at end of file diff --git a/test/Airframe.Tests/NoExceptionHandlerStub.cs b/test/Airframe.Tests/NoExceptionHandlerStub.cs new file mode 100644 index 000000000..5a9bb5fcf --- /dev/null +++ b/test/Airframe.Tests/NoExceptionHandlerStub.cs @@ -0,0 +1,24 @@ +using System; + +namespace Rocket.Surgery.Airframe.Tests +{ + internal sealed class NoExceptionHandlerStub : IObserver + { + public static readonly NoExceptionHandlerStub Instance = new NoExceptionHandlerStub(); + + /// + public void OnCompleted() + { + } + + /// + public void OnError(Exception error) + { + } + + /// + public void OnNext(Exception exception) + { + } + } +} \ No newline at end of file diff --git a/test/Airframe.Tests/SchedulerProviderFixture.cs b/test/Airframe.Tests/SchedulerProviderFixture.cs index a84b8b71e..10b9d1021 100644 --- a/test/Airframe.Tests/SchedulerProviderFixture.cs +++ b/test/Airframe.Tests/SchedulerProviderFixture.cs @@ -1,21 +1,41 @@ -using System.Reactive.Concurrency; using Microsoft.Reactive.Testing; -using Rocket.Surgery.Airframe.Forms; using Rocket.Surgery.Extensions.Testing.Fixtures; +using System; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Concurrency; -namespace Airframe.Tests +namespace Rocket.Surgery.Airframe.Tests { + [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order")] public class SchedulerProviderFixture : ITestFixtureBuilder { + public static implicit operator SchedulerProviderMock(SchedulerProviderFixture fixture) => fixture.Build(); + + public SchedulerProviderFixture WithTestScheduler(IScheduler scheduler) => this.With(ref _mainThreadScheduler, scheduler) + .With(ref _backgroundThreadScheduler, scheduler); + + private SchedulerProviderMock Build() => new SchedulerProviderMock(_mainThreadScheduler, _backgroundThreadScheduler); + private IScheduler _mainThreadScheduler = new TestScheduler(); private IScheduler _backgroundThreadScheduler = new TestScheduler(); - public SchedulerProviderFixture WithTestScheduler(IScheduler scheduler) - => this.With(ref _mainThreadScheduler, scheduler) - .With(ref _backgroundThreadScheduler, scheduler); + public class SchedulerProviderMock(IScheduler userInterfaceTestScheduler, IScheduler backgroundTestScheduler) : ISchedulerProvider + { + /// + IScheduler ISchedulerProvider.UserInterfaceThread => UserInterfaceTestScheduler; + + /// + IScheduler ISchedulerProvider.BackgroundThread => BackgroundTestScheduler; - public static implicit operator SchedulerProvider(SchedulerProviderFixture fixture) => fixture.Build(); + /// + /// Gets the test user interface scheduler. + /// + public TestScheduler UserInterfaceTestScheduler { get; } = userInterfaceTestScheduler as TestScheduler ?? throw new ArgumentOutOfRangeException(nameof(userInterfaceTestScheduler)); - private SchedulerProvider Build() => new SchedulerProvider(_mainThreadScheduler, _backgroundThreadScheduler); + /// + /// Gets the test background scheduler. + /// + public TestScheduler BackgroundTestScheduler { get; } = backgroundTestScheduler as TestScheduler ?? throw new ArgumentOutOfRangeException(nameof(userInterfaceTestScheduler)); + } } } \ No newline at end of file diff --git a/test/Airframe.Tests/TestBase.cs b/test/Airframe.Tests/TestBase.cs index 7cf649bfe..acc2dbe6a 100644 --- a/test/Airframe.Tests/TestBase.cs +++ b/test/Airframe.Tests/TestBase.cs @@ -1,11 +1,11 @@ using ReactiveUI; -namespace Airframe.Tests +namespace Rocket.Surgery.Airframe.Tests { public abstract class TestBase { protected TestBase() => Initialize(); - private static void Initialize() => RxApp.DefaultExceptionHandler = BaseExceptionHandlerStub.Instance; + private static void Initialize() => RxApp.DefaultExceptionHandler = NoExceptionHandlerStub.Instance; } } \ No newline at end of file diff --git a/test/Composition.Tests/Composition.Tests.csproj b/test/Composition.Tests/Composition.Tests.csproj index 8eb099d1c..267a5cbed 100644 --- a/test/Composition.Tests/Composition.Tests.csproj +++ b/test/Composition.Tests/Composition.Tests.csproj @@ -1,8 +1,8 @@ - net6.0 - false + Rocket.Surgery.Airframe.Composition.Tests + Rocket.Surgery.Airframe.Composition.Tests @@ -22,7 +22,6 @@ - diff --git a/test/Composition.Tests/CompositionRootTests.cs b/test/Composition.Tests/CompositionRootTests.cs index e534e76f2..8d0748aa6 100644 --- a/test/Composition.Tests/CompositionRootTests.cs +++ b/test/Composition.Tests/CompositionRootTests.cs @@ -4,13 +4,13 @@ using Rocket.Surgery.Airframe.Composition; using Xunit; -namespace Composition.Tests +namespace Composition.Tests; + +public sealed class CompositionRootTests { - public sealed class CompositionRootTests + [Fact] + public void Should_Register_View_As_IViewFor() { - [Fact] - public void Should_Register_View_As_IViewFor() - { // Given var sut = new CompositionBuilder(); @@ -21,9 +21,9 @@ public void Should_Register_View_As_IViewFor() result.Resolve>().Should().BeOfType(); } - [Fact] - public void Should_Register_ViewModel() - { + [Fact] + public void Should_Register_ViewModel() + { // Given var sut = new CompositionBuilder(); @@ -34,9 +34,9 @@ public void Should_Register_ViewModel() result.Resolve().Should().NotBeNull(); } - [Fact] - public void Should_Register_Module() - { + [Fact] + public void Should_Register_Module() + { // Given var sut = new CompositionBuilder(); @@ -47,5 +47,4 @@ public void Should_Register_Module() result.Resolve().Should().NotBeNull(); result.Resolve>().Should().BeOfType(); } - } } \ No newline at end of file diff --git a/test/Composition.Tests/DryIocModuleTests.cs b/test/Composition.Tests/DryIocModuleTests.cs index 7aa0566a8..f7f95b005 100644 --- a/test/Composition.Tests/DryIocModuleTests.cs +++ b/test/Composition.Tests/DryIocModuleTests.cs @@ -3,13 +3,13 @@ using Rocket.Surgery.Airframe.Composition; using Xunit; -namespace Composition.Tests +namespace Composition.Tests; + +public sealed class DryIocModuleTests { - public sealed class DryIocModuleTests + [Fact] + public void Should_Resolve_Module() { - [Fact] - public void Should_Resolve_Module() - { // Given IContainer sut = new Container(); @@ -18,9 +18,9 @@ public void Should_Resolve_Module() result.Resolve().Should().NotBeNull(); } - [Fact] - public void Should_Resolve_Module_Registrations() - { + [Fact] + public void Should_Resolve_Module_Registrations() + { // Given IContainer sut = new Container(); @@ -29,5 +29,4 @@ public void Should_Resolve_Module_Registrations() result.Resolve().Should().NotBeNull(); } - } } \ No newline at end of file diff --git a/test/Composition.Tests/IRegistrarExtensionTests.cs b/test/Composition.Tests/IRegistrarExtensionTests.cs index fcabec5dc..44d2da515 100644 --- a/test/Composition.Tests/IRegistrarExtensionTests.cs +++ b/test/Composition.Tests/IRegistrarExtensionTests.cs @@ -4,15 +4,15 @@ using Rocket.Surgery.Airframe.Composition; using Xunit; -namespace Composition.Tests +namespace Composition.Tests; + +public sealed class IRegistrarExtensionTests { - public sealed class IRegistrarExtensionTests + public class TheRegisterViewMethod { - public class TheRegisterViewMethod + [Fact] + public void Should_Register_View_As_IViewFor() { - [Fact] - public void Should_Register_View_As_IViewFor() - { // Given IContainer sut = new Container(); @@ -22,13 +22,13 @@ public void Should_Register_View_As_IViewFor() // Then sut.Resolve>().Should().BeOfType(); } - } + } - public class TheRegisterViewModelMethod + public class TheRegisterViewModelMethod + { + [Fact] + public void Should_Register_ViewModel() { - [Fact] - public void Should_Register_ViewModel() - { // Given IContainer sut = new Container(); @@ -38,13 +38,13 @@ public void Should_Register_ViewModel() // Then sut.Resolve().Should().NotBeNull(); } - } + } - public class TheRegisterModuleMethod + public class TheRegisterModuleMethod + { + [Fact] + public void Should_Throw_When_Resolve_Module() { - [Fact] - public void Should_Throw_When_Resolve_Module() - { // Given IContainer sut = new Container(); sut.RegisterModule(new TestModule()); @@ -62,9 +62,9 @@ public void Should_Throw_When_Resolve_Module() .Be("UnableToResolveUnknownService"); } - [Fact] - public void Should_Resolve_Module_Registrations() - { + [Fact] + public void Should_Resolve_Module_Registrations() + { // Given IContainer sut = new Container(); @@ -75,13 +75,13 @@ public void Should_Resolve_Module_Registrations() sut.Resolve().Should().NotBeNull(); sut.Resolve>().Should().BeOfType(); } - } + } - public class TheRegisterModuleGenericMethod + public class TheRegisterModuleGenericMethod + { + [Fact] + public void Should_Resolve_Module() { - [Fact] - public void Should_Resolve_Module() - { // Given IContainer sut = new Container(); @@ -92,9 +92,9 @@ public void Should_Resolve_Module() sut.Resolve().Should().NotBeNull(); } - [Fact] - public void Should_Resolve_Module_Registrations() - { + [Fact] + public void Should_Resolve_Module_Registrations() + { // Given IContainer sut = new Container(); @@ -105,6 +105,5 @@ public void Should_Resolve_Module_Registrations() sut.Resolve().Should().NotBeNull(); sut.Resolve>().Should().BeOfType(); } - } } } \ No newline at end of file diff --git a/test/Composition.Tests/TestModule.cs b/test/Composition.Tests/TestModule.cs index 7a34c4c66..4b7041fe2 100644 --- a/test/Composition.Tests/TestModule.cs +++ b/test/Composition.Tests/TestModule.cs @@ -1,14 +1,14 @@ using DryIoc; using Rocket.Surgery.Airframe.Composition; -namespace Composition.Tests +namespace Composition.Tests; + +public class TestModule : DryIocModule { - public class TestModule : DryIocModule + /// + public override void Load(IRegistrator registrar) { - public override void Load(IRegistrator registrar) - { - registrar.RegisterViewModel(); - registrar.RegisterView(); - } + registrar.RegisterViewModel(); + registrar.RegisterView(); } } \ No newline at end of file diff --git a/test/Composition.Tests/TestView.cs b/test/Composition.Tests/TestView.cs index 5f1e6f13a..8dfa81896 100644 --- a/test/Composition.Tests/TestView.cs +++ b/test/Composition.Tests/TestView.cs @@ -1,15 +1,16 @@ using ReactiveUI; -namespace Composition.Tests +namespace Composition.Tests; + +public class TestView : IViewFor { - public class TestView : IViewFor + /// + object IViewFor.ViewModel { - object IViewFor.ViewModel - { - get => ViewModel; - set => ViewModel = (TestViewModel) value; - } - - public TestViewModel ViewModel { get; set; } + get => ViewModel; + set => ViewModel = (TestViewModel) value; } + + /// + public TestViewModel ViewModel { get; set; } } \ No newline at end of file diff --git a/test/Composition.Tests/TestViewModel.cs b/test/Composition.Tests/TestViewModel.cs index 4d71b4915..109e207ed 100644 --- a/test/Composition.Tests/TestViewModel.cs +++ b/test/Composition.Tests/TestViewModel.cs @@ -1,6 +1,6 @@ -namespace Composition.Tests -{ - public class TestViewModel - { - } -} \ No newline at end of file +using JetBrains.Annotations; + +namespace Composition.Tests; + +[PublicAPI] +public class TestViewModel; \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs b/test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs new file mode 100644 index 000000000..f977f3bd0 --- /dev/null +++ b/test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs @@ -0,0 +1,27 @@ +using Rocket.Surgery.Airframe.Connectivity; +using Rocket.Surgery.Extensions.Testing.Fixtures; +using System.Linq; + +namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; + +internal sealed class ConnectivityChangedEventFixture : ITestFixtureBuilder +{ + public static implicit operator NetworkStateChangedEvent(ConnectivityChangedEventFixture fixture) => fixture.Build(); + + public ConnectivityChangedEventFixture WithDefault() => WithDefaultAccess().WithDefaultProfiles(); + + public ConnectivityChangedEventFixture WithDefaultAccess() => this.With(ref _networkAccess, NetworkAccess.Internet); + + public ConnectivityChangedEventFixture WithDefaultProfiles() => WithProfiles( + ConnectionProfile.Bluetooth, + ConnectionProfile.Ethernet, + ConnectionProfile.WiFi + ); + + public ConnectivityChangedEventFixture WithProfiles(params ConnectionProfile[] profiles) => this.With(ref _profiles, profiles); + + private NetworkStateChangedEvent Build() => new NetworkStateChangedEvent(_networkAccess, _profiles.ToArray()); + + private NetworkAccess _networkAccess = NetworkAccess.Internet; + private ConnectionProfile[] _profiles = { ConnectionProfile.WiFi }; +} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs b/test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs new file mode 100644 index 000000000..c76050606 --- /dev/null +++ b/test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs @@ -0,0 +1,76 @@ +using FluentAssertions; +using Rocket.Surgery.Airframe.Connectivity; +using Xunit; + +namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity +{ + public class ConnectivityChangedEventTests + { + [Theory] + [InlineData(ConnectionProfile.Bluetooth)] + [InlineData(ConnectionProfile.Ethernet)] + [InlineData(ConnectionProfile.Cellular)] + [InlineData(ConnectionProfile.WiFi)] + public void GivenValidProfile_WhenHasValidProfile_ThenResultTrue(ConnectionProfile profile) + { + // Given, When + NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithProfiles(profile); + + // Then + sut + .HasValidProfile() + .Should() + .BeTrue(); + } + + [Theory] + [InlineData(ConnectionProfile.Unknown)] + public void GivenValidProfile_WhenHasValidProfile_ThenResultFalse(ConnectionProfile profile) + { + // Given, When + NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithProfiles(profile); + + // Then + sut + .HasValidProfile() + .Should() + .BeFalse(); + } + + [Fact] + public void GivenDefaultEventArg_WhenHasAccess_ThenResultTrue() + { + // Given, When + NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithDefault(); + + // Then + sut.HasSignal() + .Should() + .BeTrue(); + } + + [Fact] + public void GivenDefaultEventArg_WhenToString_ThenResultCorrect() + { + // Given, When + NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithDefault(); + + // Then + sut.ToString() + .Should() + .Be("NetworkAccess: Internet, ConnectionProfiles: [Bluetooth, Ethernet, WiFi]"); + } + + [Fact] + public void GivenDefaultEventArg_WhenDegraded_ThenResultTrue() + { + // Given, When + NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithProfiles(ConnectionProfile.Unknown); + + // Then + sut.Degraded() + .Should() + .BeTrue(); + } + } +} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs b/test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs new file mode 100644 index 000000000..4cc2e668a --- /dev/null +++ b/test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs @@ -0,0 +1,103 @@ +using FluentAssertions; +using Rocket.Surgery.Airframe.Connectivity; +using System; +using Xunit; + +namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; + +public class ConnectivityInterfaceTests +{ + [Theory] + [InlineData(NetworkAccess.Internet)] + [InlineData(NetworkAccess.Local)] + [InlineData(NetworkAccess.ConstrainedInternet)] + public void GivenImplementation_WhenConnectivityChanged_ThenHasSignal(NetworkAccess access) + { + // Given + var sut = new NetworkStateMock(); + bool? result = null; + using var _ = sut.As().HasSignal().Subscribe(actual => result = actual); + + // When + sut.Notify(new NetworkStateChangedEvent(access, ConnectionProfile.WiFi)); + + // Then + result + .Should() + .NotBeNull() + .And + .Subject + .Should() + .BeTrue(); + } + + [Theory] + [InlineData(NetworkAccess.None)] + [InlineData(NetworkAccess.Unknown)] + public void GivenImplementation_WhenConnectivityChanged_ThenHasNoSignal(NetworkAccess access) + { + // Given + var sut = new NetworkStateMock(); + bool? result = null; + using var _ = sut.As().HasSignal().Subscribe(actual => result = actual); + + // When + sut.Notify(new NetworkStateChangedEvent(access)); + + // Then + result + .Should() + .NotBeNull() + .And + .Subject + .Should() + .BeFalse(); + } + + [Theory] + [InlineData(NetworkAccess.Internet)] + [InlineData(NetworkAccess.Local)] + [InlineData(NetworkAccess.ConstrainedInternet)] + public void GivenImplementation_WhenConnectivityChanged_ThenSignalDegraded(NetworkAccess access) + { + // Given + var sut = new NetworkStateMock(); + bool? result = null; + using var _ = sut.As().SignalDegraded().Subscribe(actual => result = actual); + + // When + sut.Notify(new NetworkStateChangedEvent(access)); + + // Then + result + .Should() + .NotBeNull() + .And + .Subject + .Should() + .BeTrue(); + } + + [Theory] + [InlineData(NetworkAccess.None)] + [InlineData(NetworkAccess.Unknown)] + public void GivenImplementation_WhenConnectivityChanged_ThenSignalNotDegraded(NetworkAccess access) + { + // Given + var sut = new NetworkStateMock(); + bool? result = null; + using var _ = sut.As().SignalDegraded().Subscribe(actual => result = actual); + + // When + sut.Notify(new NetworkStateChangedEvent(access)); + + // Then + result + .Should() + .NotBeNull() + .And + .Subject + .Should() + .BeFalse(); + } +} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/NetworkStateMock.cs b/test/Core.Tests/Connectivity/NetworkStateMock.cs new file mode 100644 index 000000000..b15154e9c --- /dev/null +++ b/test/Core.Tests/Connectivity/NetworkStateMock.cs @@ -0,0 +1,22 @@ +using Rocket.Surgery.Airframe.Connectivity; +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Reactive.Subjects; + +namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; + +internal class NetworkStateMock : INetworkState +{ + public NetworkAccess NetworkAccess { get; } = NetworkAccess.Internet; + + public IReadOnlyList Profiles { get; } = new[] { ConnectionProfile.WiFi }; + + public IObservable ConnectivityChanged => _connectivity.AsObservable(); + + public void Notify(NetworkStateChangedEvent networkStateChangedEvent) => _connectivity.OnNext(networkStateChangedEvent); + + public IDisposable Subscribe(IObserver observer) => _connectivity.Subscribe(observer); + + private readonly Subject _connectivity = new Subject(); +} \ No newline at end of file diff --git a/test/Core.Tests/Core.Tests.csproj b/test/Core.Tests/Core.Tests.csproj index 3f5743d33..a8d57dedd 100644 --- a/test/Core.Tests/Core.Tests.csproj +++ b/test/Core.Tests/Core.Tests.csproj @@ -1,25 +1,10 @@ - net6.0 - false Rocket.Surgery.Airframe.Core.Tests Rocket.Surgery.Airframe.Core.Tests - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - diff --git a/test/Data.Tests/Data.Tests.csproj b/test/Data.Tests/Data.Tests.csproj index 9f0586d9f..6b2bb0b1d 100644 --- a/test/Data.Tests/Data.Tests.csproj +++ b/test/Data.Tests/Data.Tests.csproj @@ -1,8 +1,6 @@ - net6.0 - false Rocket.Surgery.Airframe.Data.Tests Rocket.Surgery.Airframe.Data.Tests diff --git a/test/MicrosoftDependencyInjection.Tests/MicrosoftDependencyInjection.Tests.csproj b/test/MicrosoftDependencyInjection.Tests/MicrosoftDependencyInjection.Tests.csproj index bce3fae97..d54451523 100644 --- a/test/MicrosoftDependencyInjection.Tests/MicrosoftDependencyInjection.Tests.csproj +++ b/test/MicrosoftDependencyInjection.Tests/MicrosoftDependencyInjection.Tests.csproj @@ -1,27 +1,10 @@ - net6.0 - - false - Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - diff --git a/test/Shiny.Tests/ReactiveShinyStartupTests.cs b/test/Shiny.Tests/ReactiveShinyStartupTests.cs deleted file mode 100644 index 85d5b0146..000000000 --- a/test/Shiny.Tests/ReactiveShinyStartupTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -using FluentAssertions; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using NSubstitute; -using Shiny; -using Xunit; - -namespace Airframe.Shiny.Tests -{ - public class ReactiveShinyStartupTests - { - [Fact] - public void Should_Register_Configuration() - { - // Given - var configuration = Substitute.For(); - var serviceCollection = new ServiceCollection(); - var sut = new TestStartup(serviceCollection, configuration); - - // When - sut.ConfigureServices(serviceCollection, Arg.Any()); - - // Then - serviceCollection.Should().ContainSingle(x => x.ServiceType == typeof(IConfiguration)); - } - - } -} diff --git a/test/Shiny.Tests/TestStartup.cs b/test/Shiny.Tests/TestStartup.cs deleted file mode 100644 index 21ea9b986..000000000 --- a/test/Shiny.Tests/TestStartup.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Rocket.Surgery.Airframe.Shiny; - -namespace Airframe.Shiny.Tests -{ - internal class TestStartup : ReactiveShinyStartup - { - /// - /// Initializes a new instance of the class. - /// - /// The service collection. - /// The configuration. - public TestStartup(IServiceCollection serviceCollection, IConfiguration configuration) - : base(serviceCollection, configuration) { } - - protected override void ConfigureServices(IServiceCollection services) { } - - protected override void ConfigureShiny(IServiceCollection services) { } - } -} diff --git a/test/Timers.Tests/DecrementTimerFixture.cs b/test/Timers.Tests/DecrementTimerFixture.cs index 238e28366..7975169ba 100644 --- a/test/Timers.Tests/DecrementTimerFixture.cs +++ b/test/Timers.Tests/DecrementTimerFixture.cs @@ -1,5 +1,4 @@ -using Airframe.Tests; -using Rocket.Surgery.Airframe.Forms; +using Rocket.Surgery.Airframe.Tests; using Rocket.Surgery.Airframe.Timers; using Rocket.Surgery.Extensions.Testing.Fixtures; diff --git a/test/Timers.Tests/DecrementTimerTests.cs b/test/Timers.Tests/DecrementTimerTests.cs index 7b03fec1c..f55a9b744 100644 --- a/test/Timers.Tests/DecrementTimerTests.cs +++ b/test/Timers.Tests/DecrementTimerTests.cs @@ -1,8 +1,8 @@ -using Airframe.Tests; using FluentAssertions; using Microsoft.Reactive.Testing; using ReactiveUI.Testing; using Rocket.Surgery.Airframe.Forms; +using Rocket.Surgery.Airframe.Tests; using Rocket.Surgery.Airframe.Timers; using System; using Xunit; diff --git a/test/Timers.Tests/DivisibleTimerFixture.cs b/test/Timers.Tests/DivisibleTimerFixture.cs index 8f0d34247..db63fb9ce 100644 --- a/test/Timers.Tests/DivisibleTimerFixture.cs +++ b/test/Timers.Tests/DivisibleTimerFixture.cs @@ -1,5 +1,5 @@ -using Airframe.Tests; using Rocket.Surgery.Airframe.Forms; +using Rocket.Surgery.Airframe.Tests; using Rocket.Surgery.Airframe.Timers; using Rocket.Surgery.Extensions.Testing.Fixtures; diff --git a/test/Timers.Tests/DivisibleTimerTests.cs b/test/Timers.Tests/DivisibleTimerTests.cs index 05054bb32..3fb3203cf 100644 --- a/test/Timers.Tests/DivisibleTimerTests.cs +++ b/test/Timers.Tests/DivisibleTimerTests.cs @@ -1,6 +1,6 @@ -using Airframe.Tests; using FluentAssertions; using Microsoft.Reactive.Testing; +using Rocket.Surgery.Airframe.Tests; using Rocket.Surgery.Airframe.Timers; using System; using System.Reactive.Linq; diff --git a/test/Timers.Tests/IncrementTimerFixture.cs b/test/Timers.Tests/IncrementTimerFixture.cs index 1d51130f1..85c4cf36f 100644 --- a/test/Timers.Tests/IncrementTimerFixture.cs +++ b/test/Timers.Tests/IncrementTimerFixture.cs @@ -1,5 +1,5 @@ -using Airframe.Tests; using Rocket.Surgery.Airframe.Forms; +using Rocket.Surgery.Airframe.Tests; using Rocket.Surgery.Airframe.Timers; using Rocket.Surgery.Extensions.Testing.Fixtures; diff --git a/test/Timers.Tests/IncrementTimerTests.cs b/test/Timers.Tests/IncrementTimerTests.cs index 6ceda573e..b49770d69 100644 --- a/test/Timers.Tests/IncrementTimerTests.cs +++ b/test/Timers.Tests/IncrementTimerTests.cs @@ -1,8 +1,8 @@ -using Airframe.Tests; using FluentAssertions; using Microsoft.Reactive.Testing; using ReactiveUI.Testing; using Rocket.Surgery.Airframe.Forms; +using Rocket.Surgery.Airframe.Tests; using Rocket.Surgery.Airframe.Timers; using System; using Xunit; diff --git a/test/Timers.Tests/Timers.Tests.csproj b/test/Timers.Tests/Timers.Tests.csproj index 842f5e0d3..4bf54c124 100644 --- a/test/Timers.Tests/Timers.Tests.csproj +++ b/test/Timers.Tests/Timers.Tests.csproj @@ -1,14 +1,11 @@ - net6.0 - false Rocket.Surgery.Airframe.Timers.Tests Rocket.Surgery.Airframe.Timers.Tests - diff --git a/test/ViewModels.Tests/NavigableViewModelTests.cs b/test/ViewModels.Tests/NavigableViewModelTests.cs index adc4a78aa..64961d005 100644 --- a/test/ViewModels.Tests/NavigableViewModelTests.cs +++ b/test/ViewModels.Tests/NavigableViewModelTests.cs @@ -1,10 +1,8 @@ -using Airframe.Tests; using FluentAssertions; -using Sextant; -using System; +using Rocket.Surgery.Airframe.Tests; using Xunit; -namespace Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests { public class NavigableViewModelTests : TestBase { diff --git a/test/ViewModels.Tests/TestNavigationViewModel.cs b/test/ViewModels.Tests/TestNavigationViewModel.cs index c50215cc3..94f10a0d4 100644 --- a/test/ViewModels.Tests/TestNavigationViewModel.cs +++ b/test/ViewModels.Tests/TestNavigationViewModel.cs @@ -1,17 +1,16 @@ using ReactiveUI; -using Rocket.Surgery.Airframe.ViewModels; -using Sextant; +using Rocket.Surgery.Airframe.Navigation; using System; using System.Reactive; using System.Reactive.Disposables; -namespace Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestNavigationViewModel : NavigableViewModelBase { - private readonly ObservableAsPropertyHelper _navigatedToParameter; - private readonly ObservableAsPropertyHelper _navigatedFromParameter; - private readonly ObservableAsPropertyHelper _navigatingToParameter; + private readonly ObservableAsPropertyHelper _navigatedToParameter; + private readonly ObservableAsPropertyHelper _navigatedFromParameter; + private readonly ObservableAsPropertyHelper _navigatingToParameter; private bool _overriden; public TestNavigationViewModel() @@ -24,16 +23,16 @@ public TestNavigationViewModel() .ToProperty(this, nameof(NavigatedFromParameter), out _navigatedFromParameter) .DisposeWith(Garbage); - NavigatingTo + Initialize .ToProperty(this, nameof(NavigatingToParameter), out _navigatingToParameter) .DisposeWith(Garbage); } - public INavigationParameter NavigatedToParameter => _navigatedToParameter.Value; + public IArguments NavigatedToParameter => _navigatedToParameter.Value; - public INavigationParameter NavigatedFromParameter => _navigatedFromParameter.Value; + public IArguments NavigatedFromParameter => _navigatedFromParameter.Value; - public INavigationParameter NavigatingToParameter => _navigatingToParameter.Value; + public IArguments NavigatingToParameter => _navigatingToParameter.Value; protected override IObservable ExecuteInitialize() { diff --git a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs index 86cab872a..470179e3b 100644 --- a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs +++ b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs @@ -1,4 +1,4 @@ -namespace Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestNavigationViewModelFixture { diff --git a/test/ViewModels.Tests/TestViewModel.cs b/test/ViewModels.Tests/TestViewModel.cs index 0d4a9901d..c34cd6452 100644 --- a/test/ViewModels.Tests/TestViewModel.cs +++ b/test/ViewModels.Tests/TestViewModel.cs @@ -1,6 +1,4 @@ -using Rocket.Surgery.Airframe.ViewModels; - -namespace Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestViewModel : ViewModelBase { diff --git a/test/ViewModels.Tests/TestViewModelFixture.cs b/test/ViewModels.Tests/TestViewModelFixture.cs index 61df423c9..f6a3e045c 100644 --- a/test/ViewModels.Tests/TestViewModelFixture.cs +++ b/test/ViewModels.Tests/TestViewModelFixture.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestViewModelFixture : ITestFixtureBuilder { diff --git a/test/ViewModels.Tests/ViewModelTests.cs b/test/ViewModels.Tests/ViewModelTests.cs index cb657ff2f..2080b7d1a 100644 --- a/test/ViewModels.Tests/ViewModelTests.cs +++ b/test/ViewModels.Tests/ViewModelTests.cs @@ -1,7 +1,7 @@ using FluentAssertions; using Xunit; -namespace Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests { public sealed class ViewModelTests { diff --git a/test/ViewModels.Tests/ViewModels.Tests.csproj b/test/ViewModels.Tests/ViewModels.Tests.csproj index 508872ca5..bbf1a62ff 100644 --- a/test/ViewModels.Tests/ViewModels.Tests.csproj +++ b/test/ViewModels.Tests/ViewModels.Tests.csproj @@ -1,8 +1,6 @@ - net6.0 - false Rocket.Surgery.Airframe.ViewModels.Tests Rocket.Surgery.Airframe.ViewModels.Tests diff --git a/test/directory.build.props b/test/directory.build.props index f83ffacfe..79a039566 100644 --- a/test/directory.build.props +++ b/test/directory.build.props @@ -1,14 +1,19 @@ + + net8.0 + false + true + - - - - - - - + + + + + + + - + \ No newline at end of file From c64c28cf341f564c5f6de61d03d80aebda2cd604 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 01:20:13 -0600 Subject: [PATCH 02/14] more bits gone --- Airframe.sln | 7 - .../Settings/SettingsProviderFixture.cs | 17 -- .../Settings/SettingsProviderTests.cs | 163 ------------------ test/Shiny.Tests/Settings/TestSetting.cs | 16 -- test/Shiny.Tests/Shiny.Tests.csproj | 25 --- 5 files changed, 228 deletions(-) delete mode 100644 test/Shiny.Tests/Settings/SettingsProviderFixture.cs delete mode 100644 test/Shiny.Tests/Settings/SettingsProviderTests.cs delete mode 100644 test/Shiny.Tests/Settings/TestSetting.cs delete mode 100644 test/Shiny.Tests/Shiny.Tests.csproj diff --git a/Airframe.sln b/Airframe.sln index c07530443..3380dac05 100644 --- a/Airframe.sln +++ b/Airframe.sln @@ -58,8 +58,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance", "benchmarks\P EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicrosoftDependencyInjection", "src\MicrosoftDependencyInjection\MicrosoftDependencyInjection.csproj", "{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shiny.Tests", "test\Shiny.Tests\Shiny.Tests.csproj", "{63623831-9DA6-4563-BC94-F9B4007CFE89}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Data.Tests", "test\Data.Tests\Data.Tests.csproj", "{5EC834CA-0341-465E-AE65-A6C181FF303B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Timers.Tests", "test\Timers.Tests\Timers.Tests.csproj", "{903C1B9D-F4F8-4540-8F46-E8EB8F15EAA5}" @@ -167,10 +165,6 @@ Global {F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Release|Any CPU.Build.0 = Release|Any CPU - {63623831-9DA6-4563-BC94-F9B4007CFE89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63623831-9DA6-4563-BC94-F9B4007CFE89}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63623831-9DA6-4563-BC94-F9B4007CFE89}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63623831-9DA6-4563-BC94-F9B4007CFE89}.Release|Any CPU.Build.0 = Release|Any CPU {5EC834CA-0341-465E-AE65-A6C181FF303B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5EC834CA-0341-465E-AE65-A6C181FF303B}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EC834CA-0341-465E-AE65-A6C181FF303B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -207,7 +201,6 @@ Global {4C29DC6C-1251-4B3F-8F2C-447F24230E56} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {F1D890A7-A606-4659-BC44-643B6D54B66C} = {0AF062D9-82F6-4384-B01A-137DF8A880D1} {F8F14442-7FE5-41DE-8C57-3D9D0DDE246D} = {BC256BE7-7896-4159-BB31-9F3D22860391} - {63623831-9DA6-4563-BC94-F9B4007CFE89} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {5EC834CA-0341-465E-AE65-A6C181FF303B} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {903C1B9D-F4F8-4540-8F46-E8EB8F15EAA5} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {64AEB8AB-619C-4AF3-BA3F-407A4FA9A305} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} diff --git a/test/Shiny.Tests/Settings/SettingsProviderFixture.cs b/test/Shiny.Tests/Settings/SettingsProviderFixture.cs deleted file mode 100644 index 8fa2b389f..000000000 --- a/test/Shiny.Tests/Settings/SettingsProviderFixture.cs +++ /dev/null @@ -1,17 +0,0 @@ -using NSubstitute; -using Rocket.Surgery.Airframe.Shiny.Settings; -using Rocket.Surgery.Extensions.Testing.Fixtures; -using Shiny.Stores; - -namespace Airframe.Shiny.Tests.Settings -{ - internal class SettingsProviderFixture : ITestFixtureBuilder - { - private IKeyValueStore _settings = Substitute.For(); - public static implicit operator SettingsProvider(SettingsProviderFixture providerFixture) => providerFixture.Build(); - - public SettingsProviderFixture WithSettings(IKeyValueStore settings) => this.With(ref _settings, settings); - - private SettingsProvider Build() => new SettingsProvider(_settings); - } -} \ No newline at end of file diff --git a/test/Shiny.Tests/Settings/SettingsProviderTests.cs b/test/Shiny.Tests/Settings/SettingsProviderTests.cs deleted file mode 100644 index 9f44d6884..000000000 --- a/test/Shiny.Tests/Settings/SettingsProviderTests.cs +++ /dev/null @@ -1,163 +0,0 @@ -using FluentAssertions; -using NSubstitute; -using Rocket.Surgery.Airframe.Shiny.Settings; -using Shiny.Stores; -using System; -using Xunit; - -namespace Airframe.Shiny.Tests.Settings -{ - public sealed class SettingsProviderTests - { - [Fact] - public void GivenDefaultValue_WhenGet_ThenReturnDefaultValue() - { - // Given - SettingsProvider sut = new SettingsProviderFixture(); - - // When - var result = sut.Get(Key, DefaultValue); - - // Then - result - .Key - .Should() - .Be(Key); - - result - .Value - .Should() - .Be(DefaultValue); - } - - [Fact] - public void GivenDefaultValue_WhenGet_ThenReturnValue() - { - // Given - SettingsProvider sut = new SettingsProviderFixture(); - sut.Set(new Setting(Key, 2)); - - // When - var result = sut.Get(Key, DefaultValue); - - // Then - result - .Value - .Should() - .NotBe(DefaultValue); - } - - [Fact] - public void GivenValueExists_WhenGet_ThenReturnValue() - { - // Given - var key = true.ToString(); - SettingsProvider settings = new SettingsProviderFixture(); - settings.Set(new Setting(key, true)); - - // When - var result = settings.Get(key); - - // Then - result - .Value - .Should() - .BeTrue(); - } - - [Fact] - public void GivenObservingChange_WhenSettingChanged_ThenChangeObserved() - { - // Given - var result = 0; - SettingsProvider sut = new SettingsProviderFixture(); - sut.Set(new Setting(Key, 1)); - sut.Observe(Key).Subscribe(_ => result = _.Value); - - // When - sut.Set(new Setting(Key, 2)); - - // Then - result.Should().Be(2); - } - - [Fact] - public void GivenSetting_WhenSet_ThenPersisted() - { - // Given - var settings = Substitute.For(); - SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings); - sut.Set(new Setting(Key, 1)); - - // When - sut.Set(new Setting(Key, 2)); - - // Then - settings.Received(1).Set(Key, 2); - } - - [Fact] - public void GivenSetting_WhenChanged_ThenPersisted() - { - // Given - var settings = Substitute.For(); - SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings); - sut.Set(new Setting(Key, 5)); - var setting = sut.Get(Key); - - // When - setting.Value = 10; - - // Then - settings.Received(1).Set(Key, 10); - } - - [Fact] - public void GivenSettings_WhenClear_ThenDoesNotContain() - { - // Given - var settings = Substitute.For(); - SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings); - sut.Get(Key, DefaultValue); - - // When - sut.Clear(); - - // Then - settings.Contains(Key).Should().BeFalse(); - } - - [Fact] - public void GivenSettings_WhenContains_ThenContains() - { - // Given - var settings = Substitute.For(); - SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings); - sut.Get(Key, DefaultValue); - - // When - var result = sut.Contains(Key); - - // Then - result.Should().BeTrue(); - } - - [Fact] - public void GivenSettings_WhenRemoved_ThenRemoved() - { - // Given - var settings = Substitute.For(); - SettingsProvider sut = new SettingsProviderFixture().WithSettings(settings); - sut.Get(Key, DefaultValue); - - // When - sut.Remove(Key); - - // Then - settings.Received().Remove(Key); - } - - private const string Key = "thing"; - private const int DefaultValue = 1; - } -} \ No newline at end of file diff --git a/test/Shiny.Tests/Settings/TestSetting.cs b/test/Shiny.Tests/Settings/TestSetting.cs deleted file mode 100644 index a72377d36..000000000 --- a/test/Shiny.Tests/Settings/TestSetting.cs +++ /dev/null @@ -1,16 +0,0 @@ -using ReactiveUI; - -namespace Airframe.Shiny.Tests.Settings -{ - internal class TestObject : ReactiveObject - { - - private string _name = string.Empty; - - public string Name - { - get => _name; - set => this.RaiseAndSetIfChanged(ref _name, value); - } - } -} \ No newline at end of file diff --git a/test/Shiny.Tests/Shiny.Tests.csproj b/test/Shiny.Tests/Shiny.Tests.csproj deleted file mode 100644 index 424a6f7e8..000000000 --- a/test/Shiny.Tests/Shiny.Tests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net6.0 - false - Rocket.Surgery.Airframe.Shiny.Tests - Rocket.Surgery.Airframe.Shiny.Tests - - - - - - - - - - - - - - - - - - From a632c2127c437a2a862f89142162c6a823881cea Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:12:58 -0600 Subject: [PATCH 03/14] everything is building, tests are failing! --- .gitignore | 3 +- .nuke/build.schema.json | 28 +++++++++--- Airframe.sln | 9 +++- directory.packages.props | 1 + src/Core/Connectivity/INetworkState.cs | 2 +- .../Connectivity/NetworkStateChangedEvent.cs | 25 ++++++++--- src/Core/Navigation/Arguments.cs | 2 +- .../Background/IBackgroundOperation.cs | 2 +- src/Synthetic/Coffee/CoffeeClientMock.cs | 2 +- src/Synthetic/Coffee/CoffeeDataService.cs | 2 +- src/Synthetic/Coffee/CoffeeDto.cs | 2 +- src/Synthetic/Coffee/ICoffeeDataService.cs | 2 +- src/Synthetic/Drinks/DrinkClientMock.cs | 2 +- src/Synthetic/Drinks/DrinkDataService.cs | 2 +- src/Synthetic/Drinks/DrinkDto.cs | 2 +- src/Synthetic/Drinks/DrinkType.cs | 2 +- src/Synthetic/Drinks/IDrinkService.cs | 2 +- src/ViewModels/NavigableViewModelBase.cs | 7 --- src/ViewModels/ViewModelBase.cs | 8 +++- src/ViewModels/ViewModels.csproj | 28 ++++++------ test/Airframe.Testing/Airframe.Testing.csproj | 13 ++++++ .../SchedulerProviderFixture.cs | 26 +++++++++++ .../Airframe.Testing/SchedulerProviderMock.cs | 30 +++++++++++++ .../SchedulerProviderFixture.cs | 41 ----------------- .../Composition.Tests/CompositionRootTests.cs | 3 +- test/Composition.Tests/DryIocModuleTests.cs | 3 +- .../IRegistrarExtensionTests.cs | 3 +- test/Composition.Tests/TestModule.cs | 3 +- test/Composition.Tests/TestView.cs | 2 +- test/Composition.Tests/TestViewModel.cs | 2 +- .../ComplexOptions/AncestorObject.cs | 2 +- .../ComplexOptions/ComplexObject.cs | 2 +- .../ComplexOptions/ComplexSettings.cs | 2 +- .../ComplexOptions/LevelSettings.cs | 2 +- .../ComplexOptions/ParentObject.cs | 2 +- .../ConfigurationBuilderTestData.cs | 1 + .../ConfigurationOptionsTestData.cs | 1 + .../MultipleConfigurationOptionsTestData.cs | 1 + test/Timers.Tests/DecrementTimerFixture.cs | 12 +++-- test/Timers.Tests/DecrementTimerTests.cs | 39 ++++++---------- test/Timers.Tests/DivisibleTimeSpanData.cs | 2 +- test/Timers.Tests/DivisibleTimerFixture.cs | 10 ++--- test/Timers.Tests/DivisibleTimerTests.cs | 14 +++--- test/Timers.Tests/IncrementTimerFixture.cs | 13 +++--- test/Timers.Tests/IncrementTimerTests.cs | 44 +++++++------------ test/Timers.Tests/Timers.Tests.csproj | 1 + .../NavigableViewModelTests.cs | 31 ++++--------- .../TestNavigationViewModel.cs | 34 ++++++-------- .../TestNavigationViewModelFixture.cs | 4 ++ test/ViewModels.Tests/TestViewModel.cs | 2 +- test/directory.build.props | 1 + 51 files changed, 247 insertions(+), 232 deletions(-) create mode 100644 test/Airframe.Testing/Airframe.Testing.csproj create mode 100644 test/Airframe.Testing/SchedulerProviderFixture.cs create mode 100644 test/Airframe.Testing/SchedulerProviderMock.cs delete mode 100644 test/Airframe.Tests/SchedulerProviderFixture.cs diff --git a/.gitignore b/.gitignore index 4f10cc335..1f6d5bb48 100644 --- a/.gitignore +++ b/.gitignore @@ -340,4 +340,5 @@ ASALocalRun/ # Code Coverage coverage/ -test/**/coverage.json \ No newline at end of file +test/**/coverage.json +.nuke/temp/ diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 1850f5910..996bbb328 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -88,22 +88,30 @@ "type": "string", "enum": [ "Build", - "BuildVersion", "Clean", + "CoreBuild", + "CorePack", + "CoreRestore", "CoreTest", "Default", + "DotNetFormat", + "DotnetToolRestore", "GenerateCodeCoverageBadges", "GenerateCodeCoverageReport", "GenerateCodeCoverageReportCobertura", "GenerateCodeCoverageSummary", "GenerateReadme", + "JetBrainsCleanupCode", "Lint", "LintGitAdd", - "NetPack", - "NetRestore", + "LintPublicApiAnalyzers", + "LintStaged", + "MoveUnshippedToShipped", "Pack", "PostLint", + "RegenerateBuildConfigurations", "Restore", + "ShipPublicApis", "Test", "TriggerCodeCoverageReports" ] @@ -120,22 +128,30 @@ "type": "string", "enum": [ "Build", - "BuildVersion", "Clean", + "CoreBuild", + "CorePack", + "CoreRestore", "CoreTest", "Default", + "DotNetFormat", + "DotnetToolRestore", "GenerateCodeCoverageBadges", "GenerateCodeCoverageReport", "GenerateCodeCoverageReportCobertura", "GenerateCodeCoverageSummary", "GenerateReadme", + "JetBrainsCleanupCode", "Lint", "LintGitAdd", - "NetPack", - "NetRestore", + "LintPublicApiAnalyzers", + "LintStaged", + "MoveUnshippedToShipped", "Pack", "PostLint", + "RegenerateBuildConfigurations", "Restore", + "ShipPublicApis", "Test", "TriggerCodeCoverageReports" ] diff --git a/Airframe.sln b/Airframe.sln index 3380dac05..cbee59cdf 100644 --- a/Airframe.sln +++ b/Airframe.sln @@ -111,7 +111,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{F9E0EB .husky/commit-msg = .husky/commit-msg EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{3AB63C21-EA38-4EC8-BECC-FC10CFFC5195}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Airframe.Testing", "test\Airframe.Testing\Airframe.Testing.csproj", "{03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -185,12 +185,17 @@ Global {A250A99B-0225-4B5D-9753-ED1DF770D61D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A250A99B-0225-4B5D-9753-ED1DF770D61D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A250A99B-0225-4B5D-9753-ED1DF770D61D}.Release|Any CPU.Build.0 = Release|Any CPU + {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {CA4B6910-402D-40C3-99C6-8DF8E3ABF041} = {BC256BE7-7896-4159-BB31-9F3D22860391} + {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {36A9DAA0-FCD4-41A3-A046-C755937CA701} = {BC256BE7-7896-4159-BB31-9F3D22860391} {D8A98936-BA4C-44A9-BD39-34DCBEF665C9} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {D42E447B-522C-48E6-82A9-B24780BC7A35} = {BC256BE7-7896-4159-BB31-9F3D22860391} @@ -209,7 +214,7 @@ Global {6813747B-13DB-4144-AB19-22C84E734517} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {9FF05512-3C79-4FF9-8006-1313E2AF8A65} = {6813747B-13DB-4144-AB19-22C84E734517} {F9E0EBA5-5737-440E-8F30-20CCFC207E9E} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} - {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {3AB63C21-EA38-4EC8-BECC-FC10CFFC5195} + {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8F0DF64A-C8D5-41DF-B4C9-5C70526644DF} diff --git a/directory.packages.props b/directory.packages.props index 846aa558d..0c5ba5647 100644 --- a/directory.packages.props +++ b/directory.packages.props @@ -37,6 +37,7 @@ + diff --git a/src/Core/Connectivity/INetworkState.cs b/src/Core/Connectivity/INetworkState.cs index 665d5d0ba..2c715c8a3 100644 --- a/src/Core/Connectivity/INetworkState.cs +++ b/src/Core/Connectivity/INetworkState.cs @@ -11,7 +11,7 @@ public interface INetworkState : IObservable /// /// Gets an observable sequence notifying if the device has connectivity. /// - /// + /// A value indicating the is a signal. IObservable HasSignal() => this .Select(changedEvent => changedEvent.HasSignal()) diff --git a/src/Core/Connectivity/NetworkStateChangedEvent.cs b/src/Core/Connectivity/NetworkStateChangedEvent.cs index 0c9ba378b..57d7fbc70 100644 --- a/src/Core/Connectivity/NetworkStateChangedEvent.cs +++ b/src/Core/Connectivity/NetworkStateChangedEvent.cs @@ -4,13 +4,16 @@ namespace Rocket.Surgery.Airframe.Connectivity { + /// + /// Class representing the for network state changes. + /// public class NetworkStateChangedEvent : EventArgs { /// /// Initializes a new instance of the class. /// - /// - /// + /// The current network access. + /// The connection profile. public NetworkStateChangedEvent(NetworkAccess access, params ConnectionProfile[] connectionProfiles) { NetworkAccess = access; @@ -21,20 +24,32 @@ public NetworkStateChangedEvent(NetworkAccess access, params ConnectionProfile[] /// Initializes a new instance of the class. /// /// The current network access. - /// + /// The connection profile. public NetworkStateChangedEvent(NetworkAccess access, IEnumerable connectionProfiles) - : this(access, connectionProfiles.ToArray()) { } + : this(access, connectionProfiles.ToArray()) + { + } + /// + /// Gets the network access. + /// public NetworkAccess NetworkAccess { get; } + /// + /// Gets the connection profiles. + /// public IReadOnlyCollection ConnectionProfiles { get; } + /// + /// Gets a value indicating whether there is a signal. + /// + /// A signal. public bool HasSignal() => HasValidProfile() && HasNetworkAccess(); /// /// Determines if the signal is degraded. /// - /// + /// Degraded signal. public bool Degraded() => NetworkAccess > NetworkAccess.None || ContainsProfile(ConnectionProfile.Unknown); /// diff --git a/src/Core/Navigation/Arguments.cs b/src/Core/Navigation/Arguments.cs index d6f616ed8..b0430cf0c 100644 --- a/src/Core/Navigation/Arguments.cs +++ b/src/Core/Navigation/Arguments.cs @@ -3,4 +3,4 @@ namespace Rocket.Surgery.Airframe.Navigation; /// /// Represents a basic argument. /// -public class Arguments(string query) : ArgumentsBase(query); \ No newline at end of file +public class Arguments(string query = "") : ArgumentsBase(query); \ No newline at end of file diff --git a/src/Core/Operations/Background/IBackgroundOperation.cs b/src/Core/Operations/Background/IBackgroundOperation.cs index b93cd1f3e..8e2aad95d 100644 --- a/src/Core/Operations/Background/IBackgroundOperation.cs +++ b/src/Core/Operations/Background/IBackgroundOperation.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe.Background { /// /// Interface representing an operation to run in the background on a specific platform. diff --git a/src/Synthetic/Coffee/CoffeeClientMock.cs b/src/Synthetic/Coffee/CoffeeClientMock.cs index c7c5a31b8..c5788941b 100644 --- a/src/Synthetic/Coffee/CoffeeClientMock.cs +++ b/src/Synthetic/Coffee/CoffeeClientMock.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Coffee { /// /// Represents an that returns . diff --git a/src/Synthetic/Coffee/CoffeeDataService.cs b/src/Synthetic/Coffee/CoffeeDataService.cs index 0626a685e..b950adf74 100644 --- a/src/Synthetic/Coffee/CoffeeDataService.cs +++ b/src/Synthetic/Coffee/CoffeeDataService.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Coffee { /// /// Represents a coffee data service. diff --git a/src/Synthetic/Coffee/CoffeeDto.cs b/src/Synthetic/Coffee/CoffeeDto.cs index 6f519efb3..6c7d2485f 100644 --- a/src/Synthetic/Coffee/CoffeeDto.cs +++ b/src/Synthetic/Coffee/CoffeeDto.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Coffee { /// /// A coffee data transfer object. diff --git a/src/Synthetic/Coffee/ICoffeeDataService.cs b/src/Synthetic/Coffee/ICoffeeDataService.cs index 26a0231f8..7ae456463 100644 --- a/src/Synthetic/Coffee/ICoffeeDataService.cs +++ b/src/Synthetic/Coffee/ICoffeeDataService.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Coffee { /// /// Interface representing a coffee data service. diff --git a/src/Synthetic/Drinks/DrinkClientMock.cs b/src/Synthetic/Drinks/DrinkClientMock.cs index ac23d4c49..e34828602 100644 --- a/src/Synthetic/Drinks/DrinkClientMock.cs +++ b/src/Synthetic/Drinks/DrinkClientMock.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Drinks { /// /// Represents an that returns . diff --git a/src/Synthetic/Drinks/DrinkDataService.cs b/src/Synthetic/Drinks/DrinkDataService.cs index 677f7fe5a..9f35469dd 100644 --- a/src/Synthetic/Drinks/DrinkDataService.cs +++ b/src/Synthetic/Drinks/DrinkDataService.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Drinks { /// /// Represents a coffee data service. diff --git a/src/Synthetic/Drinks/DrinkDto.cs b/src/Synthetic/Drinks/DrinkDto.cs index d18076ac4..37ba0a11d 100644 --- a/src/Synthetic/Drinks/DrinkDto.cs +++ b/src/Synthetic/Drinks/DrinkDto.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Drinks { /// /// A coffee drink data transfer object. diff --git a/src/Synthetic/Drinks/DrinkType.cs b/src/Synthetic/Drinks/DrinkType.cs index 316de0a77..a378761ab 100644 --- a/src/Synthetic/Drinks/DrinkType.cs +++ b/src/Synthetic/Drinks/DrinkType.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Drinks { /// /// Enumeration representing espresso drink types. diff --git a/src/Synthetic/Drinks/IDrinkService.cs b/src/Synthetic/Drinks/IDrinkService.cs index f8674a172..552bccefa 100644 --- a/src/Synthetic/Drinks/IDrinkService.cs +++ b/src/Synthetic/Drinks/IDrinkService.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic.Drinks { /// /// Interface representing a coffee drink data service. diff --git a/src/ViewModels/NavigableViewModelBase.cs b/src/ViewModels/NavigableViewModelBase.cs index 94dcd1e58..384b2632a 100644 --- a/src/ViewModels/NavigableViewModelBase.cs +++ b/src/ViewModels/NavigableViewModelBase.cs @@ -10,13 +10,6 @@ namespace Rocket.Surgery.Airframe.ViewModels /// public abstract class NavigableViewModelBase : ViewModelBase, INavigated, IDestructible, IInitialize { - /// - /// Initializes a new instance of the class. - /// - protected NavigableViewModelBase() - { - } - /// void IInitialize.OnInitialize(IArguments arguments) { diff --git a/src/ViewModels/ViewModelBase.cs b/src/ViewModels/ViewModelBase.cs index d295f4d63..b09d6ea0a 100644 --- a/src/ViewModels/ViewModelBase.cs +++ b/src/ViewModels/ViewModelBase.cs @@ -1,13 +1,19 @@ using System; using System.Reactive.Disposables; +using ReactiveMarbles.Mvvm; namespace Rocket.Surgery.Airframe.ViewModels { /// /// Base ReactiveUI View Model. /// - public abstract class ViewModelBase : IDisposable + public abstract class ViewModelBase : RxObject, IDisposable { + /// + /// Gets or sets a value indicating whether this view model is loading. + /// + public bool IsLoading { get; protected set; } + /// /// Gets the collection of disposables. /// diff --git a/src/ViewModels/ViewModels.csproj b/src/ViewModels/ViewModels.csproj index 5621d4130..a70aa18c3 100644 --- a/src/ViewModels/ViewModels.csproj +++ b/src/ViewModels/ViewModels.csproj @@ -1,20 +1,20 @@  - - net8.0 - Rocket.Surgery.Airframe.ViewModels - Rocket.Surgery.Airframe.ViewModels - Rocket.Surgery.Airframe.ViewModels - ReactiveUI base view model abstractions. - + + net8.0 + Rocket.Surgery.Airframe.ViewModels + Rocket.Surgery.Airframe.ViewModels + Rocket.Surgery.Airframe.ViewModels + Observable base view model abstractions. + - - - - + + + + - - - + + + diff --git a/test/Airframe.Testing/Airframe.Testing.csproj b/test/Airframe.Testing/Airframe.Testing.csproj new file mode 100644 index 000000000..4a1d8ab90 --- /dev/null +++ b/test/Airframe.Testing/Airframe.Testing.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/test/Airframe.Testing/SchedulerProviderFixture.cs b/test/Airframe.Testing/SchedulerProviderFixture.cs new file mode 100644 index 000000000..e93634f71 --- /dev/null +++ b/test/Airframe.Testing/SchedulerProviderFixture.cs @@ -0,0 +1,26 @@ +using Microsoft.Reactive.Testing; +using Rocket.Surgery.Airframe; +using Rocket.Surgery.Extensions.Testing.Fixtures; +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Concurrency; + +namespace Airframe.Testing; + +[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order")] +public class SchedulerProviderFixture : ITestFixtureBuilder +{ + public static implicit operator SchedulerProviderMock(SchedulerProviderFixture fixture) => fixture.Build(); + + public SchedulerProviderFixture WithUserInterfaceScheduler(IScheduler scheduler) => this.With(ref _mainThreadScheduler, scheduler); + + public SchedulerProviderFixture WithBackgroundScheduler(IScheduler scheduler) => this.With(ref _backgroundThreadScheduler, scheduler); + + public SchedulerProviderFixture WithTestScheduler(IScheduler scheduler) => WithUserInterfaceScheduler(scheduler).WithBackgroundScheduler(scheduler); + + public ISchedulerProvider AsInterface() => Build(); + + private SchedulerProviderMock Build() => new SchedulerProviderMock(_mainThreadScheduler, _backgroundThreadScheduler); + + private IScheduler _mainThreadScheduler = new TestScheduler(); + private IScheduler _backgroundThreadScheduler = new TestScheduler(); +} \ No newline at end of file diff --git a/test/Airframe.Testing/SchedulerProviderMock.cs b/test/Airframe.Testing/SchedulerProviderMock.cs new file mode 100644 index 000000000..4a3ae484f --- /dev/null +++ b/test/Airframe.Testing/SchedulerProviderMock.cs @@ -0,0 +1,30 @@ +using Microsoft.Reactive.Testing; +using Rocket.Surgery.Airframe; +using System.Reactive.Concurrency; + +namespace Airframe.Testing; + +public sealed class SchedulerProviderMock : ISchedulerProvider +{ + internal SchedulerProviderMock(IScheduler userInterfaceTestScheduler, IScheduler backgroundTestScheduler) + { + UserInterfaceTestScheduler = userInterfaceTestScheduler as TestScheduler ?? throw new ArgumentOutOfRangeException(nameof(userInterfaceTestScheduler)); + BackgroundTestScheduler = backgroundTestScheduler as TestScheduler ?? throw new ArgumentOutOfRangeException(nameof(userInterfaceTestScheduler)); + } + + /// + IScheduler ISchedulerProvider.UserInterfaceThread => UserInterfaceTestScheduler; + + /// + IScheduler ISchedulerProvider.BackgroundThread => BackgroundTestScheduler; + + /// + /// Gets the test user interface scheduler. + /// + public TestScheduler UserInterfaceTestScheduler { get; } + + /// + /// Gets the test background scheduler. + /// + public TestScheduler BackgroundTestScheduler { get; } +} \ No newline at end of file diff --git a/test/Airframe.Tests/SchedulerProviderFixture.cs b/test/Airframe.Tests/SchedulerProviderFixture.cs deleted file mode 100644 index 10b9d1021..000000000 --- a/test/Airframe.Tests/SchedulerProviderFixture.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.Reactive.Testing; -using Rocket.Surgery.Extensions.Testing.Fixtures; -using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive.Concurrency; - -namespace Rocket.Surgery.Airframe.Tests -{ - [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order")] - public class SchedulerProviderFixture : ITestFixtureBuilder - { - public static implicit operator SchedulerProviderMock(SchedulerProviderFixture fixture) => fixture.Build(); - - public SchedulerProviderFixture WithTestScheduler(IScheduler scheduler) => this.With(ref _mainThreadScheduler, scheduler) - .With(ref _backgroundThreadScheduler, scheduler); - - private SchedulerProviderMock Build() => new SchedulerProviderMock(_mainThreadScheduler, _backgroundThreadScheduler); - - private IScheduler _mainThreadScheduler = new TestScheduler(); - private IScheduler _backgroundThreadScheduler = new TestScheduler(); - - public class SchedulerProviderMock(IScheduler userInterfaceTestScheduler, IScheduler backgroundTestScheduler) : ISchedulerProvider - { - /// - IScheduler ISchedulerProvider.UserInterfaceThread => UserInterfaceTestScheduler; - - /// - IScheduler ISchedulerProvider.BackgroundThread => BackgroundTestScheduler; - - /// - /// Gets the test user interface scheduler. - /// - public TestScheduler UserInterfaceTestScheduler { get; } = userInterfaceTestScheduler as TestScheduler ?? throw new ArgumentOutOfRangeException(nameof(userInterfaceTestScheduler)); - - /// - /// Gets the test background scheduler. - /// - public TestScheduler BackgroundTestScheduler { get; } = backgroundTestScheduler as TestScheduler ?? throw new ArgumentOutOfRangeException(nameof(userInterfaceTestScheduler)); - } - } -} \ No newline at end of file diff --git a/test/Composition.Tests/CompositionRootTests.cs b/test/Composition.Tests/CompositionRootTests.cs index 8d0748aa6..9e031e259 100644 --- a/test/Composition.Tests/CompositionRootTests.cs +++ b/test/Composition.Tests/CompositionRootTests.cs @@ -1,10 +1,9 @@ using DryIoc; using FluentAssertions; using ReactiveUI; -using Rocket.Surgery.Airframe.Composition; using Xunit; -namespace Composition.Tests; +namespace Rocket.Surgery.Airframe.Composition.Tests; public sealed class CompositionRootTests { diff --git a/test/Composition.Tests/DryIocModuleTests.cs b/test/Composition.Tests/DryIocModuleTests.cs index f7f95b005..60c7c94f4 100644 --- a/test/Composition.Tests/DryIocModuleTests.cs +++ b/test/Composition.Tests/DryIocModuleTests.cs @@ -1,9 +1,8 @@ using DryIoc; using FluentAssertions; -using Rocket.Surgery.Airframe.Composition; using Xunit; -namespace Composition.Tests; +namespace Rocket.Surgery.Airframe.Composition.Tests; public sealed class DryIocModuleTests { diff --git a/test/Composition.Tests/IRegistrarExtensionTests.cs b/test/Composition.Tests/IRegistrarExtensionTests.cs index 44d2da515..35a5f5f2c 100644 --- a/test/Composition.Tests/IRegistrarExtensionTests.cs +++ b/test/Composition.Tests/IRegistrarExtensionTests.cs @@ -1,10 +1,9 @@ using DryIoc; using FluentAssertions; using ReactiveUI; -using Rocket.Surgery.Airframe.Composition; using Xunit; -namespace Composition.Tests; +namespace Rocket.Surgery.Airframe.Composition.Tests; public sealed class IRegistrarExtensionTests { diff --git a/test/Composition.Tests/TestModule.cs b/test/Composition.Tests/TestModule.cs index 4b7041fe2..ad8be3642 100644 --- a/test/Composition.Tests/TestModule.cs +++ b/test/Composition.Tests/TestModule.cs @@ -1,7 +1,6 @@ using DryIoc; -using Rocket.Surgery.Airframe.Composition; -namespace Composition.Tests; +namespace Rocket.Surgery.Airframe.Composition.Tests; public class TestModule : DryIocModule { diff --git a/test/Composition.Tests/TestView.cs b/test/Composition.Tests/TestView.cs index 8dfa81896..8251ff84d 100644 --- a/test/Composition.Tests/TestView.cs +++ b/test/Composition.Tests/TestView.cs @@ -1,6 +1,6 @@ using ReactiveUI; -namespace Composition.Tests; +namespace Rocket.Surgery.Airframe.Composition.Tests; public class TestView : IViewFor { diff --git a/test/Composition.Tests/TestViewModel.cs b/test/Composition.Tests/TestViewModel.cs index 109e207ed..c7cb417c2 100644 --- a/test/Composition.Tests/TestViewModel.cs +++ b/test/Composition.Tests/TestViewModel.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; -namespace Composition.Tests; +namespace Rocket.Surgery.Airframe.Composition.Tests; [PublicAPI] public class TestViewModel; \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs index 03f0a109c..098c2b233 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs @@ -1,4 +1,4 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions { public class AncestorObject { diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs index 2f4aada3a..b478760e0 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs @@ -1,4 +1,4 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions { public class ComplexObject { diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs index cc7681ca9..435f74271 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs @@ -1,6 +1,6 @@ using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions { public class ComplexSettings { diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs index 962af49fa..f4f94f2ac 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs @@ -1,4 +1,4 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions { public class LevelSettings { diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs index 51339039e..94d0dd22b 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs @@ -1,4 +1,4 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions { public class ParentObject { diff --git a/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs b/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs index 303bedf6c..024f32d78 100644 --- a/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; using System.Collections.Generic; namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests diff --git a/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs index 2b7ac2e21..1352b1ae1 100644 --- a/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; using System.Collections.Generic; namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests diff --git a/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs index 924bf7e36..df8103085 100644 --- a/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions; using System.Collections.Generic; diff --git a/test/Timers.Tests/DecrementTimerFixture.cs b/test/Timers.Tests/DecrementTimerFixture.cs index 7975169ba..4e8fd28ba 100644 --- a/test/Timers.Tests/DecrementTimerFixture.cs +++ b/test/Timers.Tests/DecrementTimerFixture.cs @@ -1,18 +1,16 @@ -using Rocket.Surgery.Airframe.Tests; -using Rocket.Surgery.Airframe.Timers; +using Airframe.Testing; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { internal class DecrementTimerFixture : ITestFixtureBuilder { - private SchedulerProvider _schedulerProvider = new SchedulerProviderFixture(); - public static implicit operator DecrementTimer(DecrementTimerFixture fixture) => fixture.Build(); - public DecrementTimerFixture WithProvider(SchedulerProvider schedulerProvider) => - this.With(ref _schedulerProvider, schedulerProvider); + public DecrementTimerFixture WithProvider(ISchedulerProvider schedulerProvider) => this.With(ref _schedulerProvider, schedulerProvider); private DecrementTimer Build() => new DecrementTimer(_schedulerProvider); + + private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); } } \ No newline at end of file diff --git a/test/Timers.Tests/DecrementTimerTests.cs b/test/Timers.Tests/DecrementTimerTests.cs index f55a9b744..e54709243 100644 --- a/test/Timers.Tests/DecrementTimerTests.cs +++ b/test/Timers.Tests/DecrementTimerTests.cs @@ -1,13 +1,12 @@ +using Airframe.Testing; using FluentAssertions; using Microsoft.Reactive.Testing; using ReactiveUI.Testing; -using Rocket.Surgery.Airframe.Forms; using Rocket.Surgery.Airframe.Tests; -using Rocket.Surgery.Airframe.Timers; using System; using Xunit; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { public class DecrementTimerTests : TestBase { @@ -29,7 +28,7 @@ public void Should_Be_Running_When_Started() { // Given var testScheduler = new TestScheduler(); - SchedulerProvider schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); // When @@ -44,19 +43,15 @@ public void Should_Be_Running_When_Started() public void Should_Advance_When_Started() { // Given - var testScheduler = new TestScheduler(); - var schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); var timer = TimeSpan.Zero; - sut.Subscribe(x => - { - timer = x; - }); + using var _ = sut.Subscribe(x => timer = x); // When sut.Start(TimeSpan.FromMinutes(1)); - testScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); // Then timer.Should().Be(TimeSpan.FromSeconds(59)); @@ -67,20 +62,18 @@ public void Should_Resume_Where_Stopped() { // Given var testScheduler = new TestScheduler(); - var schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); var timer = TimeSpan.Zero; sut.Start(TimeSpan.FromMinutes(1)); - sut.Subscribe(x => - { - timer = x; - }); + using var _ = sut.Subscribe(x => timer = x); sut.Start(TimeSpan.FromMinutes(1)); testScheduler.AdvanceByMs(InitialMilliseconds); sut.Stop(); testScheduler.AdvanceByMs(OneThousandMilliseconds); + // When sut.Start(); @@ -92,24 +85,20 @@ public void Should_Resume_Where_Stopped() public void Should_Resume_After_Stopped() { // Given - var testScheduler = new TestScheduler(); - var schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); var timer = TimeSpan.Zero; - sut.Subscribe(x => - { - timer = x; - }); + sut.Subscribe(x => timer = x); sut.Start(TimeSpan.FromMinutes(1)); - testScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); sut.Stop(); - testScheduler.AdvanceByMs(OneThousandMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); // When sut.Start(); - testScheduler.AdvanceByMs(OneThousandMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); // Then timer.Should().Be(TimeSpan.FromSeconds(58)); diff --git a/test/Timers.Tests/DivisibleTimeSpanData.cs b/test/Timers.Tests/DivisibleTimeSpanData.cs index c69e0c23a..c19b33704 100644 --- a/test/Timers.Tests/DivisibleTimeSpanData.cs +++ b/test/Timers.Tests/DivisibleTimeSpanData.cs @@ -1,7 +1,7 @@ using System; using Xunit; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { internal class DivisibleTimeSpanData : TheoryData { diff --git a/test/Timers.Tests/DivisibleTimerFixture.cs b/test/Timers.Tests/DivisibleTimerFixture.cs index db63fb9ce..0f870e1bf 100644 --- a/test/Timers.Tests/DivisibleTimerFixture.cs +++ b/test/Timers.Tests/DivisibleTimerFixture.cs @@ -1,17 +1,15 @@ -using Rocket.Surgery.Airframe.Forms; -using Rocket.Surgery.Airframe.Tests; -using Rocket.Surgery.Airframe.Timers; +using Airframe.Testing; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { internal class DivisibleTimerFixture : ITestFixtureBuilder { - private SchedulerProvider _schedulerProvider = new SchedulerProviderFixture(); + private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); public static implicit operator DivisibleTimer(DivisibleTimerFixture fixture) => fixture.Build(); - public DivisibleTimerFixture WithProvider(SchedulerProvider scheduler) => this.With(ref _schedulerProvider, scheduler); + public DivisibleTimerFixture WithProvider(ISchedulerProvider scheduler) => this.With(ref _schedulerProvider, scheduler); private DivisibleTimer Build() => new DivisibleTimer(_schedulerProvider); } diff --git a/test/Timers.Tests/DivisibleTimerTests.cs b/test/Timers.Tests/DivisibleTimerTests.cs index 3fb3203cf..abaf51f80 100644 --- a/test/Timers.Tests/DivisibleTimerTests.cs +++ b/test/Timers.Tests/DivisibleTimerTests.cs @@ -1,12 +1,10 @@ +using Airframe.Testing; using FluentAssertions; -using Microsoft.Reactive.Testing; -using Rocket.Surgery.Airframe.Tests; -using Rocket.Surgery.Airframe.Timers; using System; using System.Reactive.Linq; using Xunit; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { public sealed class DivisibleTimerTests { @@ -29,14 +27,14 @@ public void Should_Run_Correct_Partition_Count() { // Given int count = 1; - var testScheduler = new TestScheduler(); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); DivisibleTimer sut = - new DivisibleTimerFixture().WithProvider(new SchedulerProviderFixture().WithTestScheduler(testScheduler)); - sut.Interval.ObserveOn(testScheduler).Subscribe(_ => count++); + new DivisibleTimerFixture().WithProvider(schedulerProvider); + sut.Interval.ObserveOn(schedulerProvider.UserInterfaceTestScheduler).Subscribe(_ => count++); // When sut.Start(4, TimeSpan.FromHours(1)); - testScheduler.AdvanceBy(TimeSpan.FromMinutes(30).Ticks); + schedulerProvider.UserInterfaceTestScheduler.AdvanceBy(TimeSpan.FromMinutes(30).Ticks); // Then count.Should().Be(4); diff --git a/test/Timers.Tests/IncrementTimerFixture.cs b/test/Timers.Tests/IncrementTimerFixture.cs index 85c4cf36f..7af7d6365 100644 --- a/test/Timers.Tests/IncrementTimerFixture.cs +++ b/test/Timers.Tests/IncrementTimerFixture.cs @@ -1,19 +1,16 @@ -using Rocket.Surgery.Airframe.Forms; -using Rocket.Surgery.Airframe.Tests; -using Rocket.Surgery.Airframe.Timers; +using Airframe.Testing; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { internal class IncrementTimerFixture : ITestFixtureBuilder { - private SchedulerProvider _schedulerProvider = new SchedulerProviderFixture(); - public static implicit operator IncrementTimer(IncrementTimerFixture fixture) => fixture.Build(); - public IncrementTimerFixture WithProvider(SchedulerProvider schedulerProvider) => - this.With(ref _schedulerProvider, schedulerProvider); + public IncrementTimerFixture WithProvider(ISchedulerProvider schedulerProvider) => this.With(ref _schedulerProvider, schedulerProvider); private IncrementTimer Build() => new IncrementTimer(_schedulerProvider); + + private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); } } \ No newline at end of file diff --git a/test/Timers.Tests/IncrementTimerTests.cs b/test/Timers.Tests/IncrementTimerTests.cs index b49770d69..a05e2d180 100644 --- a/test/Timers.Tests/IncrementTimerTests.cs +++ b/test/Timers.Tests/IncrementTimerTests.cs @@ -1,13 +1,11 @@ +using Airframe.Testing; using FluentAssertions; -using Microsoft.Reactive.Testing; using ReactiveUI.Testing; -using Rocket.Surgery.Airframe.Forms; using Rocket.Surgery.Airframe.Tests; -using Rocket.Surgery.Airframe.Timers; using System; using Xunit; -namespace Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests { public class IncrementTimerTests : TestBase { @@ -28,13 +26,12 @@ public void Should_Not_Be_Running_When_Constructed() public void Should_Be_Running_When_Started() { // Given - var testScheduler = new TestScheduler(); - SchedulerProvider schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); // When sut.Start(TimeSpan.FromMinutes(25)); - testScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); // Then sut.IsRunning.Should().BeTrue(); @@ -44,8 +41,7 @@ public void Should_Be_Running_When_Started() public void Should_Advance_When_Started() { // Given - var testScheduler = new TestScheduler(); - var schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); var timer = TimeSpan.Zero; @@ -56,8 +52,8 @@ public void Should_Advance_When_Started() // When sut.Start(); - testScheduler.AdvanceByMs(InitialMilliseconds); - testScheduler.AdvanceByMs(OneThousandMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); // Then timer.Should().Be(TimeSpan.FromSeconds(2)); @@ -67,21 +63,17 @@ public void Should_Advance_When_Started() public void Should_Resume_Where_Stopped() { // Given - var testScheduler = new TestScheduler(); - var schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); var timer = TimeSpan.Zero; sut.Start(TimeSpan.FromMinutes(1)); - sut.Subscribe(x => - { - timer = x; - }); + using var _ = sut.Subscribe(x => timer = x); sut.Start(); - testScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); sut.Stop(); - testScheduler.AdvanceByMs(OneThousandMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); // When sut.Start(); @@ -94,24 +86,20 @@ public void Should_Resume_Where_Stopped() public void Should_Resume_After_Stopped() { // Given - var testScheduler = new TestScheduler(); - var schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); var timer = TimeSpan.Zero; - sut.Subscribe(x => - { - timer = x; - }); + sut.Subscribe(x => timer = x); sut.Start(); - testScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); sut.Stop(); - testScheduler.AdvanceByMs(OneThousandMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); // When sut.Start(); - testScheduler.AdvanceByMs(OneThousandMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); // Then timer.Should().Be(TimeSpan.FromSeconds(2)); diff --git a/test/Timers.Tests/Timers.Tests.csproj b/test/Timers.Tests/Timers.Tests.csproj index 4bf54c124..4eeff04fe 100644 --- a/test/Timers.Tests/Timers.Tests.csproj +++ b/test/Timers.Tests/Timers.Tests.csproj @@ -7,6 +7,7 @@ + diff --git a/test/ViewModels.Tests/NavigableViewModelTests.cs b/test/ViewModels.Tests/NavigableViewModelTests.cs index 64961d005..e79e99cc8 100644 --- a/test/ViewModels.Tests/NavigableViewModelTests.cs +++ b/test/ViewModels.Tests/NavigableViewModelTests.cs @@ -1,4 +1,5 @@ using FluentAssertions; +using Rocket.Surgery.Airframe.Navigation; using Rocket.Surgery.Airframe.Tests; using Xunit; @@ -15,10 +16,10 @@ public void Should_Have_Parameter() TestNavigationViewModel sut = new TestNavigationViewModelFixture(); // When - ( (INavigated)sut ).WhenNavigatedTo(new NavigationParameter()).Subscribe(); + sut.As().OnNavigatedTo(new Arguments()); // Then - sut.NavigatedToParameter.Should().BeAssignableTo(); + sut.NavigatedToParameter.Should().BeAssignableTo(); } } @@ -31,14 +32,14 @@ public void Should_Have_Parameter() TestNavigationViewModel sut = new TestNavigationViewModelFixture(); // When - ( (INavigated)sut ).WhenNavigatedFrom(new NavigationParameter()).Subscribe(); + sut.As().OnNavigatedFrom(new Arguments()); // Then - sut.NavigatedFromParameter.Should().BeAssignableTo(); + sut.NavigatedFromParameter.Should().BeAssignableTo(); } } - public class TheNavigatingToProperty + public class TheInitializeProperty { [Fact] public void Should_Have_Parameter() @@ -47,26 +48,10 @@ public void Should_Have_Parameter() TestNavigationViewModel sut = new TestNavigationViewModelFixture(); // When - ( (INavigating)sut ).WhenNavigatingTo(new NavigationParameter()).Subscribe(); + sut.As().OnInitialize(new Arguments()); // Then - sut.NavigatingToParameter.Should().BeAssignableTo(); - } - } - - public class TheInitializeCommand - { - [Fact] - public void Should_Execute_Template() - { - // Given - TestNavigationViewModel sut = new TestNavigationViewModelFixture(); - - // When - sut.Initialize.Execute().Subscribe(); - - // Then - sut.Overriden.Should().BeTrue(); + sut.InitializeParameter.Should().BeAssignableTo(); } } } diff --git a/test/ViewModels.Tests/TestNavigationViewModel.cs b/test/ViewModels.Tests/TestNavigationViewModel.cs index 94f10a0d4..9672b8411 100644 --- a/test/ViewModels.Tests/TestNavigationViewModel.cs +++ b/test/ViewModels.Tests/TestNavigationViewModel.cs @@ -1,30 +1,24 @@ +using ReactiveMarbles.Mvvm; using ReactiveUI; using Rocket.Surgery.Airframe.Navigation; -using System; -using System.Reactive; using System.Reactive.Disposables; namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestNavigationViewModel : NavigableViewModelBase { - private readonly ObservableAsPropertyHelper _navigatedToParameter; - private readonly ObservableAsPropertyHelper _navigatedFromParameter; - private readonly ObservableAsPropertyHelper _navigatingToParameter; - private bool _overriden; - public TestNavigationViewModel() { - NavigatedTo - .ToProperty(this, nameof(NavigatedToParameter), out _navigatedToParameter) + Initialize + .AsValue(_ => RaisePropertyChanged(nameof(InitializeParameter))) .DisposeWith(Garbage); - NavigatedFrom - .ToProperty(this, nameof(NavigatedFromParameter), out _navigatedFromParameter) + NavigatedTo + .AsValue(_ => RaisePropertyChanged(nameof(NavigatedToParameter))) .DisposeWith(Garbage); - Initialize - .ToProperty(this, nameof(NavigatingToParameter), out _navigatingToParameter) + NavigatedFrom + .AsValue(_ => RaisePropertyChanged(nameof(NavigatedFromParameter))) .DisposeWith(Garbage); } @@ -32,19 +26,17 @@ public TestNavigationViewModel() public IArguments NavigatedFromParameter => _navigatedFromParameter.Value; - public IArguments NavigatingToParameter => _navigatingToParameter.Value; - - protected override IObservable ExecuteInitialize() - { - Overriden = true; - - return base.ExecuteInitialize(); - } + public IArguments InitializeParameter => _navigatingToParameter.Value; public bool Overriden { get => _overriden; set => this.RaiseAndSetIfChanged(ref _overriden, value); } + + private readonly ObservableAsPropertyHelper _navigatedToParameter; + private readonly ObservableAsPropertyHelper _navigatedFromParameter; + private readonly ObservableAsPropertyHelper _navigatingToParameter; + private bool _overriden; } } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs index 470179e3b..be768e83d 100644 --- a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs +++ b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs @@ -1,9 +1,13 @@ +using Rocket.Surgery.Airframe.Navigation; + namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestNavigationViewModelFixture { public static implicit operator TestNavigationViewModel(TestNavigationViewModelFixture fixture) => fixture.Build(); + public INavigated AsNavigated() => Build(); + private TestNavigationViewModel Build() => new TestNavigationViewModel(); } } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestViewModel.cs b/test/ViewModels.Tests/TestViewModel.cs index c34cd6452..8542e2aac 100644 --- a/test/ViewModels.Tests/TestViewModel.cs +++ b/test/ViewModels.Tests/TestViewModel.cs @@ -2,6 +2,6 @@ namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestViewModel : ViewModelBase { - public override bool IsLoading { get; } = true; + public bool IsLoading { get; } = true; } } \ No newline at end of file diff --git a/test/directory.build.props b/test/directory.build.props index 79a039566..a8e35e973 100644 --- a/test/directory.build.props +++ b/test/directory.build.props @@ -9,6 +9,7 @@ + From 132007fe370d7b7261d68e44abc1ff82cec8a152 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:21:09 -0600 Subject: [PATCH 04/14] chore: all tests passing --- .../SchedulerProviderFixture.cs | 6 ++- .../TestNavigationViewModel.cs | 46 +++++++++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/test/Airframe.Testing/SchedulerProviderFixture.cs b/test/Airframe.Testing/SchedulerProviderFixture.cs index e93634f71..77e3f8557 100644 --- a/test/Airframe.Testing/SchedulerProviderFixture.cs +++ b/test/Airframe.Testing/SchedulerProviderFixture.cs @@ -9,6 +9,8 @@ namespace Airframe.Testing; [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order")] public class SchedulerProviderFixture : ITestFixtureBuilder { + public SchedulerProviderFixture() => _mainThreadScheduler = _backgroundThreadScheduler = new TestScheduler(); + public static implicit operator SchedulerProviderMock(SchedulerProviderFixture fixture) => fixture.Build(); public SchedulerProviderFixture WithUserInterfaceScheduler(IScheduler scheduler) => this.With(ref _mainThreadScheduler, scheduler); @@ -21,6 +23,6 @@ public class SchedulerProviderFixture : ITestFixtureBuilder private SchedulerProviderMock Build() => new SchedulerProviderMock(_mainThreadScheduler, _backgroundThreadScheduler); - private IScheduler _mainThreadScheduler = new TestScheduler(); - private IScheduler _backgroundThreadScheduler = new TestScheduler(); + private IScheduler _mainThreadScheduler; + private IScheduler _backgroundThreadScheduler; } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestNavigationViewModel.cs b/test/ViewModels.Tests/TestNavigationViewModel.cs index 9672b8411..ced466e14 100644 --- a/test/ViewModels.Tests/TestNavigationViewModel.cs +++ b/test/ViewModels.Tests/TestNavigationViewModel.cs @@ -1,42 +1,42 @@ using ReactiveMarbles.Mvvm; -using ReactiveUI; using Rocket.Surgery.Airframe.Navigation; +using System.Diagnostics.CodeAnalysis; using System.Reactive.Disposables; namespace Rocket.Surgery.Airframe.ViewModels.Tests { + [SuppressMessage("Usage", "CA2213:Disposable fields should be disposed")] internal class TestNavigationViewModel : NavigableViewModelBase { + /// + /// Initializes a new instance of the class. + /// public TestNavigationViewModel() { - Initialize - .AsValue(_ => RaisePropertyChanged(nameof(InitializeParameter))) - .DisposeWith(Garbage); - - NavigatedTo - .AsValue(_ => RaisePropertyChanged(nameof(NavigatedToParameter))) - .DisposeWith(Garbage); - - NavigatedFrom - .AsValue(_ => RaisePropertyChanged(nameof(NavigatedFromParameter))) - .DisposeWith(Garbage); + _initializeParameter = + Initialize + .AsValue(_ => RaisePropertyChanged(nameof(InitializeParameter))) + .DisposeWith(Garbage)!; + + _navigatedToParameter = + NavigatedTo + .AsValue(_ => RaisePropertyChanged(nameof(NavigatedToParameter))) + .DisposeWith(Garbage)!; + + _navigatedFromParameter = + NavigatedFrom + .AsValue(_ => RaisePropertyChanged(nameof(NavigatedFromParameter))) + .DisposeWith(Garbage)!; } public IArguments NavigatedToParameter => _navigatedToParameter.Value; public IArguments NavigatedFromParameter => _navigatedFromParameter.Value; - public IArguments InitializeParameter => _navigatingToParameter.Value; - - public bool Overriden - { - get => _overriden; - set => this.RaiseAndSetIfChanged(ref _overriden, value); - } + public IArguments InitializeParameter => _initializeParameter.Value; - private readonly ObservableAsPropertyHelper _navigatedToParameter; - private readonly ObservableAsPropertyHelper _navigatedFromParameter; - private readonly ObservableAsPropertyHelper _navigatingToParameter; - private bool _overriden; + private readonly ValueBinder _initializeParameter; + private readonly ValueBinder _navigatedToParameter; + private readonly ValueBinder _navigatedFromParameter; } } \ No newline at end of file From e85e06298384f3a413cca4825c005e834d58bc11 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:26:07 -0600 Subject: [PATCH 05/14] chore: cleaning --- test/ViewModels.Tests/TestNavigationViewModelFixture.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs index be768e83d..470179e3b 100644 --- a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs +++ b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs @@ -1,13 +1,9 @@ -using Rocket.Surgery.Airframe.Navigation; - namespace Rocket.Surgery.Airframe.ViewModels.Tests { internal class TestNavigationViewModelFixture { public static implicit operator TestNavigationViewModel(TestNavigationViewModelFixture fixture) => fixture.Build(); - public INavigated AsNavigated() => Build(); - private TestNavigationViewModel Build() => new TestNavigationViewModel(); } } \ No newline at end of file From 2a6e7f2f15d7610379ce8606460693b49935d1db Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 02:33:53 -0600 Subject: [PATCH 06/14] chore: .net8 in the csproj, .net8 in the ci --- .build/.build.csproj | 2 +- .build/AirframeBuild.CI.cs | 25 ++++++++++++------------- .github/workflows/ci.yml | 4 ++-- Airframe.sln | 4 +++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.build/.build.csproj b/.build/.build.csproj index 9aad0d95c..da17a1f32 100644 --- a/.build/.build.csproj +++ b/.build/.build.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 false False diff --git a/.build/AirframeBuild.CI.cs b/.build/AirframeBuild.CI.cs index 51d5ed284..960136f92 100644 --- a/.build/AirframeBuild.CI.cs +++ b/.build/AirframeBuild.CI.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using Nuke.Common.CI.GitHubActions; -using Rocket.Surgery.Nuke; using Rocket.Surgery.Nuke.ContinuousIntegration; using Rocket.Surgery.Nuke.DotNetCore; using Rocket.Surgery.Nuke.GithubActions; @@ -9,13 +8,13 @@ [GitHubActionsSteps("ci", GitHubActionsImage.MacOsLatest, AutoGenerate = true, - On = new[] { RocketSurgeonGitHubActionsTrigger.Push }, - OnPushTags = new[] { "v*" }, - OnPushBranches = new[] { "master", "next", "feature/*" }, - OnPullRequestBranches = new[] { "master", "next" }, - InvokedTargets = new[] { nameof(Default) }, - NonEntryTargets = new[] - { + On = [RocketSurgeonGitHubActionsTrigger.Push], + OnPushTags = ["v*"], + OnPushBranches = ["master", "next", "feature/*"], + OnPullRequestBranches = ["master", "next"], + InvokedTargets = [nameof(Default)], + NonEntryTargets = + [ nameof(ICIEnvironment.CIEnvironment), nameof(ITriggerCodeCoverageReports.TriggerCodeCoverageReports), nameof(ITriggerCodeCoverageReports.GenerateCodeCoverageReportCobertura), @@ -23,9 +22,9 @@ nameof(IGenerateCodeCoverageReport.GenerateCodeCoverageReport), nameof(IGenerateCodeCoverageSummary.GenerateCodeCoverageSummary), nameof(Default) - }, - ExcludedTargets = new[] { nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) }, - Enhancements = new[] { nameof(Middleware) } + ], + ExcludedTargets = [nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore)], + Enhancements = [nameof(Middleware)] )] [PrintBuildVersion, PrintCIEnvironment, UploadLogs] [LocalBuildConventions] @@ -42,8 +41,8 @@ public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGi new RunStep("Fetch all history for all tags and branches") { Run = "git fetch --prune" }, - new SetupDotNetStep("Use .NET 6 SDK") { - DotNetVersion = "6.0.100" + new SetupDotNetStep("Use .NET 8 SDK") { + DotNetVersion = "8.0.101" } }); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 660d5a21a..d82d054ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,10 +55,10 @@ jobs: - name: Fetch all history for all tags and branches run: | git fetch --prune - - name: 🔨 Use .NET 6 SDK + - name: 🔨 Use .NET 8 SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.100' + dotnet-version: '8.0.101' - name: 🎁 dotnet tool restore run: | dotnet tool restore diff --git a/Airframe.sln b/Airframe.sln index cbee59cdf..d53f49294 100644 --- a/Airframe.sln +++ b/Airframe.sln @@ -113,6 +113,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{F9E0EB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Airframe.Testing", "test\Airframe.Testing\Airframe.Testing.csproj", "{03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{88D47515-D0D4-4C21-AE1A-558A4C164A30}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -195,7 +197,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {CA4B6910-402D-40C3-99C6-8DF8E3ABF041} = {BC256BE7-7896-4159-BB31-9F3D22860391} - {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {36A9DAA0-FCD4-41A3-A046-C755937CA701} = {BC256BE7-7896-4159-BB31-9F3D22860391} {D8A98936-BA4C-44A9-BD39-34DCBEF665C9} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {D42E447B-522C-48E6-82A9-B24780BC7A35} = {BC256BE7-7896-4159-BB31-9F3D22860391} @@ -215,6 +216,7 @@ Global {9FF05512-3C79-4FF9-8006-1313E2AF8A65} = {6813747B-13DB-4144-AB19-22C84E734517} {F9E0EBA5-5737-440E-8F30-20CCFC207E9E} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} + {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {88D47515-D0D4-4C21-AE1A-558A4C164A30} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8F0DF64A-C8D5-41DF-B4C9-5C70526644DF} From b2862c2d28d2b8b6c6987a7033deb3b551d90baf Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:19:37 -0600 Subject: [PATCH 07/14] chore: fix the build scoped namespaces --- .build/AirframeBuild.cs | 11 +- .config/dotnet-tools.json | 4 + Airframe.sln | 4 +- benchmarks/Performance/Mocks/Test.cs | 7 +- .../Performance/Mocks/TestReactiveObject.cs | 7 +- benchmarks/Performance/Program.cs | 19 +- .../Performance/ViewModelBaseBenchmark.cs | 39 +- directory.packages.props | 4 +- src/Apple/LocationEventExtensions.cs | 241 ++++++----- .../Locations/CLLocationManagerDecorator.cs | 261 ++++++------ src/Apple/Locations/CoreLocationManager.cs | 291 +++++++------- src/Apple/Locations/ICLLocationManager.cs | 357 +++++++++-------- src/Composition/CompositionBuilder.cs | 171 ++++---- src/Composition/DryIocContainerExtensions.cs | 111 +++--- src/Composition/DryIocModule.cs | 19 +- src/Composition/IModule.cs | 21 +- src/Composition/IPlatformRegistrar.cs | 19 +- src/Composition/LoggingModule.cs | 31 +- src/Composition/PlatformRegistrarBase.cs | 17 +- src/Core/Connectivity/ConnectionProfile.cs | 11 - src/Core/Connectivity/INetworkState.cs | 91 +++-- src/Core/Connectivity/NetworkAccess.cs | 39 +- src/Core/Connectivity/NetworkConnection.cs | 32 ++ .../Connectivity/NetworkStateChangedEvent.cs | 111 +++--- src/Core/Core.csproj.DotSettings | 1 + src/Core/Exceptions/ExceptionHandlerBase.cs | 113 +++--- src/Core/Exceptions/IExceptionHandler.cs | 13 +- src/Core/Geofence/GeoRegion.cs | 79 ++-- src/Core/Geofence/GeofenceRegion.cs | 107 +++-- src/Core/Geofence/GeofenceService.cs | 79 ++-- src/Core/Geofence/GeofenceStore.cs | 47 ++- src/Core/Geofence/IGeofenceService.cs | 85 ++-- src/Core/Geofence/IGeofenceStore.cs | 71 ++-- src/Core/Geofence/Position.cs | 87 ++-- src/Core/Locations/AuthorizationStatus.cs | 49 ++- .../Events/AuthorizationChangedEvent.cs | 27 +- src/Core/Locations/Events/ErrorEvent.cs | 27 +- .../Locations/Events/HeadingUpdatedEvent.cs | 13 +- .../Locations/Events/LocationUpdatedEvent.cs | 43 +- .../Locations/Events/LocationsUpdatedEvent.cs | 27 +- .../Events/RegionBeaconRangedEvent.cs | 13 +- .../Locations/Events/RegionChangedEvent.cs | 43 +- src/Core/Locations/Events/RegionErrorEvent.cs | 43 +- src/Core/Locations/Events/VisitedEvent.cs | 67 ++-- src/Core/Locations/GeoCoordinate.cs | 81 ++-- src/Core/Locations/GeoLocation.cs | 43 +- src/Core/Locations/GpsLocation.cs | 149 ++++--- src/Core/Locations/ICoreLocationService.cs | 123 +++--- src/Core/Locations/IGpsLocation.cs | 89 ++--- src/Core/Locations/LocationAccuracy.cs | 59 ++- src/Core/Locations/MonitorResult.cs | 59 ++- src/Core/Locations/MonitorState.cs | 113 +++--- src/Core/Locations/RegionState.cs | 33 +- .../Background/IBackgroundOperation.cs | 35 +- src/Core/Operations/ICanExecute.cs | 19 +- src/Core/Operations/IOperation.cs | 33 +- .../Operations/Startup/ApplicationStartup.cs | 23 +- .../Operations/Startup/IApplicationStartup.cs | 35 +- .../Operations/Startup/IStartupOperation.cs | 19 +- .../Startup/LoggableApplicationStartup.cs | 81 ++-- .../Startup/LoggableStartupOperation.cs | 89 ++--- .../Startup/StartupOperationBase.cs | 49 ++- src/Core/Scheduling/ISchedulerProvider.cs | 25 +- src/Core/Settings/ISetting.cs | 43 +- src/Core/Settings/ISettingsProvider.cs | 99 +++-- src/Core/Timers/IDecrement.cs | 15 +- src/Core/Timers/IIncrement.cs | 15 +- src/Core/Timers/IObservableTimer.cs | 13 +- src/Core/Timers/ITimer.cs | 43 +- src/Data/CacheFunctions.cs | 85 ++-- src/Data/Client/IClient.cs | 103 +++-- src/Data/Data/DataServiceBase.cs | 203 +++++----- src/Data/Data/Dto.cs | 39 +- src/Data/Data/IDataService.cs | 159 ++++---- src/Data/Data/IDto.cs | 13 +- src/Data/Data/IHaveIdentifier.cs | 19 +- src/Data/DuckDuckGo/DuckDuckGoFunctions.cs | 81 ++-- src/Data/DuckDuckGo/DuckDuckGoService.cs | 105 +++-- src/Data/DuckDuckGo/IDuckDuckGoApiClient.cs | 45 +-- src/Data/DuckDuckGo/IDuckDuckGoService.cs | 37 +- src/Data/DuckDuckGo/Models/Developer.cs | 33 +- src/Data/DuckDuckGo/Models/Icon.cs | 33 +- src/Data/DuckDuckGo/Models/Maintainer.cs | 17 +- src/Data/DuckDuckGo/Models/Meta.cs | 299 +++++++------- src/Data/DuckDuckGo/Models/RelatedTopic.cs | 57 ++- src/Data/DuckDuckGo/Models/SearchResult.cs | 169 ++++---- src/Data/DuckDuckGo/Models/SrcOptions.cs | 121 +++--- src/Data/DuckDuckGo/Models/Topic.cs | 41 +- src/Data/Hub/HubClientBase.cs | 47 ++- src/Data/Hub/IHubClient.cs | 33 +- src/Data/Jokes/ChuckNorris/ChuckNorrisJoke.cs | 91 +++-- .../ChuckNorris/ChuckNorrisJokeService.cs | 95 +++-- .../ChuckNorris/IChuckNorrisJokeApiClient.cs | 65 ++- .../ChuckNorris/IChuckNorrisJokeService.cs | 57 ++- .../ConfigurationOptions.cs | 97 +++-- .../DependencyInjectionExtensions.cs | 345 ++++++++-------- .../IPlatformInitializer.cs | 21 +- .../IServiceCollectionModule.cs | 21 +- .../ServiceCollectionModule.cs | 27 +- .../ServiceCollectionModuleExtensions.cs | 43 +- .../StartupOption.cs | 45 +-- src/Synthetic/ClientMock.cs | 77 ++-- src/Synthetic/Coffee/CoffeeClientMock.cs | 87 ++-- src/Synthetic/Coffee/CoffeeDataService.cs | 21 +- src/Synthetic/Coffee/CoffeeDto.cs | 33 +- src/Synthetic/Coffee/ICoffeeDataService.cs | 13 +- src/Synthetic/Drinks/DrinkClientMock.cs | 239 ++++++----- src/Synthetic/Drinks/DrinkDataService.cs | 21 +- src/Synthetic/Drinks/DrinkDto.cs | 49 ++- src/Synthetic/Drinks/DrinkType.cs | 79 ++-- src/Synthetic/Drinks/IDrinkService.cs | 13 +- src/Synthetic/HubClientMock.cs | 21 +- src/Synthetic/Regions.cs | 89 ++--- src/Synthetic/Species.cs | 25 +- src/Timers/DecrementTimer.cs | 33 +- src/Timers/DivisibleTimer.cs | 107 +++-- src/Timers/Events/TimerEvent.cs | 13 +- src/Timers/Events/TimerResetEvent.cs | 13 +- src/Timers/Events/TimerResumeEvent.cs | 13 +- src/Timers/Events/TimerStartEvent.cs | 27 +- src/Timers/Events/TimerStopEvent.cs | 13 +- src/Timers/IncrementTimer.cs | 31 +- src/Timers/ObservableTimer.cs | 163 ++++---- src/Timers/TimeSpans.cs | 17 +- src/Timers/TimerBase.cs | 61 ++- src/ViewModels/INetworkAware.cs | 20 +- src/ViewModels/NavigableViewModelBase.cs | 101 +++-- src/ViewModels/ReactiveDisposable.cs | 45 +-- src/ViewModels/ViewModelBase.cs | 53 ++- test/Airframe.Tests/NoExceptionHandlerStub.cs | 31 +- test/Airframe.Tests/TestBase.cs | 11 +- .../ConnectivityChangedEventFixture.cs | 27 -- .../ConnectivityChangedEventTests.cs | 76 ---- .../NetworkStateChangedEventFixture.cs | 26 ++ .../NetworkStateChangedEventTests.cs | 74 ++++ ...s => NetworkStateDefaultInterfaceTests.cs} | 13 +- .../Connectivity/NetworkStateMock.cs | 13 +- test/Core.Tests/LoggerMock.cs | 37 +- .../Startup/ApplicationStartupFixture.cs | 21 +- .../Startup/ApplicationStartupTest.cs | 173 ++++---- .../Operations/Startup/OperationTests.cs | 79 ++-- .../Startup/ScheduledTestOperation.cs | 39 +- .../Operations/Startup/TestOperation.cs | 29 +- .../Startup/TestOperationFixture.cs | 19 +- .../DuckGo/DuckDuckGoFunctionTests.cs | 111 +++--- .../DuckGo/DuckDuckGoServiceFixture.cs | 15 +- .../DuckGo/DuckDuckGoServiceTests.cs | 51 ++- .../ChuckNorrisJokeApiClientMock.cs | 61 ++- .../ChuckNorrisJokeServiceTests.cs | 201 +++++----- .../ComplexOptions/AncestorObject.cs | 9 +- .../ComplexOptions/AncestorOptionsTestData.cs | 43 +- .../ComplexOptions/ComplexObject.cs | 9 +- .../ComplexOptions/ComplexSettings.cs | 11 +- .../ComplexOptions/LevelSettings.cs | 9 +- .../ComplexOptions/ParentObject.cs | 9 +- .../ConfigurationBuilderTestData.cs | 39 +- .../ConfigurationOptionsTestData.cs | 37 +- .../DefaultOptions/DefaultOptionsTestData.cs | 43 +- .../FlatOptions/FlatOptionsTestData.cs | 33 +- .../FlatOptions/FlatSettings.cs | 11 +- .../MultipleConfigurationOptionsTestData.cs | 47 ++- .../OptionsTests.cs | 377 +++++++++--------- .../TestClassData.cs | 25 +- .../TransientFaultHandlingOptions.cs | 11 +- test/Timers.Tests/DecrementTimerFixture.cs | 15 +- test/Timers.Tests/DecrementTimerTests.cs | 189 +++++---- test/Timers.Tests/DivisibleTimeSpanData.cs | 43 +- test/Timers.Tests/DivisibleTimerFixture.cs | 15 +- test/Timers.Tests/DivisibleTimerTests.cs | 55 ++- test/Timers.Tests/IncrementTimerFixture.cs | 15 +- test/Timers.Tests/IncrementTimerTests.cs | 161 ++++---- .../NavigableViewModelTests.cs | 81 ++-- .../TestNavigationViewModel.cs | 65 ++- .../TestNavigationViewModelFixture.cs | 11 +- test/ViewModels.Tests/TestViewModel.cs | 9 +- test/ViewModels.Tests/TestViewModelFixture.cs | 11 +- test/ViewModels.Tests/ViewModelTests.cs | 23 +- 177 files changed, 5424 insertions(+), 5549 deletions(-) delete mode 100644 src/Core/Connectivity/ConnectionProfile.cs create mode 100644 src/Core/Connectivity/NetworkConnection.cs delete mode 100644 test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs delete mode 100644 test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs create mode 100644 test/Core.Tests/Connectivity/NetworkStateChangedEventFixture.cs create mode 100644 test/Core.Tests/Connectivity/NetworkStateChangedEventTests.cs rename test/Core.Tests/Connectivity/{ConnectivityInterfaceTests.cs => NetworkStateDefaultInterfaceTests.cs} (84%) diff --git a/.build/AirframeBuild.cs b/.build/AirframeBuild.cs index 9581453a4..80e8344dd 100644 --- a/.build/AirframeBuild.cs +++ b/.build/AirframeBuild.cs @@ -53,18 +53,19 @@ public partial class AirframeBuild : NukeBuild, .DependsOn(Test) .DependsOn(Pack); + public Target Clean => definition => definition.Inherit(x => x.Clean); + public Target Restore => definition => definition.Inherit(x => x.CoreRestore); public Target Build => definition => definition.Inherit(x => x.CoreBuild); + public Target Test => definition => definition.Inherit(x => x.CoreTest); + + public Target Pack => definition => definition.Inherit(x => x.CorePack) .DependsOn(Clean) .After(Test); - public Target Clean => definition => definition.Inherit(x => x.Clean); - public Target Restore => definition => definition.Inherit(x => x.CoreRestore); - public Target Test => definition => definition.Inherit(x => x.CoreTest); - [Solution(GenerateProjects = true)] - private Solution Solution { get; } = null!; + Solution Solution { get; } = null!; Nuke.Common.ProjectModel.Solution IHaveSolution.Solution => Solution; diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a7e1a6f2e..bbdfa465d 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -2,6 +2,10 @@ "version": 1, "isRoot": true, "tools": { + "gitversion.tool": { + "version": "5.12.0", + "commands": ["dotnet-gitversion"] + }, "dotnet-outdated": { "version": "2.11.0", "commands": ["dotnet-outdated"] diff --git a/Airframe.sln b/Airframe.sln index d53f49294..cbee59cdf 100644 --- a/Airframe.sln +++ b/Airframe.sln @@ -113,8 +113,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".husky", ".husky", "{F9E0EB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Airframe.Testing", "test\Airframe.Testing\Airframe.Testing.csproj", "{03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{88D47515-D0D4-4C21-AE1A-558A4C164A30}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -197,6 +195,7 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {CA4B6910-402D-40C3-99C6-8DF8E3ABF041} = {BC256BE7-7896-4159-BB31-9F3D22860391} + {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {36A9DAA0-FCD4-41A3-A046-C755937CA701} = {BC256BE7-7896-4159-BB31-9F3D22860391} {D8A98936-BA4C-44A9-BD39-34DCBEF665C9} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} {D42E447B-522C-48E6-82A9-B24780BC7A35} = {BC256BE7-7896-4159-BB31-9F3D22860391} @@ -216,7 +215,6 @@ Global {9FF05512-3C79-4FF9-8006-1313E2AF8A65} = {6813747B-13DB-4144-AB19-22C84E734517} {F9E0EBA5-5737-440E-8F30-20CCFC207E9E} = {786B1ADD-7D0E-448E-80C2-1EEDB7393342} {03C0CB0E-CC59-4AF9-8999-C371EF6D6DF7} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77} - {8322904C-5A48-4A92-A5EA-2AF91F8C4595} = {88D47515-D0D4-4C21-AE1A-558A4C164A30} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8F0DF64A-C8D5-41DF-B4C9-5C70526644DF} diff --git a/benchmarks/Performance/Mocks/Test.cs b/benchmarks/Performance/Mocks/Test.cs index 597876701..c712d77ee 100644 --- a/benchmarks/Performance/Mocks/Test.cs +++ b/benchmarks/Performance/Mocks/Test.cs @@ -1,8 +1,7 @@ using Rocket.Surgery.Airframe.ViewModels; -namespace Rocket.Surgery.Airframe.Performance +namespace Rocket.Surgery.Airframe.Performance; + +public class Test : ViewModelBase { - public class Test : ViewModelBase - { - } } \ No newline at end of file diff --git a/benchmarks/Performance/Mocks/TestReactiveObject.cs b/benchmarks/Performance/Mocks/TestReactiveObject.cs index dfee70680..eb2fee996 100644 --- a/benchmarks/Performance/Mocks/TestReactiveObject.cs +++ b/benchmarks/Performance/Mocks/TestReactiveObject.cs @@ -1,6 +1,5 @@ using ReactiveUI; -namespace Rocket.Surgery.Airframe.Performance -{ - public class TestReactiveObject : ReactiveObject { } -} \ No newline at end of file +namespace Rocket.Surgery.Airframe.Performance; + +public class TestReactiveObject : ReactiveObject { } \ No newline at end of file diff --git a/benchmarks/Performance/Program.cs b/benchmarks/Performance/Program.cs index 472fdebf9..2c176bb0c 100644 --- a/benchmarks/Performance/Program.cs +++ b/benchmarks/Performance/Program.cs @@ -1,16 +1,15 @@ using BenchmarkDotNet.Running; -namespace Rocket.Surgery.Airframe.Performance +namespace Rocket.Surgery.Airframe.Performance; + +/// +/// Class which hosts the main entry point into the application. +/// +public static class Program { /// - /// Class which hosts the main entry point into the application. + /// The main entry point into the benchmarking application. /// - public static class Program - { - /// - /// The main entry point into the benchmarking application. - /// - /// Arguments from the command line. - public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); - } + /// Arguments from the command line. + public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); } \ No newline at end of file diff --git a/benchmarks/Performance/ViewModelBaseBenchmark.cs b/benchmarks/Performance/ViewModelBaseBenchmark.cs index 0c174c8a4..0ac4e9dca 100644 --- a/benchmarks/Performance/ViewModelBaseBenchmark.cs +++ b/benchmarks/Performance/ViewModelBaseBenchmark.cs @@ -1,25 +1,24 @@ using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Jobs; -namespace Rocket.Surgery.Airframe.Performance +namespace Rocket.Surgery.Airframe.Performance; + +[SimpleJob(RuntimeMoniker.NetCoreApp31)] +[MemoryDiagnoser] +[MarkdownExporterAttribute.GitHub] +public class ViewModelBaseBenchmark { - [SimpleJob(RuntimeMoniker.NetCoreApp31)] - [MemoryDiagnoser] - [MarkdownExporterAttribute.GitHub] - public class ViewModelBaseBenchmark - { - /// - /// Benchmarks the instance creation. - /// - /// - [Benchmark(Baseline = true)] - public TestReactiveObject CreateReactiveObject() => new TestReactiveObject(); + /// + /// Benchmarks the instance creation. + /// + /// + [Benchmark(Baseline = true)] + public TestReactiveObject CreateReactiveObject() => new TestReactiveObject(); - /// - /// Benchmarks the instance creation. - /// - /// - [Benchmark] - public Test CreateViewModel() => new Test(); - } -} + /// + /// Benchmarks the instance creation. + /// + /// + [Benchmark] + public Test CreateViewModel() => new Test(); +} \ No newline at end of file diff --git a/directory.packages.props b/directory.packages.props index 0c5ba5647..7be5a98f7 100644 --- a/directory.packages.props +++ b/directory.packages.props @@ -18,9 +18,9 @@ - + - + diff --git a/src/Apple/LocationEventExtensions.cs b/src/Apple/LocationEventExtensions.cs index a608fe5e0..11286f89f 100644 --- a/src/Apple/LocationEventExtensions.cs +++ b/src/Apple/LocationEventExtensions.cs @@ -4,128 +4,127 @@ using CoreLocation; using Foundation; -namespace Rocket.Surgery.Airframe.Apple +namespace Rocket.Surgery.Airframe.Apple; + +internal static class LocationEventExtensions { - internal static class LocationEventExtensions - { - private static readonly Dictionary AuthorizationStatuses = - new() - { - { CLAuthorizationStatus.NotDetermined, AuthorizationStatus.NotDetermined }, - { CLAuthorizationStatus.Restricted, AuthorizationStatus.Restricted }, - { CLAuthorizationStatus.Denied, AuthorizationStatus.Denied }, - { CLAuthorizationStatus.AuthorizedAlways, AuthorizationStatus.AuthorizedAlways }, - { CLAuthorizationStatus.AuthorizedWhenInUse, AuthorizationStatus.AuthorizedWhenInUse } - }; - - private static readonly Dictionary RegionStates = - new() - { - { CLRegionState.Unknown, RegionState.Unknown }, - { CLRegionState.Inside, RegionState.Inside }, - { CLRegionState.Outside, RegionState.Outside } - }; - - /// - /// Converts the to an instance of . - /// - /// The arguments. - /// The changed notification. - public static AuthorizationChangedEvent ToNotification(this CLAuthorizationChangedEventArgs args) => - new(AuthorizationStatuses[args.Status]); - - /// - /// Converts the to an instance of . - /// - /// The arguments. - /// The changed notification. - public static HeadingUpdatedEvent ToNotification(this CLHeadingUpdatedEventArgs args) => - new(); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static LocationsUpdatedEvent ToNotification(this CLLocationsUpdatedEventArgs args) => - new(args.Locations.Select(location => location.ToGpsLocation())); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static LocationUpdatedEvent ToNotification(this CLLocationUpdatedEventArgs args) => - new( - args.OldLocation.ToGpsLocation(), - args.NewLocation.ToGpsLocation()); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static RegionChangedEvent ToNotification(this CLRegionEventArgs args) => - new(args.Region.ToGeoRegion()); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static RegionChangedEvent ToNotification(this CLRegionStateDeterminedEventArgs args) => - new(args.Region.ToGeoRegion(), RegionStates[args.State]); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static ErrorEvent ToNotification(this NSErrorEventArgs args) => - new(new Exception(args.ToString())); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static VisitedEvent ToNotification(this CLVisitedEventArgs args) => - new(args.Visit.Coordinate.ToLocation(), args.Visit.ArrivalDate.ToLocalTime(), args.Visit.DepartureDate.ToLocalTime(), args.Visit.HorizontalAccuracy); - - /// - /// Converts the to . - /// - /// The arguments. - /// The notification. - public static RegionErrorEvent ToNotification(this CLRegionErrorEventArgs args) => - new(/*args.Error*/new Exception(), ToGeoRegion(args.Region)); - - /// - /// Converts a to a . - /// - /// The region. - /// The converted value. - public static GeoRegion ToGeoRegion(this CLRegion region) => new( - region.Identifier, - region.Center.ToLocation(), - region.Radius, - region.NotifyOnEntry, - region.NotifyOnExit); - - /// - /// Converts the to a . - /// - /// The location. - /// The converted vale. - public static GeoCoordinate ToLocation(this CLLocationCoordinate2D location) => new(location.Latitude, location.Longitude); - - public static IGpsLocation ToGpsLocation(this CLLocation location) => new GpsLocation(location.Coordinate.Latitude, location.Coordinate.Longitude, location.Altitude, location.Course, location.CourseAccuracy, location.Speed, location.SpeedAccuracy, 0, location.Timestamp.ToLocalTime()); - - public static DateTime ToLocalTime(this NSDate nsDate) + private static readonly Dictionary AuthorizationStatuses = + new() { - DateTime referenceDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0)); + { CLAuthorizationStatus.NotDetermined, AuthorizationStatus.NotDetermined }, + { CLAuthorizationStatus.Restricted, AuthorizationStatus.Restricted }, + { CLAuthorizationStatus.Denied, AuthorizationStatus.Denied }, + { CLAuthorizationStatus.AuthorizedAlways, AuthorizationStatus.AuthorizedAlways }, + { CLAuthorizationStatus.AuthorizedWhenInUse, AuthorizationStatus.AuthorizedWhenInUse } + }; + + private static readonly Dictionary RegionStates = + new() + { + { CLRegionState.Unknown, RegionState.Unknown }, + { CLRegionState.Inside, RegionState.Inside }, + { CLRegionState.Outside, RegionState.Outside } + }; + + /// + /// Converts the to an instance of . + /// + /// The arguments. + /// The changed notification. + public static AuthorizationChangedEvent ToNotification(this CLAuthorizationChangedEventArgs args) => + new(AuthorizationStatuses[args.Status]); + + /// + /// Converts the to an instance of . + /// + /// The arguments. + /// The changed notification. + public static HeadingUpdatedEvent ToNotification(this CLHeadingUpdatedEventArgs args) => + new(); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static LocationsUpdatedEvent ToNotification(this CLLocationsUpdatedEventArgs args) => + new(args.Locations.Select(location => location.ToGpsLocation())); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static LocationUpdatedEvent ToNotification(this CLLocationUpdatedEventArgs args) => + new( + args.OldLocation.ToGpsLocation(), + args.NewLocation.ToGpsLocation()); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static RegionChangedEvent ToNotification(this CLRegionEventArgs args) => + new(args.Region.ToGeoRegion()); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static RegionChangedEvent ToNotification(this CLRegionStateDeterminedEventArgs args) => + new(args.Region.ToGeoRegion(), RegionStates[args.State]); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static ErrorEvent ToNotification(this NSErrorEventArgs args) => + new(new Exception(args.ToString())); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static VisitedEvent ToNotification(this CLVisitedEventArgs args) => + new(args.Visit.Coordinate.ToLocation(), args.Visit.ArrivalDate.ToLocalTime(), args.Visit.DepartureDate.ToLocalTime(), args.Visit.HorizontalAccuracy); + + /// + /// Converts the to . + /// + /// The arguments. + /// The notification. + public static RegionErrorEvent ToNotification(this CLRegionErrorEventArgs args) => + new(/*args.Error*/new Exception(), ToGeoRegion(args.Region)); + + /// + /// Converts a to a . + /// + /// The region. + /// The converted value. + public static GeoRegion ToGeoRegion(this CLRegion region) => new( + region.Identifier, + region.Center.ToLocation(), + region.Radius, + region.NotifyOnEntry, + region.NotifyOnExit); + + /// + /// Converts the to a . + /// + /// The location. + /// The converted vale. + public static GeoCoordinate ToLocation(this CLLocationCoordinate2D location) => new(location.Latitude, location.Longitude); + + public static IGpsLocation ToGpsLocation(this CLLocation location) => new GpsLocation(location.Coordinate.Latitude, location.Coordinate.Longitude, location.Altitude, location.Course, location.CourseAccuracy, location.Speed, location.SpeedAccuracy, 0, location.Timestamp.ToLocalTime()); + + public static DateTime ToLocalTime(this NSDate nsDate) + { + DateTime referenceDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0)); - return referenceDate.AddSeconds(nsDate.SecondsSinceReferenceDate); - } + return referenceDate.AddSeconds(nsDate.SecondsSinceReferenceDate); } -} +} \ No newline at end of file diff --git a/src/Apple/Locations/CLLocationManagerDecorator.cs b/src/Apple/Locations/CLLocationManagerDecorator.cs index 6c6982443..1a4e738ef 100644 --- a/src/Apple/Locations/CLLocationManagerDecorator.cs +++ b/src/Apple/Locations/CLLocationManagerDecorator.cs @@ -4,128 +4,128 @@ using Foundation; using ObjCRuntime; -namespace Rocket.Surgery.Airframe.Apple +namespace Rocket.Surgery.Airframe.Apple; + +/// +/// Represents a . +/// +[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Apple")] +public sealed class CLLocationManagerDecorator : ICLLocationManager { + private readonly Lazy _locationManager; + /// - /// Represents a . + /// Initializes a new instance of the class. /// - [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Apple")] - public sealed class CLLocationManagerDecorator : ICLLocationManager + public CLLocationManagerDecorator() { - private readonly Lazy _locationManager; - - /// - /// Initializes a new instance of the class. - /// - public CLLocationManagerDecorator() - { - _locationManager = new Lazy(() => new CLLocationManager()); - _locationManager.Value.AuthorizationChanged += AuthorizationChanged; - _locationManager.Value.DeferredUpdatesFinished += DeferredUpdatesFinished; - _locationManager.Value.DidDetermineState += DidDetermineState; - _locationManager.Value.DidFailRangingBeacons += DidFailRangingBeacons; - _locationManager.Value.DidRangeBeaconsSatisfyingConstraint += DidRangeBeaconsSatisfyingConstraint; - _locationManager.Value.DidStartMonitoringForRegion += DidStartMonitoringForRegion; - _locationManager.Value.DidVisit += DidVisit; - _locationManager.Value.Failed += Failed; - _locationManager.Value.LocationUpdatesPaused += LocationUpdatesPaused; - _locationManager.Value.LocationUpdatesResumed += LocationUpdatesResumed; - _locationManager.Value.LocationsUpdated += LocationsUpdated; - _locationManager.Value.MonitoringFailed += MonitoringFailed; - _locationManager.Value.RegionEntered += RegionEntered; - _locationManager.Value.RegionLeft += RegionLeft; - _locationManager.Value.UpdatedHeading += UpdatedHeading; - _locationManager.Value.UpdatedLocation += UpdatedLocation; - } + _locationManager = new Lazy(() => new CLLocationManager()); + _locationManager.Value.AuthorizationChanged += AuthorizationChanged; + _locationManager.Value.DeferredUpdatesFinished += DeferredUpdatesFinished; + _locationManager.Value.DidDetermineState += DidDetermineState; + _locationManager.Value.DidFailRangingBeacons += DidFailRangingBeacons; + _locationManager.Value.DidRangeBeaconsSatisfyingConstraint += DidRangeBeaconsSatisfyingConstraint; + _locationManager.Value.DidStartMonitoringForRegion += DidStartMonitoringForRegion; + _locationManager.Value.DidVisit += DidVisit; + _locationManager.Value.Failed += Failed; + _locationManager.Value.LocationUpdatesPaused += LocationUpdatesPaused; + _locationManager.Value.LocationUpdatesResumed += LocationUpdatesResumed; + _locationManager.Value.LocationsUpdated += LocationsUpdated; + _locationManager.Value.MonitoringFailed += MonitoringFailed; + _locationManager.Value.RegionEntered += RegionEntered; + _locationManager.Value.RegionLeft += RegionLeft; + _locationManager.Value.UpdatedHeading += UpdatedHeading; + _locationManager.Value.UpdatedLocation += UpdatedLocation; + } - /// - public event EventHandler? AuthorizationChanged; + /// + public event EventHandler? AuthorizationChanged; - /// - public event EventHandler? DeferredUpdatesFinished; + /// + public event EventHandler? DeferredUpdatesFinished; - /// - public event EventHandler? DidDetermineState; + /// + public event EventHandler? DidDetermineState; - /// - public event EventHandler? DidFailRangingBeacons; + /// + public event EventHandler? DidFailRangingBeacons; - /// - public event EventHandler? DidRangeBeaconsSatisfyingConstraint; + /// + public event EventHandler? DidRangeBeaconsSatisfyingConstraint; - /// - public event EventHandler? DidStartMonitoringForRegion; + /// + public event EventHandler? DidStartMonitoringForRegion; - /// - public event EventHandler? DidVisit; + /// + public event EventHandler? DidVisit; - /// - public event EventHandler? Failed; + /// + public event EventHandler? Failed; - /// - public event EventHandler? LocationUpdatesPaused; + /// + public event EventHandler? LocationUpdatesPaused; - /// - public event EventHandler? LocationUpdatesResumed; + /// + public event EventHandler? LocationUpdatesResumed; - /// - public event EventHandler? LocationsUpdated; + /// + public event EventHandler? LocationsUpdated; - /// - public event EventHandler? MonitoringFailed; + /// + public event EventHandler? MonitoringFailed; - /// - public event EventHandler? RegionEntered; + /// + public event EventHandler? RegionEntered; - /// - public event EventHandler? RegionLeft; + /// + public event EventHandler? RegionLeft; - /// - public event EventHandler? UpdatedHeading; + /// + public event EventHandler? UpdatedHeading; - /// - public event EventHandler? UpdatedLocation; + /// + public event EventHandler? UpdatedLocation; - /// - public void DismissHeadingCalibrationDisplay() => _locationManager.Value.DismissHeadingCalibrationDisplay(); + /// + public void DismissHeadingCalibrationDisplay() => _locationManager.Value.DismissHeadingCalibrationDisplay(); - /// - public bool IsMonitoringAvailable(Class regionClass) => + /// + public bool IsMonitoringAvailable(Class regionClass) => - // TODO: Rodney gets to fix this - CLLocationManager.IsMonitoringAvailable(regionClass); + // TODO: Rodney gets to fix this + CLLocationManager.IsMonitoringAvailable(regionClass); - /// - public void RequestAlwaysAuthorization() => _locationManager.Value.RequestAlwaysAuthorization(); + /// + public void RequestAlwaysAuthorization() => _locationManager.Value.RequestAlwaysAuthorization(); - /// - public void RequestLocation() => _locationManager.Value.RequestLocation(); + /// + public void RequestLocation() => _locationManager.Value.RequestLocation(); - /// - public void RequestState(CLRegion region) => _locationManager.Value.RequestState(region); + /// + public void RequestState(CLRegion region) => _locationManager.Value.RequestState(region); - /// - public void RequestWhenInUseAuthorization() => _locationManager.Value.RequestWhenInUseAuthorization(); + /// + public void RequestWhenInUseAuthorization() => _locationManager.Value.RequestWhenInUseAuthorization(); - /// - public void StartMonitoring(CLRegion region, double desiredAccuracy) => + /// + public void StartMonitoring(CLRegion region, double desiredAccuracy) => - // TODO: Rodney gets to fix this + // TODO: Rodney gets to fix this #if XAMARIN_IOS _locationManager.Value.StartMonitoring(region, desiredAccuracy); #else - _locationManager.Value.StartMonitoring(region); + _locationManager.Value.StartMonitoring(region); #endif - /// - public void StartMonitoring(CLRegion region) => _locationManager.Value.StartMonitoring(region); + /// + public void StartMonitoring(CLRegion region) => _locationManager.Value.StartMonitoring(region); - /// - public void StartMonitoringSignificantLocationChanges() => - _locationManager.Value.StartMonitoringSignificantLocationChanges(); + /// + public void StartMonitoringSignificantLocationChanges() => + _locationManager.Value.StartMonitoringSignificantLocationChanges(); - /// - public void StartMonitoringVisits() => _locationManager.Value.StartMonitoringVisits(); + /// + public void StartMonitoringVisits() => _locationManager.Value.StartMonitoringVisits(); #if XAMARIN_IOS @@ -133,26 +133,26 @@ public void StartMonitoringSignificantLocationChanges() => public void StartRangingBeacons(CLBeaconRegion region) => _locationManager.Value.StartRangingBeacons(region); #else - /// - public void StartRangingBeacons(CLBeaconIdentityConstraint constraint) => _locationManager.Value.StartRangingBeacons(constraint); + /// + public void StartRangingBeacons(CLBeaconIdentityConstraint constraint) => _locationManager.Value.StartRangingBeacons(constraint); #endif - /// - public void StartUpdatingHeading() => _locationManager.Value.StartUpdatingHeading(); + /// + public void StartUpdatingHeading() => _locationManager.Value.StartUpdatingHeading(); - /// - public void StartUpdatingLocation() => _locationManager.Value.StartUpdatingLocation(); + /// + public void StartUpdatingLocation() => _locationManager.Value.StartUpdatingLocation(); - /// - public void StopMonitoring(CLRegion region) => _locationManager.Value.StopMonitoring(region); + /// + public void StopMonitoring(CLRegion region) => _locationManager.Value.StopMonitoring(region); - /// - public void StopMonitoringSignificantLocationChanges() => - _locationManager.Value.StopMonitoringSignificantLocationChanges(); + /// + public void StopMonitoringSignificantLocationChanges() => + _locationManager.Value.StopMonitoringSignificantLocationChanges(); - /// - public void StopMonitoringVisits() => _locationManager.Value.StopMonitoringVisits(); + /// + public void StopMonitoringVisits() => _locationManager.Value.StopMonitoringVisits(); #if XAMARIN_IOS /// @@ -160,40 +160,39 @@ public void StopMonitoringSignificantLocationChanges() => #else - /// - public void StopRangingBeacons(CLBeaconIdentityConstraint constraint) => - _locationManager.Value.StopRangingBeacons(constraint); + /// + public void StopRangingBeacons(CLBeaconIdentityConstraint constraint) => + _locationManager.Value.StopRangingBeacons(constraint); #endif - /// - public void StopUpdatingHeading() => _locationManager.Value.StopUpdatingHeading(); + /// + public void StopUpdatingHeading() => _locationManager.Value.StopUpdatingHeading(); - /// - public void StopUpdatingLocation() => _locationManager.Value.StopUpdatingLocation(); - - /// - /// Releases unmanaged and - optionally - managed resources. - /// - public void Dispose() - { - _locationManager.Value.AuthorizationChanged -= AuthorizationChanged; - _locationManager.Value.DeferredUpdatesFinished -= DeferredUpdatesFinished; - _locationManager.Value.DidDetermineState -= DidDetermineState; - _locationManager.Value.DidFailRangingBeacons -= DidFailRangingBeacons; - _locationManager.Value.DidRangeBeaconsSatisfyingConstraint -= DidRangeBeaconsSatisfyingConstraint; - _locationManager.Value.DidStartMonitoringForRegion -= DidStartMonitoringForRegion; - _locationManager.Value.DidVisit -= DidVisit; - _locationManager.Value.Failed -= Failed; - _locationManager.Value.LocationUpdatesPaused -= LocationUpdatesPaused; - _locationManager.Value.LocationUpdatesResumed -= LocationUpdatesResumed; - _locationManager.Value.LocationsUpdated -= LocationsUpdated; - _locationManager.Value.MonitoringFailed -= MonitoringFailed; - _locationManager.Value.RegionEntered -= RegionEntered; - _locationManager.Value.RegionLeft -= RegionLeft; - _locationManager.Value.UpdatedHeading -= UpdatedHeading; - _locationManager.Value.UpdatedLocation -= UpdatedLocation; - _locationManager.Value.Dispose(); - } + /// + public void StopUpdatingLocation() => _locationManager.Value.StopUpdatingLocation(); + + /// + /// Releases unmanaged and - optionally - managed resources. + /// + public void Dispose() + { + _locationManager.Value.AuthorizationChanged -= AuthorizationChanged; + _locationManager.Value.DeferredUpdatesFinished -= DeferredUpdatesFinished; + _locationManager.Value.DidDetermineState -= DidDetermineState; + _locationManager.Value.DidFailRangingBeacons -= DidFailRangingBeacons; + _locationManager.Value.DidRangeBeaconsSatisfyingConstraint -= DidRangeBeaconsSatisfyingConstraint; + _locationManager.Value.DidStartMonitoringForRegion -= DidStartMonitoringForRegion; + _locationManager.Value.DidVisit -= DidVisit; + _locationManager.Value.Failed -= Failed; + _locationManager.Value.LocationUpdatesPaused -= LocationUpdatesPaused; + _locationManager.Value.LocationUpdatesResumed -= LocationUpdatesResumed; + _locationManager.Value.LocationsUpdated -= LocationsUpdated; + _locationManager.Value.MonitoringFailed -= MonitoringFailed; + _locationManager.Value.RegionEntered -= RegionEntered; + _locationManager.Value.RegionLeft -= RegionLeft; + _locationManager.Value.UpdatedHeading -= UpdatedHeading; + _locationManager.Value.UpdatedLocation -= UpdatedLocation; + _locationManager.Value.Dispose(); } -} +} \ No newline at end of file diff --git a/src/Apple/Locations/CoreLocationManager.cs b/src/Apple/Locations/CoreLocationManager.cs index 5cee3863d..c76fb97db 100644 --- a/src/Apple/Locations/CoreLocationManager.cs +++ b/src/Apple/Locations/CoreLocationManager.cs @@ -4,156 +4,155 @@ using CoreLocation; using Foundation; -namespace Rocket.Surgery.Airframe.Apple +namespace Rocket.Surgery.Airframe.Apple; + +/// +/// Implementation of on top of . +/// +public class CoreLocationManager : ICoreLocationService { + private readonly Lazy _locationManager = new(() => new CLLocationManager()); + /// - /// Implementation of on top of . + /// Initializes a new instance of the class. /// - public class CoreLocationManager : ICoreLocationService + public CoreLocationManager() { - private readonly Lazy _locationManager = new(() => new CLLocationManager()); - - /// - /// Initializes a new instance of the class. - /// - public CoreLocationManager() - { - AuthorizationChanged = - Observable - .FromEvent, CLAuthorizationChangedEventArgs>( - handler => _locationManager.Value.AuthorizationChanged += handler, - handler => _locationManager.Value.AuthorizationChanged -= handler) - .Select(LocationEventExtensions.ToNotification); - - DeferredUpdatesFinished = - Observable - .FromEvent, NSErrorEventArgs>( + AuthorizationChanged = + Observable + .FromEvent, CLAuthorizationChangedEventArgs>( + handler => _locationManager.Value.AuthorizationChanged += handler, + handler => _locationManager.Value.AuthorizationChanged -= handler) + .Select(LocationEventExtensions.ToNotification); + + DeferredUpdatesFinished = + Observable + .FromEvent, NSErrorEventArgs>( handler => _locationManager.Value.DeferredUpdatesFinished += handler, handler => _locationManager.Value.DeferredUpdatesFinished -= handler) - .Select(LocationEventExtensions.ToNotification); - - DeterminedState = - Observable - .FromEvent, CLRegionStateDeterminedEventArgs>( - handler => _locationManager.Value.DidDetermineState += handler, - handler => _locationManager.Value.DidDetermineState -= handler) - .Select(LocationEventExtensions.ToNotification); - - StartedMonitoringForRegion = - Observable - .FromEvent, CLRegionEventArgs>( - handler => _locationManager.Value.DidStartMonitoringForRegion += handler, - handler => _locationManager.Value.DidStartMonitoringForRegion -= handler) - .Select(LocationEventExtensions.ToNotification); - - Visited = - Observable - .FromEvent, CLVisitedEventArgs>( - handler => _locationManager.Value.DidVisit += handler, - handler => _locationManager.Value.DidVisit -= handler) - .Select(LocationEventExtensions.ToNotification); - - Failed = - Observable - .FromEvent, NSErrorEventArgs>( - handler => _locationManager.Value.Failed += handler, - handler => _locationManager.Value.Failed -= handler) - .Select(LocationEventExtensions.ToNotification); - - LocationUpdatesPaused = - Observable - .FromEvent( - handler => _locationManager.Value.LocationUpdatesPaused += handler, - handler => _locationManager.Value.LocationUpdatesPaused -= handler); - - LocationUpdatesResumed = - Observable - .FromEvent( - handler => _locationManager.Value.LocationUpdatesResumed += handler, - handler => _locationManager.Value.LocationUpdatesResumed -= handler); - - LocationsUpdated = - Observable - .FromEvent, CLLocationsUpdatedEventArgs>( - handler => _locationManager.Value.LocationsUpdated += handler, - handler => _locationManager.Value.LocationsUpdated -= handler) - .Select(LocationEventExtensions.ToNotification); - - MonitoringFailed = - Observable - .FromEvent, CLRegionErrorEventArgs>( - handler => _locationManager.Value.MonitoringFailed += handler, - handler => _locationManager.Value.MonitoringFailed -= handler) - .Select(LocationEventExtensions.ToNotification); - - RegionEntered = - Observable - .FromEvent, CLRegionEventArgs>( - handler => _locationManager.Value.RegionEntered += handler, - handler => _locationManager.Value.RegionEntered -= handler) - .Select(LocationEventExtensions.ToNotification); - - RegionExited = - Observable.FromEvent, CLRegionEventArgs>( - handler => _locationManager.Value.RegionLeft += handler, - handler => _locationManager.Value.RegionLeft -= handler) - .Select(LocationEventExtensions.ToNotification); - - UpdatedHeading = - Observable - .FromEvent, CLHeadingUpdatedEventArgs>( - handler => _locationManager.Value.UpdatedHeading += handler, - handler => _locationManager.Value.UpdatedHeading -= handler) - .Select(LocationEventExtensions.ToNotification); - - UpdatedLocation = - Observable - .FromEvent, CLLocationUpdatedEventArgs>( - handler => _locationManager.Value.UpdatedLocation += handler, - handler => _locationManager.Value.UpdatedLocation -= handler) - .Select(LocationEventExtensions.ToNotification); - } - - /// - public IObservable AuthorizationChanged { get; } - - /// - public IObservable DeferredUpdatesFinished { get; } - - /// - public IObservable DeterminedState { get; } - - /// - public IObservable StartedMonitoringForRegion { get; } - - /// - public IObservable Visited { get; } - - /// - public IObservable Failed { get; } - - /// - public IObservable LocationUpdatesPaused { get; } - - /// - public IObservable LocationUpdatesResumed { get; } - - /// - public IObservable LocationsUpdated { get; } - - /// - public IObservable MonitoringFailed { get; } - - /// - public IObservable RegionEntered { get; } - - /// - public IObservable RegionExited { get; } - - /// - public IObservable UpdatedHeading { get; } - - /// - public IObservable UpdatedLocation { get; } + .Select(LocationEventExtensions.ToNotification); + + DeterminedState = + Observable + .FromEvent, CLRegionStateDeterminedEventArgs>( + handler => _locationManager.Value.DidDetermineState += handler, + handler => _locationManager.Value.DidDetermineState -= handler) + .Select(LocationEventExtensions.ToNotification); + + StartedMonitoringForRegion = + Observable + .FromEvent, CLRegionEventArgs>( + handler => _locationManager.Value.DidStartMonitoringForRegion += handler, + handler => _locationManager.Value.DidStartMonitoringForRegion -= handler) + .Select(LocationEventExtensions.ToNotification); + + Visited = + Observable + .FromEvent, CLVisitedEventArgs>( + handler => _locationManager.Value.DidVisit += handler, + handler => _locationManager.Value.DidVisit -= handler) + .Select(LocationEventExtensions.ToNotification); + + Failed = + Observable + .FromEvent, NSErrorEventArgs>( + handler => _locationManager.Value.Failed += handler, + handler => _locationManager.Value.Failed -= handler) + .Select(LocationEventExtensions.ToNotification); + + LocationUpdatesPaused = + Observable + .FromEvent( + handler => _locationManager.Value.LocationUpdatesPaused += handler, + handler => _locationManager.Value.LocationUpdatesPaused -= handler); + + LocationUpdatesResumed = + Observable + .FromEvent( + handler => _locationManager.Value.LocationUpdatesResumed += handler, + handler => _locationManager.Value.LocationUpdatesResumed -= handler); + + LocationsUpdated = + Observable + .FromEvent, CLLocationsUpdatedEventArgs>( + handler => _locationManager.Value.LocationsUpdated += handler, + handler => _locationManager.Value.LocationsUpdated -= handler) + .Select(LocationEventExtensions.ToNotification); + + MonitoringFailed = + Observable + .FromEvent, CLRegionErrorEventArgs>( + handler => _locationManager.Value.MonitoringFailed += handler, + handler => _locationManager.Value.MonitoringFailed -= handler) + .Select(LocationEventExtensions.ToNotification); + + RegionEntered = + Observable + .FromEvent, CLRegionEventArgs>( + handler => _locationManager.Value.RegionEntered += handler, + handler => _locationManager.Value.RegionEntered -= handler) + .Select(LocationEventExtensions.ToNotification); + + RegionExited = + Observable.FromEvent, CLRegionEventArgs>( + handler => _locationManager.Value.RegionLeft += handler, + handler => _locationManager.Value.RegionLeft -= handler) + .Select(LocationEventExtensions.ToNotification); + + UpdatedHeading = + Observable + .FromEvent, CLHeadingUpdatedEventArgs>( + handler => _locationManager.Value.UpdatedHeading += handler, + handler => _locationManager.Value.UpdatedHeading -= handler) + .Select(LocationEventExtensions.ToNotification); + + UpdatedLocation = + Observable + .FromEvent, CLLocationUpdatedEventArgs>( + handler => _locationManager.Value.UpdatedLocation += handler, + handler => _locationManager.Value.UpdatedLocation -= handler) + .Select(LocationEventExtensions.ToNotification); } -} + + /// + public IObservable AuthorizationChanged { get; } + + /// + public IObservable DeferredUpdatesFinished { get; } + + /// + public IObservable DeterminedState { get; } + + /// + public IObservable StartedMonitoringForRegion { get; } + + /// + public IObservable Visited { get; } + + /// + public IObservable Failed { get; } + + /// + public IObservable LocationUpdatesPaused { get; } + + /// + public IObservable LocationUpdatesResumed { get; } + + /// + public IObservable LocationsUpdated { get; } + + /// + public IObservable MonitoringFailed { get; } + + /// + public IObservable RegionEntered { get; } + + /// + public IObservable RegionExited { get; } + + /// + public IObservable UpdatedHeading { get; } + + /// + public IObservable UpdatedLocation { get; } +} \ No newline at end of file diff --git a/src/Apple/Locations/ICLLocationManager.cs b/src/Apple/Locations/ICLLocationManager.cs index 6f9b00e13..211a35ac1 100644 --- a/src/Apple/Locations/ICLLocationManager.cs +++ b/src/Apple/Locations/ICLLocationManager.cs @@ -4,184 +4,183 @@ using Foundation; using ObjCRuntime; -namespace Rocket.Surgery.Airframe.Apple +namespace Rocket.Surgery.Airframe.Apple; + +/// +/// Interface representing a at the iOS platform level. +/// +[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Apple")] +public interface ICLLocationManager { /// - /// Interface representing a at the iOS platform level. - /// - [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Apple")] - public interface ICLLocationManager - { - /// - /// Event handler for authorization changes events. - /// - event EventHandler AuthorizationChanged; - - /// - /// Event handler for deferred updates finished events. - /// - event EventHandler DeferredUpdatesFinished; - - /// - /// Event handler for did determine state events. - /// - event EventHandler DidDetermineState; - - /// - /// Event handler for did fail ranging beacons events. - /// - event EventHandler DidFailRangingBeacons; - - /// - /// Event handler for did range beacons satisfy constraint events. - /// - event EventHandler DidRangeBeaconsSatisfyingConstraint; - - /// - /// Event handler for did start monitor for region events. - /// - event EventHandler DidStartMonitoringForRegion; - - /// - /// Event handler for did visit events. - /// - event EventHandler DidVisit; - - /// - /// Event handler for failed events. - /// - event EventHandler Failed; - - /// - /// Event handler for location updates paused events. - /// - event EventHandler LocationUpdatesPaused; - - /// - /// Event handler for location updates resumed events. - /// - event EventHandler LocationUpdatesResumed; - - /// - /// Event handler for locations updated events. - /// - event EventHandler LocationsUpdated; - - /// - /// Event handler for region error events. - /// - event EventHandler MonitoringFailed; - - /// - /// Event handler for region entered. - /// - event EventHandler RegionEntered; - - /// - /// Event handler for - /// - event EventHandler RegionLeft; - - /// - /// Event handler for - /// - event EventHandler UpdatedHeading; - - /// - /// Event handler for - /// - event EventHandler UpdatedLocation; - - /// - /// Dismisses the heading calibration display. - /// - void DismissHeadingCalibrationDisplay(); - - /// - /// Request the current state. - /// - /// The region class. - /// A value indicating whether the can monitor a region. - bool IsMonitoringAvailable(Class regionClass); - - /// - /// Request the current location. - /// - void RequestLocation(); - - /// - /// Request the current state. - /// - /// The region. - void RequestState(CLRegion region); - - /// - /// Request to use the location services when application is in use. - /// - void RequestAlwaysAuthorization(); - - /// - /// Request to use the location services when application is in use. - /// - void RequestWhenInUseAuthorization(); - - /// - /// Starts monitoring a region. - /// - /// The region. - /// The requested accuracy. - void StartMonitoring(CLRegion region, double desiredAccuracy); - - /// - /// Starts monitoring a region. - /// - /// The region. - void StartMonitoring(CLRegion region); - - /// - /// Starts monitoring significant location changes. - /// - void StartMonitoringSignificantLocationChanges(); - - /// - /// Starts monitoring visits. - /// - void StartMonitoringVisits(); - - /// - /// Starts receiving updates on heading. - /// - void StartUpdatingHeading(); - - /// - /// Starts receiving updates on location. - /// - void StartUpdatingLocation(); - - /// - /// Stops monitoring the specified region. - /// - /// The region. - void StopMonitoring(CLRegion region); - - /// - /// Stops receiving updates on significant location changes. - /// - void StopMonitoringSignificantLocationChanges(); - - /// - /// Stops receiving updates on visits. - /// - void StopMonitoringVisits(); - - /// - /// Stops receiving updates on heading. - /// - void StopUpdatingHeading(); - - /// - /// Stops receiving updates on location. - /// - void StopUpdatingLocation(); - } -} + /// Event handler for authorization changes events. + /// + event EventHandler AuthorizationChanged; + + /// + /// Event handler for deferred updates finished events. + /// + event EventHandler DeferredUpdatesFinished; + + /// + /// Event handler for did determine state events. + /// + event EventHandler DidDetermineState; + + /// + /// Event handler for did fail ranging beacons events. + /// + event EventHandler DidFailRangingBeacons; + + /// + /// Event handler for did range beacons satisfy constraint events. + /// + event EventHandler DidRangeBeaconsSatisfyingConstraint; + + /// + /// Event handler for did start monitor for region events. + /// + event EventHandler DidStartMonitoringForRegion; + + /// + /// Event handler for did visit events. + /// + event EventHandler DidVisit; + + /// + /// Event handler for failed events. + /// + event EventHandler Failed; + + /// + /// Event handler for location updates paused events. + /// + event EventHandler LocationUpdatesPaused; + + /// + /// Event handler for location updates resumed events. + /// + event EventHandler LocationUpdatesResumed; + + /// + /// Event handler for locations updated events. + /// + event EventHandler LocationsUpdated; + + /// + /// Event handler for region error events. + /// + event EventHandler MonitoringFailed; + + /// + /// Event handler for region entered. + /// + event EventHandler RegionEntered; + + /// + /// Event handler for + /// + event EventHandler RegionLeft; + + /// + /// Event handler for + /// + event EventHandler UpdatedHeading; + + /// + /// Event handler for + /// + event EventHandler UpdatedLocation; + + /// + /// Dismisses the heading calibration display. + /// + void DismissHeadingCalibrationDisplay(); + + /// + /// Request the current state. + /// + /// The region class. + /// A value indicating whether the can monitor a region. + bool IsMonitoringAvailable(Class regionClass); + + /// + /// Request the current location. + /// + void RequestLocation(); + + /// + /// Request the current state. + /// + /// The region. + void RequestState(CLRegion region); + + /// + /// Request to use the location services when application is in use. + /// + void RequestAlwaysAuthorization(); + + /// + /// Request to use the location services when application is in use. + /// + void RequestWhenInUseAuthorization(); + + /// + /// Starts monitoring a region. + /// + /// The region. + /// The requested accuracy. + void StartMonitoring(CLRegion region, double desiredAccuracy); + + /// + /// Starts monitoring a region. + /// + /// The region. + void StartMonitoring(CLRegion region); + + /// + /// Starts monitoring significant location changes. + /// + void StartMonitoringSignificantLocationChanges(); + + /// + /// Starts monitoring visits. + /// + void StartMonitoringVisits(); + + /// + /// Starts receiving updates on heading. + /// + void StartUpdatingHeading(); + + /// + /// Starts receiving updates on location. + /// + void StartUpdatingLocation(); + + /// + /// Stops monitoring the specified region. + /// + /// The region. + void StopMonitoring(CLRegion region); + + /// + /// Stops receiving updates on significant location changes. + /// + void StopMonitoringSignificantLocationChanges(); + + /// + /// Stops receiving updates on visits. + /// + void StopMonitoringVisits(); + + /// + /// Stops receiving updates on heading. + /// + void StopUpdatingHeading(); + + /// + /// Stops receiving updates on location. + /// + void StopUpdatingLocation(); +} \ No newline at end of file diff --git a/src/Composition/CompositionBuilder.cs b/src/Composition/CompositionBuilder.cs index b1754a29f..0da51816a 100644 --- a/src/Composition/CompositionBuilder.cs +++ b/src/Composition/CompositionBuilder.cs @@ -2,99 +2,98 @@ using JetBrains.Annotations; using ReactiveUI; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// Builds a composition root. +/// +public sealed class CompositionBuilder { + private readonly IContainer _container; + /// - /// Builds a composition root. + /// Initializes a new instance of the class. /// - public sealed class CompositionBuilder - { - private readonly IContainer _container; - - /// - /// Initializes a new instance of the class. - /// - /// The container instance. - public CompositionBuilder(IContainer? container = null) => - _container = container ?? new Container(); + /// The container instance. + public CompositionBuilder(IContainer? container = null) => + _container = container ?? new Container(); - /// - /// Loads the autofac module. - /// - /// The type of the module. - /// The composition builder. - public CompositionBuilder RegisterModule() - where TModule : IModule, new() - { - _container.RegisterModule(); - return this; - } + /// + /// Loads the autofac module. + /// + /// The type of the module. + /// The composition builder. + public CompositionBuilder RegisterModule() + where TModule : IModule, new() + { + _container.RegisterModule(); + return this; + } - /// - /// Loads the autofac module. - /// - /// The type of the module. - /// The module. - /// The composition builder. - public CompositionBuilder RegisterModule([NotNull] TModule module) - where TModule : IModule - { - _container.RegisterModule(module); - return this; - } + /// + /// Loads the autofac module. + /// + /// The type of the module. + /// The module. + /// The composition builder. + public CompositionBuilder RegisterModule([NotNull] TModule module) + where TModule : IModule + { + _container.RegisterModule(module); + return this; + } - /// - /// Registers custom command binders. - /// - /// The type of the interface. - /// The type of the class. - /// - /// The composition builder. - /// - public CompositionBuilder RegisterCommandBinders() - where TClass : class, TInterface - { - _container.Register(Reuse.Singleton); - return this; - } + /// + /// Registers custom command binders. + /// + /// The type of the interface. + /// The type of the class. + /// + /// The composition builder. + /// + public CompositionBuilder RegisterCommandBinders() + where TClass : class, TInterface + { + _container.Register(Reuse.Singleton); + return this; + } - /// - /// Registers Views to View Models. - /// - /// The type of the view. - /// The type of the view model. - /// The composition builder. - public CompositionBuilder RegisterView() - where TView : IViewFor - where TViewModel : class - { - _container.Register, TView>(); - return this; - } + /// + /// Registers Views to View Models. + /// + /// The type of the view. + /// The type of the view model. + /// The composition builder. + public CompositionBuilder RegisterView() + where TView : IViewFor + where TViewModel : class + { + _container.Register, TView>(); + return this; + } - /// - /// Registers Views to View Models. - /// - /// The view model type. - /// The composition builder. - public CompositionBuilder RegisterViewModel() - where T : class - { - _container.Register(); - return this; - } + /// + /// Registers Views to View Models. + /// + /// The view model type. + /// The composition builder. + public CompositionBuilder RegisterViewModel() + where T : class + { + _container.Register(); + return this; + } - /// - /// Compose the . - /// - /// The container. - public IContainer Compose() => _container.WithNoMoreRegistrationAllowed(); + /// + /// Compose the . + /// + /// The container. + public IContainer Compose() => _container.WithNoMoreRegistrationAllowed(); - /// - /// Compose the . - /// - /// Ignore instead of throw. - /// The container. - public IContainer Compose(bool ignore) => _container.WithNoMoreRegistrationAllowed(ignore); - } -} + /// + /// Compose the . + /// + /// Ignore instead of throw. + /// The container. + public IContainer Compose(bool ignore) => _container.WithNoMoreRegistrationAllowed(ignore); +} \ No newline at end of file diff --git a/src/Composition/DryIocContainerExtensions.cs b/src/Composition/DryIocContainerExtensions.cs index c063979ce..c2eae2e32 100644 --- a/src/Composition/DryIocContainerExtensions.cs +++ b/src/Composition/DryIocContainerExtensions.cs @@ -1,68 +1,67 @@ using DryIoc; using ReactiveUI; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// extensions methods. +/// +public static class DryIocContainerExtensions { /// - /// extensions methods. + /// Registers a module to the instance. /// - public static class DryIocContainerExtensions + /// The container. + /// The module type. + /// The container instance. + public static IContainer RegisterModule(this IContainer container) + where TModule : IModule { - /// - /// Registers a module to the instance. - /// - /// The container. - /// The module type. - /// The container instance. - public static IContainer RegisterModule(this IContainer container) - where TModule : IModule - { - container.Register(); - var module = container.Resolve(); - module.Load(container); - return container; - } + container.Register(); + var module = container.Resolve(); + module.Load(container); + return container; + } - /// - /// Registers a module to the instance. - /// - /// The registrar. - /// The module instance. - /// The module type. - /// The registrar instance. - public static IRegistrator RegisterModule(this IRegistrator registrar, TModule module) - where TModule : IModule - { - module.Load(registrar); - return registrar; - } + /// + /// Registers a module to the instance. + /// + /// The registrar. + /// The module instance. + /// The module type. + /// The registrar instance. + public static IRegistrator RegisterModule(this IRegistrator registrar, TModule module) + where TModule : IModule + { + module.Load(registrar); + return registrar; + } - /// - /// Registers Views to View Models. - /// - /// The registrar. - /// The type of the view. - /// The type of the view model. - /// The composition builder. - public static IRegistrator RegisterView(this IRegistrator registrar) - where TView : IViewFor - where TViewModel : class - { - registrar.Register, TView>(); - return registrar; - } + /// + /// Registers Views to View Models. + /// + /// The registrar. + /// The type of the view. + /// The type of the view model. + /// The composition builder. + public static IRegistrator RegisterView(this IRegistrator registrar) + where TView : IViewFor + where TViewModel : class + { + registrar.Register, TView>(); + return registrar; + } - /// - /// Registers Views to View Models. - /// - /// The registrar. - /// The view model type. - /// The composition builder. - public static IRegistrator RegisterViewModel(this IRegistrator registrar) - where T : class - { - registrar.Register(); - return registrar; - } + /// + /// Registers Views to View Models. + /// + /// The registrar. + /// The view model type. + /// The composition builder. + public static IRegistrator RegisterViewModel(this IRegistrator registrar) + where T : class + { + registrar.Register(); + return registrar; } } \ No newline at end of file diff --git a/src/Composition/DryIocModule.cs b/src/Composition/DryIocModule.cs index dcd3a256e..2cbc73f86 100644 --- a/src/Composition/DryIocModule.cs +++ b/src/Composition/DryIocModule.cs @@ -1,16 +1,15 @@ using DryIoc; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// Base abstraction for an . +/// +public abstract class DryIocModule : IModule { /// - /// Base abstraction for an . + /// Loads registrations to the . /// - public abstract class DryIocModule : IModule - { - /// - /// Loads registrations to the . - /// - /// The registrar. - public abstract void Load(IRegistrator registrar); - } + /// The registrar. + public abstract void Load(IRegistrator registrar); } \ No newline at end of file diff --git a/src/Composition/IModule.cs b/src/Composition/IModule.cs index 744e09eca..9791f621b 100644 --- a/src/Composition/IModule.cs +++ b/src/Composition/IModule.cs @@ -1,17 +1,16 @@ using DryIoc; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// Represents a module to load for dependency inversion. +/// +public interface IModule { /// - /// Represents a module to load for dependency inversion. + /// Loads module registrations. /// - public interface IModule - { - /// - /// Loads module registrations. - /// - /// The dependency registrar. - // Here we are using registration role of DryIoc Container for the builder - void Load(IRegistrator registrar); - } + /// The dependency registrar. + // Here we are using registration role of DryIoc Container for the builder + void Load(IRegistrator registrar); } \ No newline at end of file diff --git a/src/Composition/IPlatformRegistrar.cs b/src/Composition/IPlatformRegistrar.cs index 0712e612c..1dd9e37cf 100644 --- a/src/Composition/IPlatformRegistrar.cs +++ b/src/Composition/IPlatformRegistrar.cs @@ -1,16 +1,15 @@ using DryIoc; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// Represents a platform specific registration handler. +/// +public interface IPlatformRegistrar { /// - /// Represents a platform specific registration handler. + /// Register platform specific services. /// - public interface IPlatformRegistrar - { - /// - /// Register platform specific services. - /// - /// The registrator. - void RegisterPlatformServices(IRegistrator registrator); - } + /// The registrator. + void RegisterPlatformServices(IRegistrator registrator); } \ No newline at end of file diff --git a/src/Composition/LoggingModule.cs b/src/Composition/LoggingModule.cs index fc3d2c881..cb344d63d 100644 --- a/src/Composition/LoggingModule.cs +++ b/src/Composition/LoggingModule.cs @@ -2,25 +2,24 @@ using Serilog; using Splat; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// Logging registrations. +/// +public class LoggingModule : DryIocModule { - /// - /// Logging registrations. - /// - public class LoggingModule : DryIocModule + /// + public override void Load(IRegistrator registrar) { - /// - public override void Load(IRegistrator registrar) + var funcLogManager = new FuncLogManager(type => { - var funcLogManager = new FuncLogManager(type => - { - var actualLogger = Log.ForContext(type); - return new SerilogFullLogger(actualLogger); - }); + var actualLogger = Log.ForContext(type); + return new SerilogFullLogger(actualLogger); + }); - registrar.RegisterInstance(Log.Logger); - registrar.Register(Reuse.Singleton); - registrar.RegisterInstance(funcLogManager); - } + registrar.RegisterInstance(Log.Logger); + registrar.Register(Reuse.Singleton); + registrar.RegisterInstance(funcLogManager); } } \ No newline at end of file diff --git a/src/Composition/PlatformRegistrarBase.cs b/src/Composition/PlatformRegistrarBase.cs index fa4e905ce..cb70da8e7 100644 --- a/src/Composition/PlatformRegistrarBase.cs +++ b/src/Composition/PlatformRegistrarBase.cs @@ -1,13 +1,12 @@ using DryIoc; -namespace Rocket.Surgery.Airframe.Composition +namespace Rocket.Surgery.Airframe.Composition; + +/// +/// Base platform registration object. +/// +public abstract class PlatformRegistrarBase : IPlatformRegistrar { - /// - /// Base platform registration object. - /// - public abstract class PlatformRegistrarBase : IPlatformRegistrar - { - /// - public abstract void RegisterPlatformServices(IRegistrator registrator); - } + /// + public abstract void RegisterPlatformServices(IRegistrator registrator); } \ No newline at end of file diff --git a/src/Core/Connectivity/ConnectionProfile.cs b/src/Core/Connectivity/ConnectionProfile.cs deleted file mode 100644 index 645e340ab..000000000 --- a/src/Core/Connectivity/ConnectionProfile.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Rocket.Surgery.Airframe.Connectivity -{ - public enum ConnectionProfile - { - Unknown = 0, - Bluetooth = 1, - Cellular = 2, - Ethernet = 3, - WiFi = 4 - } -} \ No newline at end of file diff --git a/src/Core/Connectivity/INetworkState.cs b/src/Core/Connectivity/INetworkState.cs index 2c715c8a3..85d18011c 100644 --- a/src/Core/Connectivity/INetworkState.cs +++ b/src/Core/Connectivity/INetworkState.cs @@ -1,56 +1,55 @@ using System; using System.Reactive.Linq; -namespace Rocket.Surgery.Airframe.Connectivity +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing the Network Connectivity. +/// +public interface INetworkState : IObservable { /// - /// Interface representing the Network Connectivity. + /// Gets an observable sequence notifying if the device has connectivity. /// - public interface INetworkState : IObservable - { - /// - /// Gets an observable sequence notifying if the device has connectivity. - /// - /// A value indicating the is a signal. - IObservable HasSignal() => - this - .Select(changedEvent => changedEvent.HasSignal()) - .DistinctUntilChanged() - .Publish() - .RefCount(); + /// A value indicating the is a signal. + IObservable HasSignal() => + this + .Select(changedEvent => changedEvent.HasSignal()) + .DistinctUntilChanged() + .Publish() + .RefCount(); - /// - /// Gets an observable sequence notifying that signal has degraded. - /// - /// A value indicating the signal is degraded. - IObservable SignalDegraded() => - this - .DistinctUntilChanged(changedEvent => changedEvent.NetworkAccess) - .Select(changedEvent => changedEvent.Degraded()) - .DistinctUntilChanged() - .Publish() - .RefCount(); + /// + /// Gets an observable sequence notifying that signal has degraded. + /// + /// A value indicating the signal is degraded. + IObservable SignalDegraded() => + this + .DistinctUntilChanged(changedEvent => changedEvent.Access) + .Select(changedEvent => changedEvent.Degraded()) + .DistinctUntilChanged() + .Publish() + .RefCount(); - /// - /// Gets an observable sequence notifying if the device has connectivity. - /// - /// - IObservable WhereHasSignal() => - this - .Where(changedEvent => changedEvent.HasSignal()) - .DistinctUntilChanged() - .Publish() - .RefCount(); + /// + /// Gets an observable sequence notifying if the device has network access. + /// + /// Network state events when there is a signal. + IObservable WhereHasSignal() => + this + .Where(changedEvent => changedEvent.HasSignal()) + .DistinctUntilChanged() + .Publish() + .RefCount(); - /// - /// Gets an observable sequence notifying if the device has a signal. - /// - /// - IObservable WhereHasNoSignal() => - this - .Where(changedEvent => !changedEvent.HasSignal()) - .DistinctUntilChanged() - .Publish() - .RefCount(); - } + /// + /// Gets an observable sequence notifying if the device has a signal. + /// + /// Network state events when there is no signal. + IObservable WhereHasNoSignal() => + this + .Where(changedEvent => !changedEvent.HasSignal()) + .DistinctUntilChanged() + .Publish() + .RefCount(); } \ No newline at end of file diff --git a/src/Core/Connectivity/NetworkAccess.cs b/src/Core/Connectivity/NetworkAccess.cs index 6b9ce5229..b77b1201e 100644 --- a/src/Core/Connectivity/NetworkAccess.cs +++ b/src/Core/Connectivity/NetworkAccess.cs @@ -1,11 +1,32 @@ -namespace Rocket.Surgery.Airframe.Connectivity +namespace Rocket.Surgery.Airframe; + +/// +/// State of network availability. +/// +public enum NetworkAccess { - public enum NetworkAccess - { - Unknown = 0, - None = 1, - Local = 2, - ConstrainedInternet = 3, - Internet = 4 - } + /// + /// Cannot determine the state of the network. + /// + Unknown = 0, + + /// + /// No network. + /// + None = 1, + + /// + /// Local access only. + /// + Local = 2, + + /// + /// Limited access. + /// + ConstrainedInternet = 3, + + /// + /// Local and internet access. + /// + Internet = 4 } \ No newline at end of file diff --git a/src/Core/Connectivity/NetworkConnection.cs b/src/Core/Connectivity/NetworkConnection.cs new file mode 100644 index 000000000..dc4519ef5 --- /dev/null +++ b/src/Core/Connectivity/NetworkConnection.cs @@ -0,0 +1,32 @@ +namespace Rocket.Surgery.Airframe; + +/// +/// The connection providing network access. +/// +public enum NetworkConnection +{ + /// + /// An unknown connection. + /// + Unknown = 0, + + /// + /// A bluetooth connection. + /// + Bluetooth = 1, + + /// + /// A cellular connection. + /// + Cellular = 2, + + /// + /// A wired connection. + /// + Ethernet = 3, + + /// + /// A wireless connection. + /// + WiFi = 4 +} \ No newline at end of file diff --git a/src/Core/Connectivity/NetworkStateChangedEvent.cs b/src/Core/Connectivity/NetworkStateChangedEvent.cs index 57d7fbc70..e6a4e8185 100644 --- a/src/Core/Connectivity/NetworkStateChangedEvent.cs +++ b/src/Core/Connectivity/NetworkStateChangedEvent.cs @@ -2,78 +2,77 @@ using System.Collections.Generic; using System.Linq; -namespace Rocket.Surgery.Airframe.Connectivity +namespace Rocket.Surgery.Airframe; + +/// +/// Class representing the for network state changes. +/// +public class NetworkStateChangedEvent : EventArgs { /// - /// Class representing the for network state changes. + /// Initializes a new instance of the class. /// - public class NetworkStateChangedEvent : EventArgs + /// The current network access. + /// The connection profile. + public NetworkStateChangedEvent(NetworkAccess access, params NetworkConnection[] connections) { - /// - /// Initializes a new instance of the class. - /// - /// The current network access. - /// The connection profile. - public NetworkStateChangedEvent(NetworkAccess access, params ConnectionProfile[] connectionProfiles) - { - NetworkAccess = access; - ConnectionProfiles = connectionProfiles; - } + Access = access; + Connections = connections; + } - /// - /// Initializes a new instance of the class. - /// - /// The current network access. - /// The connection profile. - public NetworkStateChangedEvent(NetworkAccess access, IEnumerable connectionProfiles) - : this(access, connectionProfiles.ToArray()) - { - } + /// + /// Initializes a new instance of the class. + /// + /// The current network access. + /// The connection profile. + public NetworkStateChangedEvent(NetworkAccess access, IEnumerable connectionProfiles) + : this(access, connectionProfiles.ToArray()) + { + } - /// - /// Gets the network access. - /// - public NetworkAccess NetworkAccess { get; } + /// + /// Gets the network access. + /// + public NetworkAccess Access { get; } - /// - /// Gets the connection profiles. - /// - public IReadOnlyCollection ConnectionProfiles { get; } + /// + /// Gets the connection profiles. + /// + public IReadOnlyCollection Connections { get; } - /// - /// Gets a value indicating whether there is a signal. - /// - /// A signal. - public bool HasSignal() => HasValidProfile() && HasNetworkAccess(); + /// + /// Gets a value indicating whether there is a signal. + /// + /// A signal. + public bool HasSignal() => HasValidConnection() && HasNetworkAccess(); - /// - /// Determines if the signal is degraded. - /// - /// Degraded signal. - public bool Degraded() => NetworkAccess > NetworkAccess.None || ContainsProfile(ConnectionProfile.Unknown); + /// + /// Determines if the signal is degraded. + /// + /// Degraded signal. + public bool Degraded() => Access > NetworkAccess.None || ContainsConnection(NetworkConnection.Unknown); - /// - /// Determines if this instance has a valid connection profile. - /// - /// A value indicating a valid profile exists. - public bool HasValidProfile() => ContainsProfile( - ConnectionProfile.Bluetooth, - ConnectionProfile.Cellular, - ConnectionProfile.Ethernet, - ConnectionProfile.WiFi); + /// + /// Determines if this instance has a valid connection profile. + /// + /// A value indicating a valid profile exists. + public bool HasValidConnection() => ContainsConnection( + NetworkConnection.Bluetooth, + NetworkConnection.Cellular, + NetworkConnection.Ethernet, + NetworkConnection.WiFi); - /// - public override string ToString() => $"{nameof(NetworkAccess)}: {NetworkAccess}, " - + $"{nameof(ConnectionProfiles)}: [{string.Join(", ", ConnectionProfiles)}]"; + /// + public override string ToString() => $"{nameof(Access)}: {Access}, " + + $"{nameof(Connections)}: [{string.Join(", ", Connections)}]"; - private bool HasNetworkAccess() => NetworkAccess is NetworkAccess.Internet or NetworkAccess.Local or NetworkAccess.ConstrainedInternet; + private bool HasNetworkAccess() => Access is NetworkAccess.Internet or NetworkAccess.Local or NetworkAccess.ConstrainedInternet; - private bool ContainsProfile(params ConnectionProfile[] profiles) => - ConnectionProfiles.Join( + private bool ContainsConnection(params NetworkConnection[] profiles) => + Connections.Join( profiles, instanceProfile => instanceProfile, argumentProfile => argumentProfile, (instanceProfile, argumentProfile) => instanceProfile == argumentProfile) .Any(truth => truth); - } } \ No newline at end of file diff --git a/src/Core/Core.csproj.DotSettings b/src/Core/Core.csproj.DotSettings index f5decf96d..d27a6bdc8 100644 --- a/src/Core/Core.csproj.DotSettings +++ b/src/Core/Core.csproj.DotSettings @@ -1,5 +1,6 @@  True + True True True True diff --git a/src/Core/Exceptions/ExceptionHandlerBase.cs b/src/Core/Exceptions/ExceptionHandlerBase.cs index dc432690d..d05ba90ac 100644 --- a/src/Core/Exceptions/ExceptionHandlerBase.cs +++ b/src/Core/Exceptions/ExceptionHandlerBase.cs @@ -3,80 +3,79 @@ using System.Reactive.Concurrency; using JetBrains.Annotations; -namespace Rocket.Surgery.Airframe.Exceptions +namespace Rocket.Surgery.Airframe.Exceptions; + +/// +/// Represents a base implementation. +/// +public abstract class ExceptionHandlerBase : IExceptionHandler { + private readonly IScheduler _scheduler; + /// - /// Represents a base implementation. + /// Initializes a new instance of the class. /// - public abstract class ExceptionHandlerBase : IExceptionHandler - { - private readonly IScheduler _scheduler; + /// The main thread scheduler. + protected ExceptionHandlerBase([NotNull] IScheduler scheduler) => _scheduler = scheduler; - /// - /// Initializes a new instance of the class. - /// - /// The main thread scheduler. - protected ExceptionHandlerBase([NotNull] IScheduler scheduler) => _scheduler = scheduler; - - /// - void IObserver.OnCompleted() - { - DebuggerBreak(); + /// + void IObserver.OnCompleted() + { + DebuggerBreak(); - OnCompleted(); + OnCompleted(); - _scheduler.Schedule(() => throw new NotImplementedException()); - } + _scheduler.Schedule(() => throw new NotImplementedException()); + } - /// - void IObserver.OnError(Exception error) - { - DebuggerBreak(); + /// + void IObserver.OnError(Exception error) + { + DebuggerBreak(); - OnError(error); + OnError(error); - _scheduler.Schedule(() => throw error); - } + _scheduler.Schedule(() => throw error); + } - /// - void IObserver.OnNext(Exception value) - { - DebuggerBreak(); + /// + void IObserver.OnNext(Exception value) + { + DebuggerBreak(); - OnNext(value); + OnNext(value); - _scheduler.Schedule(() => throw value); - } + _scheduler.Schedule(() => throw value); + } - /// - /// Notifies the observer that the provider has finished sending push based notifications. - /// - protected virtual void OnCompleted() - { - } + /// + /// Notifies the observer that the provider has finished sending push based notifications. + /// + protected virtual void OnCompleted() + { + } - /// - /// Notifies the observer that the provider has experienced and error. - /// - /// The exception. - protected virtual void OnError(Exception error) - { - } + /// + /// Notifies the observer that the provider has experienced and error. + /// + /// The exception. + protected virtual void OnError(Exception error) + { + } - /// - /// Provides the observer with the next exception. - /// - /// The exception. - protected virtual void OnNext(Exception value) - { - } + /// + /// Provides the observer with the next exception. + /// + /// The exception. + protected virtual void OnNext(Exception value) + { + } - private void DebuggerBreak() + private void DebuggerBreak() + { + if (Debugger.IsAttached) { - if (Debugger.IsAttached) - { - Debugger.Break(); - } + Debugger.Break(); } } } \ No newline at end of file diff --git a/src/Core/Exceptions/IExceptionHandler.cs b/src/Core/Exceptions/IExceptionHandler.cs index 9cfdaccde..2cd7437ae 100644 --- a/src/Core/Exceptions/IExceptionHandler.cs +++ b/src/Core/Exceptions/IExceptionHandler.cs @@ -1,11 +1,10 @@ using System; -namespace Rocket.Surgery.Airframe.Exceptions +namespace Rocket.Surgery.Airframe.Exceptions; + +/// +/// Interface representing an . +/// +public interface IExceptionHandler : IObserver { - /// - /// Interface representing an . - /// - public interface IExceptionHandler : IObserver - { - } } \ No newline at end of file diff --git a/src/Core/Geofence/GeoRegion.cs b/src/Core/Geofence/GeoRegion.cs index d8a50b2d7..2a993b317 100644 --- a/src/Core/Geofence/GeoRegion.cs +++ b/src/Core/Geofence/GeoRegion.cs @@ -1,50 +1,49 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a geographical region. +/// +public class GeoRegion { /// - /// Represents a geographical region. + /// Initializes a new instance of the class. /// - public class GeoRegion + /// The unique identifier. + /// The center point of the region. + /// The radius. + /// A value indicating whether to notify on entry. + /// A value indicating whether to notify on exit. + public GeoRegion(string identifier, GeoCoordinate center, double radius, bool notifyOnEntry, bool notifyOnExit) { - /// - /// Initializes a new instance of the class. - /// - /// The unique identifier. - /// The center point of the region. - /// The radius. - /// A value indicating whether to notify on entry. - /// A value indicating whether to notify on exit. - public GeoRegion(string identifier, GeoCoordinate center, double radius, bool notifyOnEntry, bool notifyOnExit) - { - Identifier = identifier; - Center = center; - NotifyOnEntry = notifyOnEntry; - NotifyOnExit = notifyOnExit; - Radius = radius; - } + Identifier = identifier; + Center = center; + NotifyOnEntry = notifyOnEntry; + NotifyOnExit = notifyOnExit; + Radius = radius; + } - /// - /// Gets or sets the region identifier. - /// - public string Identifier { get; set; } + /// + /// Gets or sets the region identifier. + /// + public string Identifier { get; set; } - /// - /// Gets or sets the center. - /// - public GeoCoordinate Center { get; set; } + /// + /// Gets or sets the center. + /// + public GeoCoordinate Center { get; set; } - /// - /// Gets or sets a value indicating whether to notify on entry of the region. - /// - public bool NotifyOnEntry { get; set; } + /// + /// Gets or sets a value indicating whether to notify on entry of the region. + /// + public bool NotifyOnEntry { get; set; } - /// - /// Gets or sets a value indicating whether to notify on exiting the region. - /// - public bool NotifyOnExit { get; set; } + /// + /// Gets or sets a value indicating whether to notify on exiting the region. + /// + public bool NotifyOnExit { get; set; } - /// - /// Gets or sets the radius of the region. - /// - public double Radius { get; set; } - } + /// + /// Gets or sets the radius of the region. + /// + public double Radius { get; set; } } \ No newline at end of file diff --git a/src/Core/Geofence/GeofenceRegion.cs b/src/Core/Geofence/GeofenceRegion.cs index 8abe7df16..6a45dc0d4 100644 --- a/src/Core/Geofence/GeofenceRegion.cs +++ b/src/Core/Geofence/GeofenceRegion.cs @@ -1,74 +1,73 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a region where a geofence exists. +/// +public class GeofenceRegion : IEquatable { /// - /// Represents a region where a geofence exists. + /// Initializes a new instance of the class. /// - public class GeofenceRegion : IEquatable + /// The region identifier. + /// The center of the region. + /// The radius of the region. + public GeofenceRegion(string identifier, Position origin, double radius) { - /// - /// Initializes a new instance of the class. - /// - /// The region identifier. - /// The center of the region. - /// The radius of the region. - public GeofenceRegion(string identifier, Position origin, double radius) - { - Identifier = identifier; - Origin = origin; - Radius = radius; - } + Identifier = identifier; + Origin = origin; + Radius = radius; + } - /// - /// Gets the default . - /// - public static GeofenceRegion Default { get; } = new GeofenceRegion(nameof(Default), Position.Default, 0); + /// + /// Gets the default . + /// + public static GeofenceRegion Default { get; } = new GeofenceRegion(nameof(Default), Position.Default, 0); - /// - /// Gets the identifier. - /// - public string Identifier { get; } + /// + /// Gets the identifier. + /// + public string Identifier { get; } - /// - /// Gets the center. - /// - public Position Origin { get; } + /// + /// Gets the center. + /// + public Position Origin { get; } - /// - /// Gets the radius. - /// - public double Radius { get; } + /// + /// Gets the radius. + /// + public double Radius { get; } - /// - /// Gets or sets a value indicating whether the region should be disposed after exiting. - /// - public bool SingleUse { get; set; } + /// + /// Gets or sets a value indicating whether the region should be disposed after exiting. + /// + public bool SingleUse { get; set; } - /// - /// Gets or sets a value indicating whether the region should notify on entry. - /// - public bool NotifyOnEntry { get; set; } = true; + /// + /// Gets or sets a value indicating whether the region should notify on entry. + /// + public bool NotifyOnEntry { get; set; } = true; - /// - /// Gets or sets a value indicating whether the region should notify on exit. - /// - public bool NotifyOnExit { get; set; } = true; + /// + /// Gets or sets a value indicating whether the region should notify on exit. + /// + public bool NotifyOnExit { get; set; } = true; - public static bool operator ==(GeofenceRegion left, GeofenceRegion right) => Equals(left, right); + public static bool operator ==(GeofenceRegion left, GeofenceRegion right) => Equals(left, right); - public static bool operator !=(GeofenceRegion left, GeofenceRegion right) => !Equals(left, right); + public static bool operator !=(GeofenceRegion left, GeofenceRegion right) => !Equals(left, right); - /// - public override string ToString() => $"[Identifier: {Identifier}]"; + /// + public override string ToString() => $"[Identifier: {Identifier}]"; - /// - public bool Equals(GeofenceRegion other) => Identifier == other?.Identifier; + /// + public bool Equals(GeofenceRegion other) => Identifier == other?.Identifier; - /// - public override bool Equals(object obj) => obj is GeofenceRegion region && Equals(region); + /// + public override bool Equals(object obj) => obj is GeofenceRegion region && Equals(region); - /// - public override int GetHashCode() => Identifier?.GetHashCode() ?? 0; - } + /// + public override int GetHashCode() => Identifier?.GetHashCode() ?? 0; } \ No newline at end of file diff --git a/src/Core/Geofence/GeofenceService.cs b/src/Core/Geofence/GeofenceService.cs index c5c6ab4f7..12c2eb9db 100644 --- a/src/Core/Geofence/GeofenceService.cs +++ b/src/Core/Geofence/GeofenceService.cs @@ -2,61 +2,60 @@ using System.Collections.Generic; using DynamicData; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a geofence service. +/// +public class GeofenceService : IGeofenceService, IGeofenceStore { - /// - /// Represents a geofence service. - /// - public class GeofenceService : IGeofenceService, IGeofenceStore - { - private readonly SourceCache _store = new SourceCache(region => region.Identifier); + private readonly SourceCache _store = new SourceCache(region => region.Identifier); - /// - public IObservable Location { get; } + /// + public IObservable Location { get; } - /// - public IObservable Entered { get; } + /// + public IObservable Entered { get; } - /// - public IObservable Exited { get; } + /// + public IObservable Exited { get; } - /// - public void StartMonitoring(GeofenceRegion region) => _store.AddOrUpdate(region); + /// + public void StartMonitoring(GeofenceRegion region) => _store.AddOrUpdate(region); - /// - public void StartMonitoring(IList regions) => _store.AddOrUpdate(regions); + /// + public void StartMonitoring(IList regions) => _store.AddOrUpdate(regions); - /// - public void StopMonitoring(string identifier) => _store.Remove(identifier); + /// + public void StopMonitoring(string identifier) => _store.Remove(identifier); - /// - public void StopMonitoring(IList identifiers) => _store.Remove(identifiers); + /// + public void StopMonitoring(IList identifiers) => _store.Remove(identifiers); - /// - public void Save(GeofenceRegion geoRegion) => _store.AddOrUpdate(geoRegion); + /// + public void Save(GeofenceRegion geoRegion) => _store.AddOrUpdate(geoRegion); - /// - public void Save(IEnumerable geoRegion) => _store.AddOrUpdate(geoRegion); + /// + public void Save(IEnumerable geoRegion) => _store.AddOrUpdate(geoRegion); - /// - public void RemoveAll() => _store.Clear(); + /// + public void RemoveAll() => _store.Clear(); - /// - public void Remove(string id) => _store.Remove(id); + /// + public void Remove(string id) => _store.Remove(id); - /// - public IObservable Observe(string id) => _store.WatchValue(id); + /// + public IObservable Observe(string id) => _store.WatchValue(id); - /// - public GeofenceRegion Get(string id) + /// + public GeofenceRegion Get(string id) + { + var optional = _store.Lookup(id); + if (optional.HasValue) { - var optional = _store.Lookup(id); - if (optional.HasValue) - { - return optional.Value; - } - - return GeofenceRegion.Default; + return optional.Value; } + + return GeofenceRegion.Default; } } \ No newline at end of file diff --git a/src/Core/Geofence/GeofenceStore.cs b/src/Core/Geofence/GeofenceStore.cs index a460e319c..c3e129bae 100644 --- a/src/Core/Geofence/GeofenceStore.cs +++ b/src/Core/Geofence/GeofenceStore.cs @@ -2,35 +2,34 @@ using System.Collections.Generic; using DynamicData; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a store for being monitored. +/// +public class GeofenceStore : IGeofenceStore { - /// - /// Represents a store for being monitored. - /// - public class GeofenceStore : IGeofenceStore - { - private readonly SourceCache _sourceCache = new SourceCache(x => x.Identifier); + private readonly SourceCache _sourceCache = new SourceCache(x => x.Identifier); - /// - public IObservable Observe(string id) => _sourceCache.WatchValue(id); + /// + public IObservable Observe(string id) => _sourceCache.WatchValue(id); - /// - public GeofenceRegion Get(string id) - { - var lookup = _sourceCache.Lookup(id); - return lookup.HasValue ? lookup.Value : GeofenceRegion.Default; - } + /// + public GeofenceRegion Get(string id) + { + var lookup = _sourceCache.Lookup(id); + return lookup.HasValue ? lookup.Value : GeofenceRegion.Default; + } - /// - public void Save(GeofenceRegion geoRegion) => _sourceCache.AddOrUpdate(geoRegion); + /// + public void Save(GeofenceRegion geoRegion) => _sourceCache.AddOrUpdate(geoRegion); - /// - public void Save(IEnumerable geoRegion) => _sourceCache.AddOrUpdate(geoRegion); + /// + public void Save(IEnumerable geoRegion) => _sourceCache.AddOrUpdate(geoRegion); - /// - public void Remove(string id) => _sourceCache.Remove(id); + /// + public void Remove(string id) => _sourceCache.Remove(id); - /// - public void RemoveAll() => _sourceCache.Clear(); - } + /// + public void RemoveAll() => _sourceCache.Clear(); } \ No newline at end of file diff --git a/src/Core/Geofence/IGeofenceService.cs b/src/Core/Geofence/IGeofenceService.cs index 79d51a638..f33320509 100644 --- a/src/Core/Geofence/IGeofenceService.cs +++ b/src/Core/Geofence/IGeofenceService.cs @@ -1,50 +1,49 @@ using System; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a service that allows you to monitor . +/// +public interface IGeofenceService { /// - /// Interface representing a service that allows you to monitor . + /// Gets an observable sequence that have been exited. + /// + IObservable Location { get; } + + /// + /// Gets an observable sequence that have been entered. + /// + IObservable Entered { get; } + + /// + /// Gets an observable sequence that have been exited. + /// + IObservable Exited { get; } + + /// + /// Starts monitoring a region. + /// + /// The region. + void StartMonitoring(GeofenceRegion region); + + /// + /// Starts monitoring multiple regions. + /// + /// The regions. + void StartMonitoring(IList regions); + + /// + /// Stops monitoring the specified regions. + /// + /// The region identifier. + void StopMonitoring(string identifier); + + /// + /// Stops monitoring multiple regions. /// - public interface IGeofenceService - { - /// - /// Gets an observable sequence that have been exited. - /// - IObservable Location { get; } - - /// - /// Gets an observable sequence that have been entered. - /// - IObservable Entered { get; } - - /// - /// Gets an observable sequence that have been exited. - /// - IObservable Exited { get; } - - /// - /// Starts monitoring a region. - /// - /// The region. - void StartMonitoring(GeofenceRegion region); - - /// - /// Starts monitoring multiple regions. - /// - /// The regions. - void StartMonitoring(IList regions); - - /// - /// Stops monitoring the specified regions. - /// - /// The region identifier. - void StopMonitoring(string identifier); - - /// - /// Stops monitoring multiple regions. - /// - /// The identifiers for the regions. - void StopMonitoring(IList identifiers); - } + /// The identifiers for the regions. + void StopMonitoring(IList identifiers); } \ No newline at end of file diff --git a/src/Core/Geofence/IGeofenceStore.cs b/src/Core/Geofence/IGeofenceStore.cs index 48568f906..9fbe9e2b9 100644 --- a/src/Core/Geofence/IGeofenceStore.cs +++ b/src/Core/Geofence/IGeofenceStore.cs @@ -1,48 +1,47 @@ using System; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a geofence store. +/// +public interface IGeofenceStore { /// - /// Interface representing a geofence store. + /// Gets an observable sequence of a change. /// - public interface IGeofenceStore - { - /// - /// Gets an observable sequence of a change. - /// - /// The region id. - /// An observable of region changes. - IObservable Observe(string id); + /// The region id. + /// An observable of region changes. + IObservable Observe(string id); - /// - /// Gets the . - /// - /// The region id. - /// The region. - GeofenceRegion Get(string id); + /// + /// Gets the . + /// + /// The region id. + /// The region. + GeofenceRegion Get(string id); - /// - /// Saves the . - /// - /// The geo region. - void Save(GeofenceRegion geoRegion); + /// + /// Saves the . + /// + /// The geo region. + void Save(GeofenceRegion geoRegion); - /// - /// Saves the list of . - /// - /// The geo region. - void Save(IEnumerable geoRegion); + /// + /// Saves the list of . + /// + /// The geo region. + void Save(IEnumerable geoRegion); - /// - /// Removes the . - /// - /// The region id. - void Remove(string id); + /// + /// Removes the . + /// + /// The region id. + void Remove(string id); - /// - /// Removes all . - /// - void RemoveAll(); - } + /// + /// Removes all . + /// + void RemoveAll(); } \ No newline at end of file diff --git a/src/Core/Geofence/Position.cs b/src/Core/Geofence/Position.cs index 1632ceba2..df1fd1b72 100644 --- a/src/Core/Geofence/Position.cs +++ b/src/Core/Geofence/Position.cs @@ -1,62 +1,61 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a position on the earth. +/// +public class Position : IEquatable { /// - /// Represents a position on the earth. + /// Initializes a new instance of the class. /// - public class Position : IEquatable + /// The latitude. + /// The longitude. + public Position(double lat, double lng) { - /// - /// Initializes a new instance of the class. - /// - /// The latitude. - /// The longitude. - public Position(double lat, double lng) + if (lat < -90 || lat > 90) { - if (lat < -90 || lat > 90) - { - throw new ArgumentException($"Invalid latitude value - {lat}"); - } - - if (lng < -180 || lng > 180) - { - throw new ArgumentException($"Invalid longitude value - {lng}"); - } - - Latitude = lat; - Longitude = lng; + throw new ArgumentException($"Invalid latitude value - {lat}"); } - /// - /// Gets the default position. - /// - public static Position Default { get; } = new Position(0, 0); + if (lng < -180 || lng > 180) + { + throw new ArgumentException($"Invalid longitude value - {lng}"); + } - /// - /// Gets the latitude. - /// - public double Latitude { get; } + Latitude = lat; + Longitude = lng; + } - /// - /// Gets the longitude. - /// - public double Longitude { get; } + /// + /// Gets the default position. + /// + public static Position Default { get; } = new Position(0, 0); - public static bool operator ==(Position? left, Position? right) => Equals(left, right); + /// + /// Gets the latitude. + /// + public double Latitude { get; } + + /// + /// Gets the longitude. + /// + public double Longitude { get; } - public static bool operator !=(Position? left, Position? right) => !Equals(left, right); + public static bool operator ==(Position? left, Position? right) => Equals(left, right); - /// - public override string ToString() => $"Latitude: {Latitude} - Longitude: {Longitude}"; + public static bool operator !=(Position? left, Position? right) => !Equals(left, right); - /// - public bool Equals(Position? other) => other != null && (Latitude, Longitude).Equals((other.Latitude, other.Longitude)); + /// + public override string ToString() => $"Latitude: {Latitude} - Longitude: {Longitude}"; - /// - public override bool Equals(object obj) => obj is Position pos && Equals(pos); + /// + public bool Equals(Position? other) => other != null && (Latitude, Longitude).Equals((other.Latitude, other.Longitude)); - /// - public override int GetHashCode() => (Latitude, Longitude).GetHashCode(); - } + /// + public override bool Equals(object obj) => obj is Position pos && Equals(pos); + + /// + public override int GetHashCode() => (Latitude, Longitude).GetHashCode(); } \ No newline at end of file diff --git a/src/Core/Locations/AuthorizationStatus.cs b/src/Core/Locations/AuthorizationStatus.cs index f43e21a2a..51b6b22f4 100644 --- a/src/Core/Locations/AuthorizationStatus.cs +++ b/src/Core/Locations/AuthorizationStatus.cs @@ -1,33 +1,32 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Enumeration of Authorization Status. +/// +public enum AuthorizationStatus { /// - /// Enumeration of Authorization Status. + /// No Authorization Determined. /// - public enum AuthorizationStatus - { - /// - /// No Authorization Determined. - /// - NotDetermined = 0, + NotDetermined = 0, - /// - /// Restricted Authorization. - /// - Restricted = 1, + /// + /// Restricted Authorization. + /// + Restricted = 1, - /// - /// Denied Authorization. - /// - Denied = 2, + /// + /// Denied Authorization. + /// + Denied = 2, - /// - /// Always Authorized. - /// - AuthorizedAlways = 3, + /// + /// Always Authorized. + /// + AuthorizedAlways = 3, - /// - /// Authorized Only When In Use. - /// - AuthorizedWhenInUse = 4, - } + /// + /// Authorized Only When In Use. + /// + AuthorizedWhenInUse = 4, } \ No newline at end of file diff --git a/src/Core/Locations/Events/AuthorizationChangedEvent.cs b/src/Core/Locations/Events/AuthorizationChangedEvent.cs index f72d05d33..a48a27dfb 100644 --- a/src/Core/Locations/Events/AuthorizationChangedEvent.cs +++ b/src/Core/Locations/Events/AuthorizationChangedEvent.cs @@ -1,19 +1,18 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Event argument that notifies an authorization state change. +/// +public class AuthorizationChangedEvent { /// - /// Event argument that notifies an authorization state change. + /// Initializes a new instance of the class. /// - public class AuthorizationChangedEvent - { - /// - /// Initializes a new instance of the class. - /// - /// The status. - public AuthorizationChangedEvent(AuthorizationStatus status) => Status = status; + /// The status. + public AuthorizationChangedEvent(AuthorizationStatus status) => Status = status; - /// - /// Gets or the status of the authorization change. - /// - public AuthorizationStatus Status { get; } - } + /// + /// Gets or the status of the authorization change. + /// + public AuthorizationStatus Status { get; } } \ No newline at end of file diff --git a/src/Core/Locations/Events/ErrorEvent.cs b/src/Core/Locations/Events/ErrorEvent.cs index bcb261ebf..f01e434e2 100644 --- a/src/Core/Locations/Events/ErrorEvent.cs +++ b/src/Core/Locations/Events/ErrorEvent.cs @@ -1,21 +1,20 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a error event. +/// +public class ErrorEvent { /// - /// Represents a error event. + /// Initializes a new instance of the class. /// - public class ErrorEvent - { - /// - /// Initializes a new instance of the class. - /// - /// The exception. - public ErrorEvent(Exception exception) => Exception = exception; + /// The exception. + public ErrorEvent(Exception exception) => Exception = exception; - /// - /// Gets an exception. - /// - public Exception Exception { get; } - } + /// + /// Gets an exception. + /// + public Exception Exception { get; } } \ No newline at end of file diff --git a/src/Core/Locations/Events/HeadingUpdatedEvent.cs b/src/Core/Locations/Events/HeadingUpdatedEvent.cs index ddff8d1e2..d0ed77d02 100644 --- a/src/Core/Locations/Events/HeadingUpdatedEvent.cs +++ b/src/Core/Locations/Events/HeadingUpdatedEvent.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a heading update event. +/// +public class HeadingUpdatedEvent { - /// - /// Represents a heading update event. - /// - public class HeadingUpdatedEvent - { - } } \ No newline at end of file diff --git a/src/Core/Locations/Events/LocationUpdatedEvent.cs b/src/Core/Locations/Events/LocationUpdatedEvent.cs index e7157155a..6c6c86eaa 100644 --- a/src/Core/Locations/Events/LocationUpdatedEvent.cs +++ b/src/Core/Locations/Events/LocationUpdatedEvent.cs @@ -1,29 +1,28 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Notification of a update. +/// +public class LocationUpdatedEvent { /// - /// Notification of a update. + /// Initializes a new instance of the class. /// - public class LocationUpdatedEvent + /// The previous. + /// The current. + public LocationUpdatedEvent(IGpsLocation? previous, IGpsLocation current) { - /// - /// Initializes a new instance of the class. - /// - /// The previous. - /// The current. - public LocationUpdatedEvent(IGpsLocation? previous, IGpsLocation current) - { - Previous = previous; - Current = current; - } + Previous = previous; + Current = current; + } - /// - /// Gets the previous location. - /// - public IGpsLocation? Previous { get; } + /// + /// Gets the previous location. + /// + public IGpsLocation? Previous { get; } - /// - /// Gets the current location. - /// - public IGpsLocation Current { get; } - } + /// + /// Gets the current location. + /// + public IGpsLocation Current { get; } } \ No newline at end of file diff --git a/src/Core/Locations/Events/LocationsUpdatedEvent.cs b/src/Core/Locations/Events/LocationsUpdatedEvent.cs index a741e7cf3..3fea2e9ef 100644 --- a/src/Core/Locations/Events/LocationsUpdatedEvent.cs +++ b/src/Core/Locations/Events/LocationsUpdatedEvent.cs @@ -1,21 +1,20 @@ using System.Collections.Generic; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a update event. +/// +public class LocationsUpdatedEvent { /// - /// Represents a update event. + /// Initializes a new instance of the class. /// - public class LocationsUpdatedEvent - { - /// - /// Initializes a new instance of the class. - /// - /// The locations. - public LocationsUpdatedEvent(IEnumerable locations) => Locations = locations; + /// The locations. + public LocationsUpdatedEvent(IEnumerable locations) => Locations = locations; - /// - /// Gets the locations. - /// - public IEnumerable Locations { get; } - } + /// + /// Gets the locations. + /// + public IEnumerable Locations { get; } } \ No newline at end of file diff --git a/src/Core/Locations/Events/RegionBeaconRangedEvent.cs b/src/Core/Locations/Events/RegionBeaconRangedEvent.cs index 5dcc5b529..8357ec982 100644 --- a/src/Core/Locations/Events/RegionBeaconRangedEvent.cs +++ b/src/Core/Locations/Events/RegionBeaconRangedEvent.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a beacon ranged event. +/// +public class RegionBeaconRangedEvent { - /// - /// Represents a beacon ranged event. - /// - public class RegionBeaconRangedEvent - { - } } \ No newline at end of file diff --git a/src/Core/Locations/Events/RegionChangedEvent.cs b/src/Core/Locations/Events/RegionChangedEvent.cs index fffd0a6c1..07f033994 100644 --- a/src/Core/Locations/Events/RegionChangedEvent.cs +++ b/src/Core/Locations/Events/RegionChangedEvent.cs @@ -1,29 +1,28 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a change to a . +/// +public class RegionChangedEvent { /// - /// Represents a change to a . + /// Initializes a new instance of the class. /// - public class RegionChangedEvent + /// The region. + /// The region state. + public RegionChangedEvent(GeoRegion region, RegionState? state = RegionState.Unknown) { - /// - /// Initializes a new instance of the class. - /// - /// The region. - /// The region state. - public RegionChangedEvent(GeoRegion region, RegionState? state = RegionState.Unknown) - { - Region = region; - State = state; - } + Region = region; + State = state; + } - /// - /// Gets the region. - /// - public GeoRegion Region { get; } + /// + /// Gets the region. + /// + public GeoRegion Region { get; } - /// - /// Gets the region state. - /// - public RegionState? State { get; } - } + /// + /// Gets the region state. + /// + public RegionState? State { get; } } \ No newline at end of file diff --git a/src/Core/Locations/Events/RegionErrorEvent.cs b/src/Core/Locations/Events/RegionErrorEvent.cs index 3caab6981..2b6f7c869 100644 --- a/src/Core/Locations/Events/RegionErrorEvent.cs +++ b/src/Core/Locations/Events/RegionErrorEvent.cs @@ -1,31 +1,30 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a error for a region. +/// +public class RegionErrorEvent { /// - /// Represents a error for a region. + /// Initializes a new instance of the class. /// - public class RegionErrorEvent + /// The error. + /// The region. + public RegionErrorEvent(Exception error, GeoRegion region) { - /// - /// Initializes a new instance of the class. - /// - /// The error. - /// The region. - public RegionErrorEvent(Exception error, GeoRegion region) - { - Error = error; - Region = region; - } + Error = error; + Region = region; + } - /// - /// Gets the exception. - /// - public Exception Error { get; } + /// + /// Gets the exception. + /// + public Exception Error { get; } - /// - /// Gets the geo region. - /// - public GeoRegion Region { get; } - } + /// + /// Gets the geo region. + /// + public GeoRegion Region { get; } } \ No newline at end of file diff --git a/src/Core/Locations/Events/VisitedEvent.cs b/src/Core/Locations/Events/VisitedEvent.cs index 405373d82..062a9c129 100644 --- a/src/Core/Locations/Events/VisitedEvent.cs +++ b/src/Core/Locations/Events/VisitedEvent.cs @@ -1,45 +1,44 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Notification of a region being visited. +/// +public class VisitedEvent { /// - /// Notification of a region being visited. + /// Initializes a new instance of the class. /// - public class VisitedEvent + /// The location. + /// The arrival date. + /// The departure date. + /// The accuracy. + public VisitedEvent(GeoCoordinate location, DateTimeOffset arrivalDate, DateTimeOffset departureDate, double horizontalAccuracy) { - /// - /// Initializes a new instance of the class. - /// - /// The location. - /// The arrival date. - /// The departure date. - /// The accuracy. - public VisitedEvent(GeoCoordinate location, DateTimeOffset arrivalDate, DateTimeOffset departureDate, double horizontalAccuracy) - { - Location = location; - ArrivalDate = arrivalDate; - DepartureDate = departureDate; - HorizontalAccuracy = horizontalAccuracy; - } + Location = location; + ArrivalDate = arrivalDate; + DepartureDate = departureDate; + HorizontalAccuracy = horizontalAccuracy; + } - /// - /// Gets the arrival date. - /// - public DateTimeOffset ArrivalDate { get; } + /// + /// Gets the arrival date. + /// + public DateTimeOffset ArrivalDate { get; } - /// - /// Gets the geo location. - /// - public GeoCoordinate Location { get; } + /// + /// Gets the geo location. + /// + public GeoCoordinate Location { get; } - /// - /// Gets the departure date. - /// - public DateTimeOffset DepartureDate { get; } + /// + /// Gets the departure date. + /// + public DateTimeOffset DepartureDate { get; } - /// - /// Gets the horizontal accuracy. - /// - public double HorizontalAccuracy { get; } - } + /// + /// Gets the horizontal accuracy. + /// + public double HorizontalAccuracy { get; } } \ No newline at end of file diff --git a/src/Core/Locations/GeoCoordinate.cs b/src/Core/Locations/GeoCoordinate.cs index d83778f2d..e9f4b113a 100644 --- a/src/Core/Locations/GeoCoordinate.cs +++ b/src/Core/Locations/GeoCoordinate.cs @@ -1,58 +1,57 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a coordinate. +/// +/// any of a set of numbers used in specifying the location of a point on a line, on a surface, or in space. +public class GeoCoordinate : IEquatable { /// - /// Represents a coordinate. + /// Initializes a new instance of the class. /// - /// any of a set of numbers used in specifying the location of a point on a line, on a surface, or in space. - public class GeoCoordinate : IEquatable + /// The latitude value. + /// The longitude value. + public GeoCoordinate(double latitude, double longitude) { - /// - /// Initializes a new instance of the class. - /// - /// The latitude value. - /// The longitude value. - public GeoCoordinate(double latitude, double longitude) + if (latitude is < -90 or > 90) { - if (latitude is < -90 or > 90) - { - throw new ArgumentException($"Invalid latitude value - {latitude}"); - } - - if (longitude is < -180 or > 180) - { - throw new ArgumentException($"Invalid longitude value - {longitude}"); - } - - Latitude = latitude; - Longitude = longitude; + throw new ArgumentException($"Invalid latitude value - {latitude}"); } - /// - /// Gets the latitude of the coordinate. - /// - public double Latitude { get; } + if (longitude is < -180 or > 180) + { + throw new ArgumentException($"Invalid longitude value - {longitude}"); + } - /// - /// Gets the longitude of the coordinate. - /// - public double Longitude { get; } + Latitude = latitude; + Longitude = longitude; + } - public static bool operator ==(GeoCoordinate? left, GeoCoordinate? right) => Equals(left, right); + /// + /// Gets the latitude of the coordinate. + /// + public double Latitude { get; } - public static bool operator !=(GeoCoordinate? left, GeoCoordinate? right) => !Equals(left, right); + /// + /// Gets the longitude of the coordinate. + /// + public double Longitude { get; } - /// - public override string ToString() => $"Latitude: {Latitude} - Longitude: {Longitude}"; + public static bool operator ==(GeoCoordinate? left, GeoCoordinate? right) => Equals(left, right); - /// - public bool Equals(GeoCoordinate? other) => other != null && (Latitude, Longitude).Equals((other.Latitude, other.Longitude)); + public static bool operator !=(GeoCoordinate? left, GeoCoordinate? right) => !Equals(left, right); - /// - public override bool Equals(object? obj) => obj is GeoCoordinate coordinate && Equals(coordinate); + /// + public override string ToString() => $"Latitude: {Latitude} - Longitude: {Longitude}"; - /// - public override int GetHashCode() => (Latitude, Longitude).GetHashCode(); - } + /// + public bool Equals(GeoCoordinate? other) => other != null && (Latitude, Longitude).Equals((other.Latitude, other.Longitude)); + + /// + public override bool Equals(object? obj) => obj is GeoCoordinate coordinate && Equals(coordinate); + + /// + public override int GetHashCode() => (Latitude, Longitude).GetHashCode(); } \ No newline at end of file diff --git a/src/Core/Locations/GeoLocation.cs b/src/Core/Locations/GeoLocation.cs index 886d0a552..5249ebc1e 100644 --- a/src/Core/Locations/GeoLocation.cs +++ b/src/Core/Locations/GeoLocation.cs @@ -1,29 +1,28 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a latitude and longitude. +/// +public class GeoLocation { /// - /// Represents a latitude and longitude. + /// Initializes a new instance of the class. /// - public class GeoLocation + /// The latitude. + /// The longitude. + public GeoLocation(double latitude, double longitude) { - /// - /// Initializes a new instance of the class. - /// - /// The latitude. - /// The longitude. - public GeoLocation(double latitude, double longitude) - { - Latitude = latitude; - Longitude = longitude; - } + Latitude = latitude; + Longitude = longitude; + } - /// - /// Gets the latitude. - /// - public double Latitude { get; } + /// + /// Gets the latitude. + /// + public double Latitude { get; } - /// - /// Gets the longitude. - /// - public double Longitude { get; } - } + /// + /// Gets the longitude. + /// + public double Longitude { get; } } \ No newline at end of file diff --git a/src/Core/Locations/GpsLocation.cs b/src/Core/Locations/GpsLocation.cs index c37e4edb9..d00e1dcd8 100644 --- a/src/Core/Locations/GpsLocation.cs +++ b/src/Core/Locations/GpsLocation.cs @@ -1,91 +1,90 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a gps location. +/// +public class GpsLocation : IGpsLocation { /// - /// Represents a gps location. + /// Initializes a new instance of the class. /// - public class GpsLocation : IGpsLocation + /// The latitude. + /// The longitude. + /// The altitude. + /// The heading. + /// The heading accuracy. + /// The speed. + /// The speed accuracy. + /// The position accuracy. + /// The date time of the reading. + public GpsLocation( + double latitude, + double longitude, + double altitude, + double heading, + double headingAccuracy, + double speed, + double speedAccuracy, + double positionAccuracy, + DateTimeOffset timestamp) + : this(new GeoCoordinate(latitude, longitude), altitude, heading, headingAccuracy, speed, speedAccuracy, positionAccuracy, timestamp) { - /// - /// Initializes a new instance of the class. - /// - /// The latitude. - /// The longitude. - /// The altitude. - /// The heading. - /// The heading accuracy. - /// The speed. - /// The speed accuracy. - /// The position accuracy. - /// The date time of the reading. - public GpsLocation( - double latitude, - double longitude, - double altitude, - double heading, - double headingAccuracy, - double speed, - double speedAccuracy, - double positionAccuracy, - DateTimeOffset timestamp) - : this(new GeoCoordinate(latitude, longitude), altitude, heading, headingAccuracy, speed, speedAccuracy, positionAccuracy, timestamp) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// The position. - /// The altitude. - /// The heading. - /// The heading accuracy. - /// The speed. - /// The speed accuracy. - /// The position accuracy. - /// The date time of the reading. - public GpsLocation( - GeoCoordinate position, - double altitude, - double heading, - double headingAccuracy, - double speed, - double speedAccuracy, - double positionAccuracy, - DateTimeOffset timestamp) - { - Altitude = altitude; - Heading = heading; - HeadingAccuracy = headingAccuracy; - Speed = speed; - SpeedAccuracy = speedAccuracy; - Position = position; - PositionAccuracy = positionAccuracy; - Timestamp = timestamp; - } + /// + /// Initializes a new instance of the class. + /// + /// The position. + /// The altitude. + /// The heading. + /// The heading accuracy. + /// The speed. + /// The speed accuracy. + /// The position accuracy. + /// The date time of the reading. + public GpsLocation( + GeoCoordinate position, + double altitude, + double heading, + double headingAccuracy, + double speed, + double speedAccuracy, + double positionAccuracy, + DateTimeOffset timestamp) + { + Altitude = altitude; + Heading = heading; + HeadingAccuracy = headingAccuracy; + Speed = speed; + SpeedAccuracy = speedAccuracy; + Position = position; + PositionAccuracy = positionAccuracy; + Timestamp = timestamp; + } - /// - public double Altitude { get; } + /// + public double Altitude { get; } - /// - public double Heading { get; } + /// + public double Heading { get; } - /// - public double HeadingAccuracy { get; } + /// + public double HeadingAccuracy { get; } - /// - public double Speed { get; } + /// + public double Speed { get; } - /// - public double SpeedAccuracy { get; } + /// + public double SpeedAccuracy { get; } - /// - public GeoCoordinate Position { get; } + /// + public GeoCoordinate Position { get; } - /// - public double PositionAccuracy { get; } + /// + public double PositionAccuracy { get; } - /// - public DateTimeOffset Timestamp { get; } - } + /// + public DateTimeOffset Timestamp { get; } } \ No newline at end of file diff --git a/src/Core/Locations/ICoreLocationService.cs b/src/Core/Locations/ICoreLocationService.cs index 2b4bf57b4..a6ee8e90d 100644 --- a/src/Core/Locations/ICoreLocationService.cs +++ b/src/Core/Locations/ICoreLocationService.cs @@ -1,81 +1,80 @@ using System; using System.Reactive; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface that represents a reactive CLLocationManager. +/// +public interface ICoreLocationService { /// - /// Interface that represents a reactive CLLocationManager. + /// Gets an observable sequence notifying that authorization change. /// - public interface ICoreLocationService - { - /// - /// Gets an observable sequence notifying that authorization change. - /// - IObservable AuthorizationChanged { get; } + IObservable AuthorizationChanged { get; } - /// - /// Gets an observable sequence of deferred update completions. - /// - IObservable DeferredUpdatesFinished { get; } + /// + /// Gets an observable sequence of deferred update completions. + /// + IObservable DeferredUpdatesFinished { get; } - /// - /// Gets an observable sequence of notifications when region state is determined. - /// - IObservable DeterminedState { get; } + /// + /// Gets an observable sequence of notifications when region state is determined. + /// + IObservable DeterminedState { get; } - /// - /// Gets an observable sequence of regions when the are started being monitored. - /// - IObservable StartedMonitoringForRegion { get; } + /// + /// Gets an observable sequence of regions when the are started being monitored. + /// + IObservable StartedMonitoringForRegion { get; } - /// - /// Gets an observable sequence of regions visited. - /// - IObservable Visited { get; } + /// + /// Gets an observable sequence of regions visited. + /// + IObservable Visited { get; } - /// - /// Gets an observable sequence of failure notifications. - /// - IObservable Failed { get; } + /// + /// Gets an observable sequence of failure notifications. + /// + IObservable Failed { get; } - /// - /// Gets an observable sequence notifying when location updates paused. - /// - IObservable LocationUpdatesPaused { get; } + /// + /// Gets an observable sequence notifying when location updates paused. + /// + IObservable LocationUpdatesPaused { get; } - /// - /// Gets an observable sequence notifying when location updates resume. - /// - IObservable LocationUpdatesResumed { get; } + /// + /// Gets an observable sequence notifying when location updates resume. + /// + IObservable LocationUpdatesResumed { get; } - /// - /// Gets an observable sequence notifying when location updates resume. - /// - IObservable LocationsUpdated { get; } + /// + /// Gets an observable sequence notifying when location updates resume. + /// + IObservable LocationsUpdated { get; } - /// - /// Gets whether the monitoring failed. - /// - IObservable MonitoringFailed { get; } + /// + /// Gets whether the monitoring failed. + /// + IObservable MonitoringFailed { get; } - /// - /// Gets an observable sequence notifying when a region has been entered. - /// - IObservable RegionEntered { get; } + /// + /// Gets an observable sequence notifying when a region has been entered. + /// + IObservable RegionEntered { get; } - /// - /// Gets an observable sequence notifying when a region has been exited. - /// - IObservable RegionExited { get; } + /// + /// Gets an observable sequence notifying when a region has been exited. + /// + IObservable RegionExited { get; } - /// - /// Gets an observable sequence of heading update notifications. - /// - IObservable UpdatedHeading { get; } + /// + /// Gets an observable sequence of heading update notifications. + /// + IObservable UpdatedHeading { get; } - /// - /// Gets the location update notifications. - /// - IObservable UpdatedLocation { get; } - } -} + /// + /// Gets the location update notifications. + /// + IObservable UpdatedLocation { get; } +} \ No newline at end of file diff --git a/src/Core/Locations/IGpsLocation.cs b/src/Core/Locations/IGpsLocation.cs index 7d33879f0..6064b65ec 100644 --- a/src/Core/Locations/IGpsLocation.cs +++ b/src/Core/Locations/IGpsLocation.cs @@ -1,50 +1,49 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a gps location. +/// +public interface IGpsLocation { /// - /// Interface representing a gps location. - /// - public interface IGpsLocation - { - /// - /// Gets the altitude of the reading. - /// - double Altitude { get; } - - /// - /// Gets the heading of the reading. - /// - double Heading { get; } - - /// - /// Gets the accuracy of the heading. - /// - double HeadingAccuracy { get; } - - /// - /// Gets the current speed. - /// - double Speed { get; } - - /// - /// Gets the accuracy in meters per second for the speed. - /// - double SpeedAccuracy { get; } - - /// - /// Gets the position of the reading. - /// - GeoCoordinate Position { get; } - - /// - /// Gets the position accuracy. - /// - double PositionAccuracy { get; } - - /// - /// Gets the timestamp. - /// - DateTimeOffset Timestamp { get; } - } + /// Gets the altitude of the reading. + /// + double Altitude { get; } + + /// + /// Gets the heading of the reading. + /// + double Heading { get; } + + /// + /// Gets the accuracy of the heading. + /// + double HeadingAccuracy { get; } + + /// + /// Gets the current speed. + /// + double Speed { get; } + + /// + /// Gets the accuracy in meters per second for the speed. + /// + double SpeedAccuracy { get; } + + /// + /// Gets the position of the reading. + /// + GeoCoordinate Position { get; } + + /// + /// Gets the position accuracy. + /// + double PositionAccuracy { get; } + + /// + /// Gets the timestamp. + /// + DateTimeOffset Timestamp { get; } } \ No newline at end of file diff --git a/src/Core/Locations/LocationAccuracy.cs b/src/Core/Locations/LocationAccuracy.cs index 5ad7001f2..fb855004e 100644 --- a/src/Core/Locations/LocationAccuracy.cs +++ b/src/Core/Locations/LocationAccuracy.cs @@ -1,39 +1,38 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Enumeration of location accuracy. +/// +/// https://stackoverflow.com/q/3411629/2088094. +public enum LocationAccuracy { /// - /// Enumeration of location accuracy. + /// Best Accuracy. /// - /// https://stackoverflow.com/q/3411629/2088094. - public enum LocationAccuracy - { - /// - /// Best Accuracy. - /// - AccuracyBest = -1, + AccuracyBest = -1, - /// - /// Accuracy to one hundred meters. - /// - AccuracyHundredMeters = 100, + /// + /// Accuracy to one hundred meters. + /// + AccuracyHundredMeters = 100, - /// - /// Accuracy to the kilometer. - /// - AccuracyKilometer = 1000, + /// + /// Accuracy to the kilometer. + /// + AccuracyKilometer = 1000, - /// - /// Accuracy to the nearest ten meters. - /// - AccuracyNearestTenMeters = 10, + /// + /// Accuracy to the nearest ten meters. + /// + AccuracyNearestTenMeters = 10, - /// - /// Accuracy to three kilometers. - /// - AccuracyThreeKilometers = 3000, + /// + /// Accuracy to three kilometers. + /// + AccuracyThreeKilometers = 3000, - /// - /// Accuracy for Navigation. - /// - AccuracyBestForNavigation = -2 - } + /// + /// Accuracy for Navigation. + /// + AccuracyBestForNavigation = -2 } \ No newline at end of file diff --git a/src/Core/Locations/MonitorResult.cs b/src/Core/Locations/MonitorResult.cs index 50f90b308..ca6e2d5ac 100644 --- a/src/Core/Locations/MonitorResult.cs +++ b/src/Core/Locations/MonitorResult.cs @@ -1,41 +1,40 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Returns the entire state of the current Core Location Manager. +/// +public class MonitorResult { /// - /// Returns the entire state of the current Core Location Manager. + /// Initializes a new instance of the class. /// - public class MonitorResult + /// The state. + /// The last changed datetime. + public MonitorResult(MonitorState state, DateTimeOffset lastChanged) { - /// - /// Initializes a new instance of the class. - /// - /// The state. - /// The last changed datetime. - public MonitorResult(MonitorState state, DateTimeOffset lastChanged) - { - State = state; - LastChanged = lastChanged; - } + State = state; + LastChanged = lastChanged; + } - /// - /// Gets the current state. - /// - public MonitorState State { get; } + /// + /// Gets the current state. + /// + public MonitorState State { get; } - /// - /// Gets the last changed date time offset. - /// - public DateTimeOffset LastChanged { get; } + /// + /// Gets the last changed date time offset. + /// + public DateTimeOffset LastChanged { get; } - /// - /// Gets or sets the exception. - /// - public Exception? Exception { get; set; } + /// + /// Gets or sets the exception. + /// + public Exception? Exception { get; set; } - /// - /// Gets or sets a value indicating whether the result of the request was successful. - /// - public bool Success { get; set; } - } + /// + /// Gets or sets a value indicating whether the result of the request was successful. + /// + public bool Success { get; set; } } \ No newline at end of file diff --git a/src/Core/Locations/MonitorState.cs b/src/Core/Locations/MonitorState.cs index edc8d019f..0cc0c4d63 100644 --- a/src/Core/Locations/MonitorState.cs +++ b/src/Core/Locations/MonitorState.cs @@ -1,73 +1,72 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents the current state of the platform service configuration. +/// +public class MonitorState { /// - /// Represents the current state of the platform service configuration. + /// Gets or sets a value indicating whether to allow background location updates. /// - public class MonitorState - { - /// - /// Gets or sets a value indicating whether to allow background location updates. - /// - public bool AllowingBackgroundLocationUpdates { get; set; } + public bool AllowingBackgroundLocationUpdates { get; set; } - /// - /// Gets or sets the desired accuracy. - /// - public double DesiredAccuracy { get; set; } + /// + /// Gets or sets the desired accuracy. + /// + public double DesiredAccuracy { get; set; } - /// - /// Gets or sets the distance filter. - /// - public double DistanceFilter { get; set; } + /// + /// Gets or sets the distance filter. + /// + public double DistanceFilter { get; set; } - /// - /// Gets or sets the current location. - /// - public GeoLocation GeoLocation { get; set; } + /// + /// Gets or sets the current location. + /// + public GeoLocation GeoLocation { get; set; } - /// - /// Gets or sets a value indicating whether location services are enabled. - /// - public bool LocationServicesEnabled { get; set; } + /// + /// Gets or sets a value indicating whether location services are enabled. + /// + public bool LocationServicesEnabled { get; set; } - /// - /// Gets or sets a value indicating whether the location services are enabled. - /// - public bool MaximumRegionMonitoringDistance { get; set; } + /// + /// Gets or sets a value indicating whether the location services are enabled. + /// + public bool MaximumRegionMonitoringDistance { get; set; } - /// - /// Gets or sets a value indicating whether to pause location updates automatically. - /// - public bool PausesLocationUpdatesAutomatically { get; set; } + /// + /// Gets or sets a value indicating whether to pause location updates automatically. + /// + public bool PausesLocationUpdatesAutomatically { get; set; } - /// - /// Gets or sets a value indicating whether region monitoring is available. - /// - public bool RegionMonitoringAvailable { get; set; } + /// + /// Gets or sets a value indicating whether region monitoring is available. + /// + public bool RegionMonitoringAvailable { get; set; } - /// - /// Gets or sets a value indicating whether region monitoring is enabled. - /// - public bool RegionMonitoringEnabled { get; set; } + /// + /// Gets or sets a value indicating whether region monitoring is enabled. + /// + public bool RegionMonitoringEnabled { get; set; } - /// - /// Gets or sets a value indicating whether to show background location indicator. - /// - public bool ShowsBackgroundLocationIndicator { get; set; } + /// + /// Gets or sets a value indicating whether to show background location indicator. + /// + public bool ShowsBackgroundLocationIndicator { get; set; } - /// - /// Gets or sets a value indicating whether significant location changed monitoring is available. - /// - public bool SignificantLocationChangeMonitoringAvailable { get; set; } + /// + /// Gets or sets a value indicating whether significant location changed monitoring is available. + /// + public bool SignificantLocationChangeMonitoringAvailable { get; set; } - /// - /// Gets or sets the maximum time interval. - /// - public double MaxTimeInterval { get; set; } + /// + /// Gets or sets the maximum time interval. + /// + public double MaxTimeInterval { get; set; } - /// - /// Gets or sets the authorization status. - /// - public AuthorizationStatus Status { get; set; } - } + /// + /// Gets or sets the authorization status. + /// + public AuthorizationStatus Status { get; set; } } \ No newline at end of file diff --git a/src/Core/Locations/RegionState.cs b/src/Core/Locations/RegionState.cs index 5c669d312..65ebe4be1 100644 --- a/src/Core/Locations/RegionState.cs +++ b/src/Core/Locations/RegionState.cs @@ -1,23 +1,22 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Enumeration of Region State. +/// +public enum RegionState { /// - /// Enumeration of Region State. + /// Unknown State. /// - public enum RegionState - { - /// - /// Unknown State. - /// - Unknown, + Unknown, - /// - /// Inside. - /// - Inside, + /// + /// Inside. + /// + Inside, - /// - /// Outside. - /// - Outside, - } + /// + /// Outside. + /// + Outside, } \ No newline at end of file diff --git a/src/Core/Operations/Background/IBackgroundOperation.cs b/src/Core/Operations/Background/IBackgroundOperation.cs index 8e2aad95d..ff66ea25a 100644 --- a/src/Core/Operations/Background/IBackgroundOperation.cs +++ b/src/Core/Operations/Background/IBackgroundOperation.cs @@ -1,26 +1,25 @@ using System; using System.Threading.Tasks; -namespace Rocket.Surgery.Airframe.Background +namespace Rocket.Surgery.Airframe.Background; + +/// +/// Interface representing an operation to run in the background on a specific platform. +/// +public interface IBackgroundOperation { /// - /// Interface representing an operation to run in the background on a specific platform. + /// Processes the task on the platform specific background thread. /// - public interface IBackgroundOperation - { - /// - /// Processes the task on the platform specific background thread. - /// - /// The background operation. - /// A completion notification. - Task ExecuteInBackground(Func operation); + /// The background operation. + /// A completion notification. + Task ExecuteInBackground(Func operation); - /// - /// Processes the task on the platform specific background thread. - /// - /// The background operation. - /// The return type. - /// A typed completion notification. - Task ExecuteInBackground(Func> operation); - } + /// + /// Processes the task on the platform specific background thread. + /// + /// The background operation. + /// The return type. + /// A typed completion notification. + Task ExecuteInBackground(Func> operation); } \ No newline at end of file diff --git a/src/Core/Operations/ICanExecute.cs b/src/Core/Operations/ICanExecute.cs index b6864bbae..1bf5561f4 100644 --- a/src/Core/Operations/ICanExecute.cs +++ b/src/Core/Operations/ICanExecute.cs @@ -1,14 +1,13 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing whether a thing™ can execute. +/// +public interface ICanExecute { /// - /// Interface representing whether a thing™ can execute. + /// Gets a value indicating whether this instance will execute the operation. /// - public interface ICanExecute - { - /// - /// Gets a value indicating whether this instance will execute the operation. - /// - /// Whether the instance will execute. - bool CanExecute(); - } + /// Whether the instance will execute. + bool CanExecute(); } \ No newline at end of file diff --git a/src/Core/Operations/IOperation.cs b/src/Core/Operations/IOperation.cs index e28b757a3..f879d9f92 100644 --- a/src/Core/Operations/IOperation.cs +++ b/src/Core/Operations/IOperation.cs @@ -1,25 +1,24 @@ using System; using System.Reactive; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a base operation. +/// +public interface IOperation : IOperation { - /// - /// Interface representing a base operation. - /// - public interface IOperation : IOperation - { - } +} +/// +/// Interface representing a base operation. +/// +/// The result type. +public interface IOperation : ICanExecute +{ /// - /// Interface representing a base operation. + /// Executes the operation. /// - /// The result type. - public interface IOperation : ICanExecute - { - /// - /// Executes the operation. - /// - /// A completion notification. - IObservable Execute(); - } + /// A completion notification. + IObservable Execute(); } \ No newline at end of file diff --git a/src/Core/Operations/Startup/ApplicationStartup.cs b/src/Core/Operations/Startup/ApplicationStartup.cs index 11941eb69..bf8ee7e5a 100644 --- a/src/Core/Operations/Startup/ApplicationStartup.cs +++ b/src/Core/Operations/Startup/ApplicationStartup.cs @@ -1,21 +1,20 @@ using System.Collections.Generic; using Microsoft.Extensions.Logging; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents the application startup sequence. +/// +public sealed class ApplicationStartup : LoggableApplicationStartup, IApplicationStartup { /// - /// Represents the application startup sequence. + /// Initializes a new instance of the class. /// - public sealed class ApplicationStartup : LoggableApplicationStartup, IApplicationStartup + /// The logger factory. + /// The startup operations. + public ApplicationStartup(ILoggerFactory loggerFactory, IEnumerable startupOperations) + : base(loggerFactory, startupOperations) { - /// - /// Initializes a new instance of the class. - /// - /// The logger factory. - /// The startup operations. - public ApplicationStartup(ILoggerFactory loggerFactory, IEnumerable startupOperations) - : base(loggerFactory, startupOperations) - { - } } } \ No newline at end of file diff --git a/src/Core/Operations/Startup/IApplicationStartup.cs b/src/Core/Operations/Startup/IApplicationStartup.cs index ad9868aeb..70380060f 100644 --- a/src/Core/Operations/Startup/IApplicationStartup.cs +++ b/src/Core/Operations/Startup/IApplicationStartup.cs @@ -2,26 +2,25 @@ using System.Reactive; using System.Reactive.Concurrency; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing that application startup sequence. +/// +public interface IApplicationStartup { /// - /// Interface representing that application startup sequence. + /// Starts the application life cycle. /// - public interface IApplicationStartup - { - /// - /// Starts the application life cycle. - /// - /// The maximum concurrent operations. - /// A completion notification. - IObservable Startup(int concurrentOperations = 1); + /// The maximum concurrent operations. + /// A completion notification. + IObservable Startup(int concurrentOperations = 1); - /// - /// Starts the application life cycle. - /// - /// The maximum concurrent operations. - /// The scheduler. - /// A completion notification. - IObservable Startup(int concurrentOperations, IScheduler scheduler); - } + /// + /// Starts the application life cycle. + /// + /// The maximum concurrent operations. + /// The scheduler. + /// A completion notification. + IObservable Startup(int concurrentOperations, IScheduler scheduler); } \ No newline at end of file diff --git a/src/Core/Operations/Startup/IStartupOperation.cs b/src/Core/Operations/Startup/IStartupOperation.cs index 6ef48e180..83e03e72a 100644 --- a/src/Core/Operations/Startup/IStartupOperation.cs +++ b/src/Core/Operations/Startup/IStartupOperation.cs @@ -1,17 +1,16 @@ using System; using System.Reactive; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a startup operation. +/// +public interface IStartupOperation : IOperation { /// - /// Interface representing a startup operation. + /// Starts the operation. /// - public interface IStartupOperation : IOperation - { - /// - /// Starts the operation. - /// - /// A completion notification. - IObservable Start(); - } + /// A completion notification. + IObservable Start(); } \ No newline at end of file diff --git a/src/Core/Operations/Startup/LoggableApplicationStartup.cs b/src/Core/Operations/Startup/LoggableApplicationStartup.cs index 736b47506..b271956a7 100644 --- a/src/Core/Operations/Startup/LoggableApplicationStartup.cs +++ b/src/Core/Operations/Startup/LoggableApplicationStartup.cs @@ -6,53 +6,52 @@ using System.Reactive.Linq; using Microsoft.Extensions.Logging; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents the application startup sequence. +/// +public abstract class LoggableApplicationStartup : IApplicationStartup { + private readonly ILogger _logger; + private readonly IEnumerable _startupOperations; + /// - /// Represents the application startup sequence. + /// Initializes a new instance of the class. /// - public abstract class LoggableApplicationStartup : IApplicationStartup + /// The logger factory. + /// The startup tasks. + protected LoggableApplicationStartup(ILoggerFactory loggerFactory, IEnumerable startupOperations) { - private readonly ILogger _logger; - private readonly IEnumerable _startupOperations; - - /// - /// Initializes a new instance of the class. - /// - /// The logger factory. - /// The startup tasks. - protected LoggableApplicationStartup(ILoggerFactory loggerFactory, IEnumerable startupOperations) - { - _logger = loggerFactory.CreateLogger(GetType()); - _startupOperations = startupOperations; - } + _logger = loggerFactory.CreateLogger(GetType()); + _startupOperations = startupOperations; + } - /// - IObservable IApplicationStartup.Startup(int concurrentOperations) => Startup(concurrentOperations) - .Finally(() => _logger.LogTrace("Start Complete: {Startup}", GetType().Name)); + /// + IObservable IApplicationStartup.Startup(int concurrentOperations) => Startup(concurrentOperations) + .Finally(() => _logger.LogTrace("Start Complete: {Startup}", GetType().Name)); - /// - IObservable IApplicationStartup.Startup(int concurrentOperations, IScheduler scheduler) => Startup(concurrentOperations, scheduler) - .Finally(() => _logger.LogTrace("Start Complete: {Startup}", GetType().Name)); + /// + IObservable IApplicationStartup.Startup(int concurrentOperations, IScheduler scheduler) => Startup(concurrentOperations, scheduler) + .Finally(() => _logger.LogTrace("Start Complete: {Startup}", GetType().Name)); - /// - /// Executes the provided . - /// - /// The maximum concurrent operations. - /// The scheduler. - /// A completion notification of the startup operation execution. - protected virtual IObservable Startup(int concurrentOperations, IScheduler scheduler) => _startupOperations - .Where(operation => operation.CanExecute()) - .Select(operation => operation.Start()) - .Merge(concurrentOperations, scheduler) - .PublishLast() - .RefCount(); + /// + /// Executes the provided . + /// + /// The maximum concurrent operations. + /// The scheduler. + /// A completion notification of the startup operation execution. + protected virtual IObservable Startup(int concurrentOperations, IScheduler scheduler) => _startupOperations + .Where(operation => operation.CanExecute()) + .Select(operation => operation.Start()) + .Merge(concurrentOperations, scheduler) + .PublishLast() + .RefCount(); - /// - /// Executes the provided . - /// - /// The maximum concurrent operations. - /// A completion notification of the startup operation execution. - protected virtual IObservable Startup(int concurrentOperations = 1) => Startup(concurrentOperations, CurrentThreadScheduler.Instance); - } + /// + /// Executes the provided . + /// + /// The maximum concurrent operations. + /// A completion notification of the startup operation execution. + protected virtual IObservable Startup(int concurrentOperations = 1) => Startup(concurrentOperations, CurrentThreadScheduler.Instance); } \ No newline at end of file diff --git a/src/Core/Operations/Startup/LoggableStartupOperation.cs b/src/Core/Operations/Startup/LoggableStartupOperation.cs index ef58220c2..1e9b3eb22 100644 --- a/src/Core/Operations/Startup/LoggableStartupOperation.cs +++ b/src/Core/Operations/Startup/LoggableStartupOperation.cs @@ -3,54 +3,53 @@ using System.Reactive.Linq; using Microsoft.Extensions.Logging; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a that logs using . +/// +public abstract class LoggableStartupOperation : IStartupOperation { /// - /// Represents a that logs using . + /// Initializes a new instance of the class. + /// + /// The logger factory. + protected LoggableStartupOperation(ILoggerFactory factory) => Logger = factory.CreateLogger(GetType()); + + /// + /// Gets the logger. /// - public abstract class LoggableStartupOperation : IStartupOperation + protected ILogger Logger { get; } + + /// + IObservable IStartupOperation.Start() => + + // Add logging. + Start().Finally(() => Logger.LogTrace("{StartupOperation}: Completed", GetType().Name)); + + /// + IObservable IOperation.Execute() => + + // Add logging. + ((IStartupOperation)this).Start(); + + /// + bool ICanExecute.CanExecute() { - /// - /// Initializes a new instance of the class. - /// - /// The logger factory. - protected LoggableStartupOperation(ILoggerFactory factory) => Logger = factory.CreateLogger(GetType()); - - /// - /// Gets the logger. - /// - protected ILogger Logger { get; } - - /// - IObservable IStartupOperation.Start() => - - // Add logging. - Start().Finally(() => Logger.LogTrace("{StartupOperation}: Completed", GetType().Name)); - - /// - IObservable IOperation.Execute() => - - // Add logging. - ((IStartupOperation)this).Start(); - - /// - bool ICanExecute.CanExecute() - { - var canExecute = CanExecute(); - Logger.LogTrace("Can Execute: {CanExecute}", canExecute); - return canExecute; - } - - /// - /// Template method for the startup operation. - /// - /// A completion notification. - protected abstract IObservable Start(); - - /// - /// Template method for whether or not the startup operation will execute. - /// - /// A completion notification. - protected virtual bool CanExecute() => true; + var canExecute = CanExecute(); + Logger.LogTrace("Can Execute: {CanExecute}", canExecute); + return canExecute; } + + /// + /// Template method for the startup operation. + /// + /// A completion notification. + protected abstract IObservable Start(); + + /// + /// Template method for whether or not the startup operation will execute. + /// + /// A completion notification. + protected virtual bool CanExecute() => true; } \ No newline at end of file diff --git a/src/Core/Operations/Startup/StartupOperationBase.cs b/src/Core/Operations/Startup/StartupOperationBase.cs index 7b82476fc..8a55e7bf8 100644 --- a/src/Core/Operations/Startup/StartupOperationBase.cs +++ b/src/Core/Operations/Startup/StartupOperationBase.cs @@ -1,34 +1,33 @@ using System; using System.Reactive; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents a base startup operation. +/// +public abstract class StartupOperationBase : IStartupOperation { - /// - /// Represents a base startup operation. - /// - public abstract class StartupOperationBase : IStartupOperation - { - /// - IObservable IStartupOperation.Start() => - Start(); + /// + IObservable IStartupOperation.Start() => + Start(); - /// - IObservable IOperation.Execute() => - Start(); + /// + IObservable IOperation.Execute() => + Start(); - /// - bool ICanExecute.CanExecute() => CanExecute(); + /// + bool ICanExecute.CanExecute() => CanExecute(); - /// - /// Template method for the startup operation. - /// - /// A completion notification. - protected abstract IObservable Start(); + /// + /// Template method for the startup operation. + /// + /// A completion notification. + protected abstract IObservable Start(); - /// - /// Template method for whether or not the startup operation will execute. - /// - /// A completion notification. - protected virtual bool CanExecute() => true; - } + /// + /// Template method for whether or not the startup operation will execute. + /// + /// A completion notification. + protected virtual bool CanExecute() => true; } \ No newline at end of file diff --git a/src/Core/Scheduling/ISchedulerProvider.cs b/src/Core/Scheduling/ISchedulerProvider.cs index 535e7a94b..447eba2d1 100644 --- a/src/Core/Scheduling/ISchedulerProvider.cs +++ b/src/Core/Scheduling/ISchedulerProvider.cs @@ -1,20 +1,19 @@ using System.Reactive.Concurrency; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a provider for instances. +/// +public interface ISchedulerProvider { /// - /// Interface representing a provider for instances. + /// Gets the user interface thread scheduler. /// - public interface ISchedulerProvider - { - /// - /// Gets the user interface thread scheduler. - /// - IScheduler UserInterfaceThread { get; } + IScheduler UserInterfaceThread { get; } - /// - /// Gets the background thread scheduler. - /// - IScheduler BackgroundThread { get; } - } + /// + /// Gets the background thread scheduler. + /// + IScheduler BackgroundThread { get; } } \ No newline at end of file diff --git a/src/Core/Settings/ISetting.cs b/src/Core/Settings/ISetting.cs index 678cf9d8a..694e90218 100644 --- a/src/Core/Settings/ISetting.cs +++ b/src/Core/Settings/ISetting.cs @@ -3,33 +3,32 @@ [assembly:SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Typed and untyped.")] -namespace Rocket.Surgery.Airframe.Settings +namespace Rocket.Surgery.Airframe.Settings; + +/// +/// Interface representing a setting. +/// +public interface ISetting : INotifyPropertyChanged { /// - /// Interface representing a setting. + /// Gets the key. /// - public interface ISetting : INotifyPropertyChanged - { - /// - /// Gets the key. - /// - string Key { get; } + string Key { get; } - /// - /// Gets or sets the value. - /// - object Value { get; set; } - } + /// + /// Gets or sets the value. + /// + object Value { get; set; } +} +/// +/// Interface representing a setting. +/// +/// The setting type. +public interface ISetting : ISetting +{ /// - /// Interface representing a setting. + /// Gets or sets the value. /// - /// The setting type. - public interface ISetting : ISetting - { - /// - /// Gets or sets the value. - /// - new T Value { get; set; } - } + new T Value { get; set; } } \ No newline at end of file diff --git a/src/Core/Settings/ISettingsProvider.cs b/src/Core/Settings/ISettingsProvider.cs index ef65fca51..02052a9b4 100644 --- a/src/Core/Settings/ISettingsProvider.cs +++ b/src/Core/Settings/ISettingsProvider.cs @@ -3,63 +3,62 @@ [assembly:SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", Justification = "Typed and untyped.")] -namespace Rocket.Surgery.Airframe.Settings +namespace Rocket.Surgery.Airframe.Settings; + +/// +/// Interface representing a way to access . +/// +public interface ISettingsProvider { /// - /// Interface representing a way to access . + /// Gets the with the specified key. /// - public interface ISettingsProvider - { - /// - /// Gets the with the specified key. - /// - /// The key. - /// The setting type. - /// The setting. - // ReSharper disable once CA1716 - ISetting Get(string key); + /// The key. + /// The setting type. + /// The setting. + // ReSharper disable once CA1716 + ISetting Get(string key); - /// - /// Gets the with the specified key and provides a default value. - /// - /// The key. - /// The default value. - /// The setting type. - /// The setting. - ISetting Get(string key, T defaultValue); + /// + /// Gets the with the specified key and provides a default value. + /// + /// The key. + /// The default value. + /// The setting type. + /// The setting. + ISetting Get(string key, T defaultValue); - /// - /// Gets an observable sequence of changes. - /// - /// The key. - /// The setting type. - /// A stream of settings. - IObservable> Observe(string key); + /// + /// Gets an observable sequence of changes. + /// + /// The key. + /// The setting type. + /// A stream of settings. + IObservable> Observe(string key); - /// - /// Sets the . - /// - /// The setting. - /// The setting type. - void Set(ISetting setting); + /// + /// Sets the . + /// + /// The setting. + /// The setting type. + void Set(ISetting setting); - /// - /// Remove the setting by key. - /// - /// The setting key. - /// A value indicating whether the setting was removed. - bool Remove(string key); + /// + /// Remove the setting by key. + /// + /// The setting key. + /// A value indicating whether the setting was removed. + bool Remove(string key); - /// - /// Checks if the setting key is set. - /// - /// The key. - /// A value indicating whether the setting is in the provider. - bool Contains(string key); + /// + /// Checks if the setting key is set. + /// + /// The key. + /// A value indicating whether the setting is in the provider. + bool Contains(string key); - /// - /// Clears all setting values. - /// - void Clear(); - } + /// + /// Clears all setting values. + /// + void Clear(); } \ No newline at end of file diff --git a/src/Core/Timers/IDecrement.cs b/src/Core/Timers/IDecrement.cs index 954faaae8..6bf88e833 100644 --- a/src/Core/Timers/IDecrement.cs +++ b/src/Core/Timers/IDecrement.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing an decrementing timer. +/// +public interface IDecrement : ITimer { - /// - /// Interface representing an decrementing timer. - /// - public interface IDecrement : ITimer - { - } -} +} \ No newline at end of file diff --git a/src/Core/Timers/IIncrement.cs b/src/Core/Timers/IIncrement.cs index d04fe5ce7..284951dd2 100644 --- a/src/Core/Timers/IIncrement.cs +++ b/src/Core/Timers/IIncrement.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing an incrementing timer. +/// +public interface IIncrement : ITimer { - /// - /// Interface representing an incrementing timer. - /// - public interface IIncrement : ITimer - { - } -} +} \ No newline at end of file diff --git a/src/Core/Timers/IObservableTimer.cs b/src/Core/Timers/IObservableTimer.cs index f7ebe3376..d1ed8f4db 100644 --- a/src/Core/Timers/IObservableTimer.cs +++ b/src/Core/Timers/IObservableTimer.cs @@ -1,11 +1,10 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Represents an that is observable. +/// +public interface IObservableTimer : ITimer, IObservable { - /// - /// Represents an that is observable. - /// - public interface IObservableTimer : ITimer, IObservable - { - } } \ No newline at end of file diff --git a/src/Core/Timers/ITimer.cs b/src/Core/Timers/ITimer.cs index 2607ff193..a910d7817 100644 --- a/src/Core/Timers/ITimer.cs +++ b/src/Core/Timers/ITimer.cs @@ -1,31 +1,30 @@ using System; -namespace Rocket.Surgery.Airframe +namespace Rocket.Surgery.Airframe; + +/// +/// Interface representing a base timer. +/// +public interface ITimer : IObservable { /// - /// Interface representing a base timer. + /// Gets a value indicating whether this instance is running. /// - public interface ITimer : IObservable - { - /// - /// Gets a value indicating whether this instance is running. - /// - bool IsRunning { get; } + bool IsRunning { get; } - /// - /// Starts the timer at the specified time. - /// - /// The time span. - void Start(TimeSpan timeSpan); + /// + /// Starts the timer at the specified time. + /// + /// The time span. + void Start(TimeSpan timeSpan); - /// - /// Starts the timer from it's current time. - /// - void Start(); + /// + /// Starts the timer from it's current time. + /// + void Start(); - /// - /// Stops the timer. - /// - void Stop(); - } + /// + /// Stops the timer. + /// + void Stop(); } \ No newline at end of file diff --git a/src/Data/CacheFunctions.cs b/src/Data/CacheFunctions.cs index f0807b02c..b0ee45f85 100644 --- a/src/Data/CacheFunctions.cs +++ b/src/Data/CacheFunctions.cs @@ -3,52 +3,51 @@ using System.Reactive.Linq; using DynamicData; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +internal static class CacheFunctions { - internal static class CacheFunctions - { - /// - /// Caches the list of . - /// - /// The result. - /// The cache. - /// A value determining whether to clear the cache. - /// A completion notification. - public static IObservable> Cache(this IObservable> result, SourceCache cache, bool clearCache) - where T : IHaveIdentifier => result - .Do(UpdateCache(cache, clearCache)) - .Select(_ => cache.Connect().RefCount()) - .Switch(); + /// + /// Caches the list of . + /// + /// The result. + /// The cache. + /// A value determining whether to clear the cache. + /// A completion notification. + public static IObservable> Cache(this IObservable> result, SourceCache cache, bool clearCache) + where T : IHaveIdentifier => result + .Do(UpdateCache(cache, clearCache)) + .Select(_ => cache.Connect().RefCount()) + .Switch(); - /// - /// Caches the list of . - /// - /// The result. - /// The cache. - /// A completion notification. - public static IObservable Cache(this IObservable result, SourceCache cache) - where T : IHaveIdentifier => result - .Do(x => Update(x, cache)); + /// + /// Caches the list of . + /// + /// The result. + /// The cache. + /// A completion notification. + public static IObservable Cache(this IObservable result, SourceCache cache) + where T : IHaveIdentifier => result + .Do(x => Update(x, cache)); - private static void Update(T item, ISourceCache cache) - where T : IHaveIdentifier => cache.AddOrUpdate(item); + private static void Update(T item, ISourceCache cache) + where T : IHaveIdentifier => cache.AddOrUpdate(item); - private static Action> UpdateCache(ISourceCache cache, bool clearCache) - where T : IHaveIdentifier => results => + private static Action> UpdateCache(ISourceCache cache, bool clearCache) + where T : IHaveIdentifier => results => + { + if (clearCache) + { + cache + .Edit(updater => + { + updater.Clear(); + updater.AddOrUpdate(results); + }); + } + else { - if (clearCache) - { - cache - .Edit(updater => - { - updater.Clear(); - updater.AddOrUpdate(results); - }); - } - else - { - cache.EditDiff(results, (first, second) => first.Id == second.Id); - } - }; - } + cache.EditDiff(results, (first, second) => first.Id == second.Id); + } + }; } \ No newline at end of file diff --git a/src/Data/Client/IClient.cs b/src/Data/Client/IClient.cs index ed5f61459..a0124478a 100644 --- a/src/Data/Client/IClient.cs +++ b/src/Data/Client/IClient.cs @@ -2,64 +2,63 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface that represents a client connection. +/// +public interface IClient : IDisposable { /// - /// Interface that represents a client connection. + /// Gets an item with the specified identifier. /// - public interface IClient : IDisposable - { - /// - /// Gets an item with the specified identifier. - /// - /// The identifier. - /// The item type. - /// The item. - Task Get(Guid id) - where T : IDto; + /// The identifier. + /// The item type. + /// The item. + Task Get(Guid id) + where T : IDto; - /// - /// Gets all items of the specified type. - /// - /// The item type. - /// The items. - Task> GetAll() - where T : IDto; + /// + /// Gets all items of the specified type. + /// + /// The item type. + /// The items. + Task> GetAll() + where T : IDto; - /// - /// Posts the specified entity. - /// - /// The entity. - /// The entity type. - /// The return entity. - Task Post(T entity) - where T : IDto; + /// + /// Posts the specified entity. + /// + /// The entity. + /// The entity type. + /// The return entity. + Task Post(T entity) + where T : IDto; - /// - /// Posts the specified entity. - /// - /// The entity. - /// The entity type. - /// The return entity. - Task Patch(T entity) - where T : IDto; + /// + /// Posts the specified entity. + /// + /// The entity. + /// The entity type. + /// The return entity. + Task Patch(T entity) + where T : IDto; - /// - /// Delete the specified entity. - /// - /// The identifier. - /// The entity type. - /// A completion notification. - Task Delete(Guid id) - where T : IDto; + /// + /// Delete the specified entity. + /// + /// The identifier. + /// The entity type. + /// A completion notification. + Task Delete(Guid id) + where T : IDto; - /// - /// Delete the specified entity. - /// - /// The entity. - /// The entity type. - /// A completion notification. - Task Delete(T entity) - where T : IDto; - } + /// + /// Delete the specified entity. + /// + /// The entity. + /// The entity type. + /// A completion notification. + Task Delete(T entity) + where T : IDto; } \ No newline at end of file diff --git a/src/Data/Data/DataServiceBase.cs b/src/Data/Data/DataServiceBase.cs index 3d14bc33d..6f9b051e2 100644 --- a/src/Data/Data/DataServiceBase.cs +++ b/src/Data/Data/DataServiceBase.cs @@ -6,122 +6,121 @@ using DynamicData; using JetBrains.Annotations; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Represents a base implementation. +/// +/// The data transfer object type. +public abstract class DataServiceBase : IDataService, IDisposable + where T : IDto { + private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); + private readonly IClient _client; + /// - /// Represents a base implementation. + /// Initializes a new instance of the class. /// - /// The data transfer object type. - public abstract class DataServiceBase : IDataService, IDisposable - where T : IDto - { - private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); - private readonly IClient _client; - - /// - /// Initializes a new instance of the class. - /// - /// The abstracted client. - protected DataServiceBase([NotNull] IClient client) => _client = client; - - /// - public virtual IObservable> ChangeSet => SourceCache.Connect().RefCount(); - - /// - /// Gets the source cache. - /// - protected SourceCache SourceCache { get; } = new SourceCache(x => x.Id); - - /// - public virtual IObservable Create(T dto) => - Observable.Create(_ => - { - var clientSubscription = Observable.FromAsync(() => _client.Post(dto)).Subscribe(); - - using var x = Observable.FromAsync(() => _semaphore.WaitAsync()).Subscribe(_); - SourceCache.AddOrUpdate(dto); - - return Disposable.Create(() => clientSubscription.Dispose()); - }); - - /// - public virtual IObservable Read() => Observable - .FromAsync(() => _client.GetAll()) - .SelectMany(x => x) - .Where(x => x != null) - .Do(_ => SourceCache.AddOrUpdate(_)); - - /// - public virtual IObservable Read(Guid id) => Observable - .FromAsync(() => _client.Get(id)) - .Where(x => x != null) - .Do(_ => SourceCache.AddOrUpdate(_)); - - /// - public virtual IObservable Update(T dto) => - Observable.Create(_ => - { - var clientSubscription = Observable.FromAsync(() => _client.Post(dto)).Subscribe(); - - using var x = Observable.FromAsync(() => _semaphore.WaitAsync()).Subscribe(_); - SourceCache.AddOrUpdate(dto); - - return Disposable.Create(() => clientSubscription.Dispose()); - }); - - /// - public virtual IObservable Delete(T dto) => - Observable.Create(_ => - { - var clientSubscription = Observable.FromAsync(() => _client.Delete(dto)).Subscribe(); - using var x = Observable.FromAsync(() => _semaphore.WaitAsync()).Subscribe(_); - SourceCache.Remove(dto); - - return Disposable.Create(() => clientSubscription.Dispose()); - }); - - /// - public IObservable Delete(Guid id) + /// The abstracted client. + protected DataServiceBase([NotNull] IClient client) => _client = client; + + /// + public virtual IObservable> ChangeSet => SourceCache.Connect().RefCount(); + + /// + /// Gets the source cache. + /// + protected SourceCache SourceCache { get; } = new SourceCache(x => x.Id); + + /// + public virtual IObservable Create(T dto) => + Observable.Create(_ => + { + var clientSubscription = Observable.FromAsync(() => _client.Post(dto)).Subscribe(); + + using var x = Observable.FromAsync(() => _semaphore.WaitAsync()).Subscribe(_); + SourceCache.AddOrUpdate(dto); + + return Disposable.Create(() => clientSubscription.Dispose()); + }); + + /// + public virtual IObservable Read() => Observable + .FromAsync(() => _client.GetAll()) + .SelectMany(x => x) + .Where(x => x != null) + .Do(_ => SourceCache.AddOrUpdate(_)); + + /// + public virtual IObservable Read(Guid id) => Observable + .FromAsync(() => _client.Get(id)) + .Where(x => x != null) + .Do(_ => SourceCache.AddOrUpdate(_)); + + /// + public virtual IObservable Update(T dto) => + Observable.Create(_ => { - var dto = SourceCache.Lookup(id); + var clientSubscription = Observable.FromAsync(() => _client.Post(dto)).Subscribe(); - return Delete(dto.Value); - } + using var x = Observable.FromAsync(() => _semaphore.WaitAsync()).Subscribe(_); + SourceCache.AddOrUpdate(dto); - /// - public void Dispose() + return Disposable.Create(() => clientSubscription.Dispose()); + }); + + /// + public virtual IObservable Delete(T dto) => + Observable.Create(_ => { - Dispose(true); - GC.SuppressFinalize(this); - } + var clientSubscription = Observable.FromAsync(() => _client.Delete(dto)).Subscribe(); + using var x = Observable.FromAsync(() => _semaphore.WaitAsync()).Subscribe(_); + SourceCache.Remove(dto); - /// - IObservable IDataService.Create(object dto) => Create((T)dto); + return Disposable.Create(() => clientSubscription.Dispose()); + }); - /// - IObservable IDataService.Read() => Read().Select(x => x as object); + /// + public IObservable Delete(Guid id) + { + var dto = SourceCache.Lookup(id); + + return Delete(dto.Value); + } + + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - IObservable IDataService.Read(Guid id) => Read(id).Select(x => x as object); + /// + IObservable IDataService.Create(object dto) => Create((T)dto); - /// - IObservable IDataService.Update(object dto) => Update((T)dto); + /// + IObservable IDataService.Read() => Read().Select(x => x as object); - /// - IObservable IDataService.Delete(object dto) => Delete((T)dto); + /// + IObservable IDataService.Read(Guid id) => Read(id).Select(x => x as object); - /// - /// Disposes of resources when finalizing. - /// - /// A value indicating whether or not this instance is disposing. - protected virtual void Dispose(bool disposing) + /// + IObservable IDataService.Update(object dto) => Update((T)dto); + + /// + IObservable IDataService.Delete(object dto) => Delete((T)dto); + + /// + /// Disposes of resources when finalizing. + /// + /// A value indicating whether or not this instance is disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - _semaphore.Dispose(); - _client.Dispose(); - SourceCache.Dispose(); - } + _semaphore.Dispose(); + _client.Dispose(); + SourceCache.Dispose(); } } } \ No newline at end of file diff --git a/src/Data/Data/Dto.cs b/src/Data/Data/Dto.cs index 4a5acba4b..158f068fc 100644 --- a/src/Data/Data/Dto.cs +++ b/src/Data/Data/Dto.cs @@ -1,29 +1,28 @@ using System; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Represents a data transfer object. +/// +public abstract class Dto : IDto { /// - /// Represents a data transfer object. + /// Initializes a new instance of the class. /// - public abstract class Dto : IDto + protected Dto() + : this(Guid.NewGuid()) { - /// - /// Initializes a new instance of the class. - /// - protected Dto() - : this(Guid.NewGuid()) - { - } + } - /// - /// Initializes a new instance of the class. - /// - /// The global unique identifier. - protected Dto(Guid id) => Id = id; + /// + /// Initializes a new instance of the class. + /// + /// The global unique identifier. + protected Dto(Guid id) => Id = id; - /// - /// Gets or sets the unique identifier. - /// - public Guid Id { get; set; } - } + /// + /// Gets or sets the unique identifier. + /// + public Guid Id { get; set; } } \ No newline at end of file diff --git a/src/Data/Data/IDataService.cs b/src/Data/Data/IDataService.cs index ace3114cb..f3fe1fbc9 100644 --- a/src/Data/Data/IDataService.cs +++ b/src/Data/Data/IDataService.cs @@ -3,100 +3,99 @@ using System.Reactive; using DynamicData; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface representing a typed data service. +/// +/// The dto type. +[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Typed and untyped.")] +public interface IDataService : IDataService + where T : IDto { /// - /// Interface representing a typed data service. + /// Gets the observable of change sets. /// - /// The dto type. - [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Typed and untyped.")] - public interface IDataService : IDataService - where T : IDto - { - /// - /// Gets the observable of change sets. - /// - IObservable> ChangeSet { get; } + IObservable> ChangeSet { get; } - /// - /// Creates a new entity. - /// - /// The dto. - /// A completion notification. - IObservable Create(T dto); + /// + /// Creates a new entity. + /// + /// The dto. + /// A completion notification. + IObservable Create(T dto); - /// - /// Reads all available entities. - /// - /// A completion notification. - new IObservable Read(); + /// + /// Reads all available entities. + /// + /// A completion notification. + new IObservable Read(); - /// - /// Reads an entity with the specified id. - /// - /// The identifier.. - /// A completion notification. - new IObservable Read(Guid id); + /// + /// Reads an entity with the specified id. + /// + /// The identifier.. + /// A completion notification. + new IObservable Read(Guid id); - /// - /// Updates the specified dto. - /// - /// The dto. - /// A completion notification. - IObservable Update(T dto); + /// + /// Updates the specified dto. + /// + /// The dto. + /// A completion notification. + IObservable Update(T dto); - /// - /// Deletes the specified dto. - /// - /// The dto. - /// A completion notification. - IObservable Delete(T dto); - } + /// + /// Deletes the specified dto. + /// + /// The dto. + /// A completion notification. + IObservable Delete(T dto); +} +/// +/// Interface representing a non typed data service. +/// +public interface IDataService +{ /// - /// Interface representing a non typed data service. + /// Creates a new dto. /// - public interface IDataService - { - /// - /// Creates a new dto. - /// - /// The dto. - /// A completion notification. - IObservable Create(object dto); + /// The dto. + /// A completion notification. + IObservable Create(object dto); - /// - /// Reads all available dto's. - /// - /// A completion notification. - IObservable Read(); + /// + /// Reads all available dto's. + /// + /// A completion notification. + IObservable Read(); - /// - /// Reads an entity with the specified id. - /// - /// The identifier.. - /// A completion notification. - IObservable Read(Guid id); + /// + /// Reads an entity with the specified id. + /// + /// The identifier.. + /// A completion notification. + IObservable Read(Guid id); - /// - /// Updates the specified dto. - /// - /// The dto. - /// A completion notification. - IObservable Update(object dto); + /// + /// Updates the specified dto. + /// + /// The dto. + /// A completion notification. + IObservable Update(object dto); - /// - /// Deletes the specified dto. - /// - /// The dto. - /// A completion notification. - IObservable Delete(object dto); + /// + /// Deletes the specified dto. + /// + /// The dto. + /// A completion notification. + IObservable Delete(object dto); - /// - /// Deletes the dto with the specified identifier. - /// - /// The identifier. - /// A completion notification. - IObservable Delete(Guid id); - } + /// + /// Deletes the dto with the specified identifier. + /// + /// The identifier. + /// A completion notification. + IObservable Delete(Guid id); } \ No newline at end of file diff --git a/src/Data/Data/IDto.cs b/src/Data/Data/IDto.cs index 7c4684411..ecb650a52 100644 --- a/src/Data/Data/IDto.cs +++ b/src/Data/Data/IDto.cs @@ -1,11 +1,10 @@ using System; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface representing a data transfer object. +/// +public interface IDto : IHaveIdentifier { - /// - /// Interface representing a data transfer object. - /// - public interface IDto : IHaveIdentifier - { - } } \ No newline at end of file diff --git a/src/Data/Data/IHaveIdentifier.cs b/src/Data/Data/IHaveIdentifier.cs index 92b9338c3..9aaee42df 100644 --- a/src/Data/Data/IHaveIdentifier.cs +++ b/src/Data/Data/IHaveIdentifier.cs @@ -1,14 +1,13 @@ -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface representing an entity with an identifier. +/// +/// The identifier type. +public interface IHaveIdentifier { /// - /// Interface representing an entity with an identifier. + /// Gets or sets the unique identifier. /// - /// The identifier type. - public interface IHaveIdentifier - { - /// - /// Gets or sets the unique identifier. - /// - T Id { get; set; } - } + T Id { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/DuckDuckGoFunctions.cs b/src/Data/DuckDuckGo/DuckDuckGoFunctions.cs index 234743501..58f3dff4c 100644 --- a/src/Data/DuckDuckGo/DuckDuckGoFunctions.cs +++ b/src/Data/DuckDuckGo/DuckDuckGoFunctions.cs @@ -4,51 +4,50 @@ using System.Reactive.Linq; using DynamicData; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// functions. +/// +public static class DuckDuckGoFunctions { /// - /// functions. + /// Converts a to an enumerable of . /// - public static class DuckDuckGoFunctions - { - /// - /// Converts a to an enumerable of . - /// - /// The search result. - /// The enumeration of quest results. - public static IEnumerable AsResult(this SearchResult searchResult) - => searchResult.RelatedTopics.Where(x => !string.IsNullOrEmpty(x.FirstUrl)); + /// The search result. + /// The enumeration of quest results. + public static IEnumerable AsResult(this SearchResult searchResult) + => searchResult.RelatedTopics.Where(x => !string.IsNullOrEmpty(x.FirstUrl)); - /// - /// Caches the list of . - /// - /// The result. - /// The cache. - /// A value determining whether to clear the cache. - /// A completion notification. - public static IObservable> Cache( - this IObservable> result, - SourceCache cache, - bool clearCache) => result - .Do(UpdateCache(cache, clearCache)) - .Select(_ => cache.Connect().RefCount()) - .Switch(); + /// + /// Caches the list of . + /// + /// The result. + /// The cache. + /// A value determining whether to clear the cache. + /// A completion notification. + public static IObservable> Cache( + this IObservable> result, + SourceCache cache, + bool clearCache) => result + .Do(UpdateCache(cache, clearCache)) + .Select(_ => cache.Connect().RefCount()) + .Switch(); - private static Action> UpdateCache(ISourceCache cache, bool clearCache) => duckDuckGoQueryResults => + private static Action> UpdateCache(ISourceCache cache, bool clearCache) => duckDuckGoQueryResults => + { + if (clearCache) + { + cache + .Edit(updater => + { + updater.Clear(); + updater.AddOrUpdate(duckDuckGoQueryResults); + }); + } + else { - if (clearCache) - { - cache - .Edit(updater => - { - updater.Clear(); - updater.AddOrUpdate(duckDuckGoQueryResults); - }); - } - else - { - cache.EditDiff(duckDuckGoQueryResults, (first, second) => first.FirstUrl == second.FirstUrl); - } - }; - } + cache.EditDiff(duckDuckGoQueryResults, (first, second) => first.FirstUrl == second.FirstUrl); + } + }; } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/DuckDuckGoService.cs b/src/Data/DuckDuckGo/DuckDuckGoService.cs index f77fd6596..38a143d77 100644 --- a/src/Data/DuckDuckGo/DuckDuckGoService.cs +++ b/src/Data/DuckDuckGo/DuckDuckGoService.cs @@ -3,68 +3,67 @@ using System.Reactive.Linq; using DynamicData; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents a service that can query the duck duck go api. +/// +[SuppressMessage("Roslynator", "RCS1243:Duplicate word in a comment.", Justification = "Duck Duck Go")] +public class DuckDuckGoService : IDuckDuckGoService, IDisposable { - /// - /// Represents a service that can query the duck duck go api. - /// - [SuppressMessage("Roslynator", "RCS1243:Duplicate word in a comment.", Justification = "Duck Duck Go")] - public class DuckDuckGoService : IDuckDuckGoService, IDisposable - { - private readonly IDuckDuckGoApiClient _duckDuckGoApiClient; + private readonly IDuckDuckGoApiClient _duckDuckGoApiClient; - private readonly SourceCache _queryResults = - new SourceCache(x => x.FirstUrl); + private readonly SourceCache _queryResults = + new SourceCache(x => x.FirstUrl); - private readonly Func> _queryException = - _ => Observable.Empty(); + private readonly Func> _queryException = + _ => Observable.Empty(); - /// - /// Initializes a new instance of the class. - /// - /// The duck duck go api. - public DuckDuckGoService(IDuckDuckGoApiClient duckDuckGoApiClient) => - _duckDuckGoApiClient = duckDuckGoApiClient; + /// + /// Initializes a new instance of the class. + /// + /// The duck duck go api. + public DuckDuckGoService(IDuckDuckGoApiClient duckDuckGoApiClient) => + _duckDuckGoApiClient = duckDuckGoApiClient; - /// - public IObservable> Query(string query) => Observable - .Create>( - observer => - _duckDuckGoApiClient - .Search(query) - .Catch(_queryException) - .Select(x => x.AsResult()) - .Cache(_queryResults, false) - .Subscribe(observer)); + /// + public IObservable> Query(string query) => Observable + .Create>( + observer => + _duckDuckGoApiClient + .Search(query) + .Catch(_queryException) + .Select(x => x.AsResult()) + .Cache(_queryResults, false) + .Subscribe(observer)); - /// - public IObservable> Query(string query, bool clearCache) => Observable - .Create>( - observer => - _duckDuckGoApiClient - .Search(query) - .Catch(_queryException) - .Select(x => x.AsResult()) - .Cache(_queryResults, clearCache) - .Subscribe(observer)); + /// + public IObservable> Query(string query, bool clearCache) => Observable + .Create>( + observer => + _duckDuckGoApiClient + .Search(query) + .Catch(_queryException) + .Select(x => x.AsResult()) + .Cache(_queryResults, clearCache) + .Subscribe(observer)); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Dispose of internal resources. - /// - /// A value indicating whether this instance is being disposed. - protected virtual void Dispose(bool disposing) + /// + /// Dispose of internal resources. + /// + /// A value indicating whether this instance is being disposed. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - _queryResults.Dispose(); - } + _queryResults.Dispose(); } } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/IDuckDuckGoApiClient.cs b/src/Data/DuckDuckGo/IDuckDuckGoApiClient.cs index 21fe37b1e..d2a12e0ce 100644 --- a/src/Data/DuckDuckGo/IDuckDuckGoApiClient.cs +++ b/src/Data/DuckDuckGo/IDuckDuckGoApiClient.cs @@ -4,31 +4,30 @@ using System.Threading.Tasks; using Refit; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Interface that defines a duck duck go api. +/// +/// https://api.duckduckgo.com +[SuppressMessage("Roslynator", "RCS1243:Duplicate word in a comment.", Justification = "Duck Duck Go")] +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "Url")] +public interface IDuckDuckGoApiClient { /// - /// Interface that defines a duck duck go api. + /// Search the duck duck go api with the provided query. /// - /// https://api.duckduckgo.com - [SuppressMessage("Roslynator", "RCS1243:Duplicate word in a comment.", Justification = "Duck Duck Go")] - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "Url")] - public interface IDuckDuckGoApiClient - { - /// - /// Search the duck duck go api with the provided query. - /// - /// The query. - /// A representing the result of the asynchronous operation. - [Get("/?q={query}&format=json")] - IObservable Search(string query); + /// The query. + /// A representing the result of the asynchronous operation. + [Get("/?q={query}&format=json")] + IObservable Search(string query); - /// - /// Search the duck duck go api with the provided query. - /// - /// The query. - /// The cancellation token. - /// A representing the result of the asynchronous operation. - [Get("/?q={query}&format=json")] - IObservable Search(string query, CancellationToken cancellationToken); - } + /// + /// Search the duck duck go api with the provided query. + /// + /// The query. + /// The cancellation token. + /// A representing the result of the asynchronous operation. + [Get("/?q={query}&format=json")] + IObservable Search(string query, CancellationToken cancellationToken); } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/IDuckDuckGoService.cs b/src/Data/DuckDuckGo/IDuckDuckGoService.cs index ec77f71c9..5c076c7a8 100644 --- a/src/Data/DuckDuckGo/IDuckDuckGoService.cs +++ b/src/Data/DuckDuckGo/IDuckDuckGoService.cs @@ -2,27 +2,26 @@ using System.Diagnostics.CodeAnalysis; using DynamicData; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Interface representing a service that queries the . +/// +[SuppressMessage("Roslynator", "RCS1243:Duplicate word in a comment.", Justification = "Duck Duck Go")] +public interface IDuckDuckGoService { /// - /// Interface representing a service that queries the . + /// Queries duck duck go. /// - [SuppressMessage("Roslynator", "RCS1243:Duplicate word in a comment.", Justification = "Duck Duck Go")] - public interface IDuckDuckGoService - { - /// - /// Queries duck duck go. - /// - /// The query. - /// An observable of chang sets. - IObservable> Query(string query); + /// The query. + /// An observable of chang sets. + IObservable> Query(string query); - /// - /// Queries duck duck go. - /// - /// The query. - /// A value indicating whether to clear the cache. - /// An observable of chang sets. - IObservable> Query(string query, bool clearCache); - } + /// + /// Queries duck duck go. + /// + /// The query. + /// A value indicating whether to clear the cache. + /// An observable of chang sets. + IObservable> Query(string query, bool clearCache); } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/Developer.cs b/src/Data/DuckDuckGo/Models/Developer.cs index 3442939b4..d6cd13c1d 100644 --- a/src/Data/DuckDuckGo/Models/Developer.cs +++ b/src/Data/DuckDuckGo/Models/Developer.cs @@ -1,23 +1,22 @@ -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents developer metadata. +/// +public class Developer { /// - /// Represents developer metadata. + /// Gets or sets the name. /// - public class Developer - { - /// - /// Gets or sets the name. - /// - public string Name { get; set; } + public string Name { get; set; } - /// - /// Gets or sets the type. - /// - public string Type { get; set; } + /// + /// Gets or sets the type. + /// + public string Type { get; set; } - /// - /// Gets or sets the url. - /// - public string Url { get; set; } - } + /// + /// Gets or sets the url. + /// + public string Url { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/Icon.cs b/src/Data/DuckDuckGo/Models/Icon.cs index cadab1d5f..366352167 100644 --- a/src/Data/DuckDuckGo/Models/Icon.cs +++ b/src/Data/DuckDuckGo/Models/Icon.cs @@ -1,23 +1,22 @@ -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents an icon. +/// +public class Icon { /// - /// Represents an icon. + /// Gets or sets the height. /// - public class Icon - { - /// - /// Gets or sets the height. - /// - public string Height { get; set; } + public string Height { get; set; } - /// - /// Gets or sets the url. - /// - public string URL { get; set; } + /// + /// Gets or sets the url. + /// + public string URL { get; set; } - /// - /// Gets or sets the width. - /// - public string Width { get; set; } - } + /// + /// Gets or sets the width. + /// + public string Width { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/Maintainer.cs b/src/Data/DuckDuckGo/Models/Maintainer.cs index 3ecf843f5..256094e7a 100644 --- a/src/Data/DuckDuckGo/Models/Maintainer.cs +++ b/src/Data/DuckDuckGo/Models/Maintainer.cs @@ -1,13 +1,12 @@ -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents maintainer metadata. +/// +public class Maintainer { /// - /// Represents maintainer metadata. + /// Gets or sets the github url. /// - public class Maintainer - { - /// - /// Gets or sets the github url. - /// - public string Github { get; set; } - } + public string Github { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/Meta.cs b/src/Data/DuckDuckGo/Models/Meta.cs index 3df3c6027..40aaeef91 100644 --- a/src/Data/DuckDuckGo/Models/Meta.cs +++ b/src/Data/DuckDuckGo/Models/Meta.cs @@ -1,155 +1,154 @@ using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents meta data. +/// +public class Meta { /// - /// Represents meta data. - /// - public class Meta - { - /// - /// Gets or sets the attribution. - /// - public object Attribution { get; set; } - - /// - /// Gets or sets the block group. - /// - public object Blockgroup { get; set; } - - /// - /// Gets or sets the created date. - /// - public object CreatedDate { get; set; } - - /// - /// Gets or sets the description. - /// - public string Description { get; set; } - - /// - /// Gets or sets the designer. - /// - public object Designer { get; set; } - - /// - /// Gets or sets the dev date. - /// - public object DevDate { get; set; } - - /// - /// Gets or sets the dev milestone. - /// - public string DevMilestone { get; set; } - - /// - /// Gets or sets the attribution developer. - /// - public IEnumerable Developer { get; set; } - - /// - /// Gets or sets the example query. - /// - public string ExampleQuery { get; set; } - - /// - /// Gets or sets the id. - /// - public string Id { get; set; } - - /// - /// Gets or sets the is stack exchange. - /// - public object IsStackexchange { get; set; } - - /// - /// Gets or sets the java script call back name. - /// - public string JsCallbackName { get; set; } - - /// - /// Gets or sets the live date. - /// - public object LiveDate { get; set; } - - /// - /// Gets or sets the maintainer. - /// - public Maintainer Maintainer { get; set; } - - /// - /// Gets or sets the name. - /// - public string Name { get; set; } - - /// - /// Gets or sets the perl module. - /// - public string PerlModule { get; set; } - - /// - /// Gets or sets the producer. - /// - public object Producer { get; set; } - - /// - /// Gets or sets the production state. - /// - public string ProductionState { get; set; } - - /// - /// Gets or sets the repo. - /// - public string Repo { get; set; } - - /// - /// Gets or sets the signal from. - /// - public string SignalFrom { get; set; } - - /// - /// Gets or sets the source domain. - /// - public string SrcDomain { get; set; } - - /// - /// Gets or sets the source id. - /// - public int SrcId { get; set; } - - /// - /// Gets or sets the source name. - /// - public string SrcName { get; set; } - - /// - /// Gets or sets the source options. - /// - public SrcOptions SrcOptions { get; set; } - - /// - /// Gets or sets the source url. - /// - public string SrcUrl { get; set; } - - /// - /// Gets or sets the status. - /// - public string Status { get; set; } - - /// - /// Gets or sets the tab. - /// - public string Tab { get; set; } - - /// - /// Gets or sets the topic. - /// - public IEnumerable Topic { get; set; } - - /// - /// Gets or sets the attribution. - /// - public int Unsafe { get; set; } - } + /// Gets or sets the attribution. + /// + public object Attribution { get; set; } + + /// + /// Gets or sets the block group. + /// + public object Blockgroup { get; set; } + + /// + /// Gets or sets the created date. + /// + public object CreatedDate { get; set; } + + /// + /// Gets or sets the description. + /// + public string Description { get; set; } + + /// + /// Gets or sets the designer. + /// + public object Designer { get; set; } + + /// + /// Gets or sets the dev date. + /// + public object DevDate { get; set; } + + /// + /// Gets or sets the dev milestone. + /// + public string DevMilestone { get; set; } + + /// + /// Gets or sets the attribution developer. + /// + public IEnumerable Developer { get; set; } + + /// + /// Gets or sets the example query. + /// + public string ExampleQuery { get; set; } + + /// + /// Gets or sets the id. + /// + public string Id { get; set; } + + /// + /// Gets or sets the is stack exchange. + /// + public object IsStackexchange { get; set; } + + /// + /// Gets or sets the java script call back name. + /// + public string JsCallbackName { get; set; } + + /// + /// Gets or sets the live date. + /// + public object LiveDate { get; set; } + + /// + /// Gets or sets the maintainer. + /// + public Maintainer Maintainer { get; set; } + + /// + /// Gets or sets the name. + /// + public string Name { get; set; } + + /// + /// Gets or sets the perl module. + /// + public string PerlModule { get; set; } + + /// + /// Gets or sets the producer. + /// + public object Producer { get; set; } + + /// + /// Gets or sets the production state. + /// + public string ProductionState { get; set; } + + /// + /// Gets or sets the repo. + /// + public string Repo { get; set; } + + /// + /// Gets or sets the signal from. + /// + public string SignalFrom { get; set; } + + /// + /// Gets or sets the source domain. + /// + public string SrcDomain { get; set; } + + /// + /// Gets or sets the source id. + /// + public int SrcId { get; set; } + + /// + /// Gets or sets the source name. + /// + public string SrcName { get; set; } + + /// + /// Gets or sets the source options. + /// + public SrcOptions SrcOptions { get; set; } + + /// + /// Gets or sets the source url. + /// + public string SrcUrl { get; set; } + + /// + /// Gets or sets the status. + /// + public string Status { get; set; } + + /// + /// Gets or sets the tab. + /// + public string Tab { get; set; } + + /// + /// Gets or sets the topic. + /// + public IEnumerable Topic { get; set; } + + /// + /// Gets or sets the attribution. + /// + public int Unsafe { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/RelatedTopic.cs b/src/Data/DuckDuckGo/Models/RelatedTopic.cs index 3eed5e0eb..8ce6239d8 100644 --- a/src/Data/DuckDuckGo/Models/RelatedTopic.cs +++ b/src/Data/DuckDuckGo/Models/RelatedTopic.cs @@ -1,40 +1,39 @@ using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents related topics. +/// +public class RelatedTopic { /// - /// Represents related topics. + /// Gets or sets the first url. /// - public class RelatedTopic - { - /// - /// Gets or sets the first url. - /// - public string FirstUrl { get; set; } + public string FirstUrl { get; set; } - /// - /// Gets or sets the icon. - /// - public Icon Icon { get; set; } + /// + /// Gets or sets the icon. + /// + public Icon Icon { get; set; } - /// - /// Gets or sets the icon. - /// - public string Result { get; set; } + /// + /// Gets or sets the icon. + /// + public string Result { get; set; } - /// - /// Gets or sets the icon. - /// - public string Text { get; set; } + /// + /// Gets or sets the icon. + /// + public string Text { get; set; } - /// - /// Gets or sets the icon. - /// - public string Name { get; set; } + /// + /// Gets or sets the icon. + /// + public string Name { get; set; } - /// - /// Gets or sets the icon. - /// - public IEnumerable Topics { get; set; } - } + /// + /// Gets or sets the icon. + /// + public IEnumerable Topics { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/SearchResult.cs b/src/Data/DuckDuckGo/Models/SearchResult.cs index 59932f537..c6fdb2fc5 100644 --- a/src/Data/DuckDuckGo/Models/SearchResult.cs +++ b/src/Data/DuckDuckGo/Models/SearchResult.cs @@ -1,90 +1,89 @@ using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Search results from query. +/// +public class SearchResult { /// - /// Search results from query. - /// - public class SearchResult - { - /// - /// Gets or sets topic summary containing HTML. - /// - public string Abstract { get; set; } - - /// - /// Gets or sets topic summary containing no HTML. - /// - public string AbstractText { get; set; } - - /// - /// Gets or sets type of Answer, e.g. calc, color, digest, info, ip, iploc, phone, pw, rand, regexp, unicode, upc, or zip (see goodies & tech pages for examples). - /// - public string AnswerType { get; set; } - - /// - /// Gets or sets name of Abstract Source. - /// - public string AbstractSource { get; set; } - - /// - /// Gets or sets dictionary definition (may differ from Abstract). - /// - public string Definition { get; set; } - - /// - /// Gets or sets name of Definition source. - /// - public string DefinitionSource { get; set; } - - /// - /// Gets or sets name of topic that goes with Abstract. - /// - public string Heading { get; set; } - - /// - /// Gets or sets link to image that goes with Abstract. - /// - public string Image { get; set; } - - /// - /// Gets or sets array of internal links to related topics associated with Abstract. - /// - public IEnumerable RelatedTopics { get; set; } - - /// - /// Gets or sets response category, i.e. A (article), D (disambiguation), C (category), N (name), E (exclusive), or nothing. - /// - public string Type { get; set; } - - /// - /// Gets or sets !bang redirect URL. - /// - public string Redirect { get; set; } - - /// - /// Gets or sets deep link to expanded definition page in DefinitionSource. - /// - public string DefinitionUrl { get; set; } - - /// - /// Gets or sets instant answer. - /// - public string Answer { get; set; } - - /// - /// Gets or sets array of external links associated with Abstract. - /// - public IEnumerable Results { get; set; } - - /// - /// Gets or sets deep link to the expanded topic page in AbstractSource. - /// - public string AbstractUrl { get; set; } - - /// - /// Gets or sets the meta data. - /// - public Meta Meta { get; set; } - } + /// Gets or sets topic summary containing HTML. + /// + public string Abstract { get; set; } + + /// + /// Gets or sets topic summary containing no HTML. + /// + public string AbstractText { get; set; } + + /// + /// Gets or sets type of Answer, e.g. calc, color, digest, info, ip, iploc, phone, pw, rand, regexp, unicode, upc, or zip (see goodies & tech pages for examples). + /// + public string AnswerType { get; set; } + + /// + /// Gets or sets name of Abstract Source. + /// + public string AbstractSource { get; set; } + + /// + /// Gets or sets dictionary definition (may differ from Abstract). + /// + public string Definition { get; set; } + + /// + /// Gets or sets name of Definition source. + /// + public string DefinitionSource { get; set; } + + /// + /// Gets or sets name of topic that goes with Abstract. + /// + public string Heading { get; set; } + + /// + /// Gets or sets link to image that goes with Abstract. + /// + public string Image { get; set; } + + /// + /// Gets or sets array of internal links to related topics associated with Abstract. + /// + public IEnumerable RelatedTopics { get; set; } + + /// + /// Gets or sets response category, i.e. A (article), D (disambiguation), C (category), N (name), E (exclusive), or nothing. + /// + public string Type { get; set; } + + /// + /// Gets or sets !bang redirect URL. + /// + public string Redirect { get; set; } + + /// + /// Gets or sets deep link to expanded definition page in DefinitionSource. + /// + public string DefinitionUrl { get; set; } + + /// + /// Gets or sets instant answer. + /// + public string Answer { get; set; } + + /// + /// Gets or sets array of external links associated with Abstract. + /// + public IEnumerable Results { get; set; } + + /// + /// Gets or sets deep link to the expanded topic page in AbstractSource. + /// + public string AbstractUrl { get; set; } + + /// + /// Gets or sets the meta data. + /// + public Meta Meta { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/SrcOptions.cs b/src/Data/DuckDuckGo/Models/SrcOptions.cs index ac5f642e0..74bf992b9 100644 --- a/src/Data/DuckDuckGo/Models/SrcOptions.cs +++ b/src/Data/DuckDuckGo/Models/SrcOptions.cs @@ -1,78 +1,77 @@ -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents source options. +/// +public class SrcOptions { /// - /// Represents source options. + /// Gets or sets the height. /// - public class SrcOptions - { - /// - /// Gets or sets the height. - /// - public string Directory { get; set; } + public string Directory { get; set; } - /// - /// Gets or sets the height. - /// - public int IsFanon { get; set; } + /// + /// Gets or sets the height. + /// + public int IsFanon { get; set; } - /// - /// Gets or sets the height. - /// - public int IsMediawiki { get; set; } + /// + /// Gets or sets the height. + /// + public int IsMediawiki { get; set; } - /// - /// Gets or sets the height. - /// - public int IsWikipedia { get; set; } + /// + /// Gets or sets the height. + /// + public int IsWikipedia { get; set; } - /// - /// Gets or sets the height. - /// - public string Language { get; set; } + /// + /// Gets or sets the height. + /// + public string Language { get; set; } - /// - /// Gets or sets the height. - /// - public string MinAbstractLength { get; set; } + /// + /// Gets or sets the height. + /// + public string MinAbstractLength { get; set; } - /// - /// Gets or sets the height. - /// - public int SkipAbstract { get; set; } + /// + /// Gets or sets the height. + /// + public int SkipAbstract { get; set; } - /// - /// Gets or sets the height. - /// - public int SkipAbstractParen { get; set; } + /// + /// Gets or sets the height. + /// + public int SkipAbstractParen { get; set; } - /// - /// Gets or sets the height. - /// - public string SkipEnd { get; set; } + /// + /// Gets or sets the height. + /// + public string SkipEnd { get; set; } - /// - /// Gets or sets the height. - /// - public int SkipIcon { get; set; } + /// + /// Gets or sets the height. + /// + public int SkipIcon { get; set; } - /// - /// Gets or sets the height. - /// - public int SkipImageName { get; set; } + /// + /// Gets or sets the height. + /// + public int SkipImageName { get; set; } - /// - /// Gets or sets the height. - /// - public string SkipQr { get; set; } + /// + /// Gets or sets the height. + /// + public string SkipQr { get; set; } - /// - /// Gets or sets the height. - /// - public string SourceSkip { get; set; } + /// + /// Gets or sets the height. + /// + public string SourceSkip { get; set; } - /// - /// Gets or sets the height. - /// - public string SrcInfo { get; set; } - } + /// + /// Gets or sets the height. + /// + public string SrcInfo { get; set; } } \ No newline at end of file diff --git a/src/Data/DuckDuckGo/Models/Topic.cs b/src/Data/DuckDuckGo/Models/Topic.cs index f753eac5d..89de540a4 100644 --- a/src/Data/DuckDuckGo/Models/Topic.cs +++ b/src/Data/DuckDuckGo/Models/Topic.cs @@ -1,28 +1,27 @@ -namespace Rocket.Surgery.Airframe.Data.DuckDuckGo +namespace Rocket.Surgery.Airframe.Data.DuckDuckGo; + +/// +/// Represents a topic. +/// +public class Topic { /// - /// Represents a topic. + /// Gets or sets the first url. /// - public class Topic - { - /// - /// Gets or sets the first url. - /// - public string FirstUrl { get; set; } + public string FirstUrl { get; set; } - /// - /// Gets or sets the icon. - /// - public Icon Icon { get; set; } + /// + /// Gets or sets the icon. + /// + public Icon Icon { get; set; } - /// - /// Gets or sets the result. - /// - public string Result { get; set; } + /// + /// Gets or sets the result. + /// + public string Result { get; set; } - /// - /// Gets or sets the text. - /// - public string Text { get; set; } - } + /// + /// Gets or sets the text. + /// + public string Text { get; set; } } \ No newline at end of file diff --git a/src/Data/Hub/HubClientBase.cs b/src/Data/Hub/HubClientBase.cs index 3abb5d4c8..56e800ecc 100644 --- a/src/Data/Hub/HubClientBase.cs +++ b/src/Data/Hub/HubClientBase.cs @@ -1,35 +1,34 @@ using System; using System.Threading.Tasks; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Base abstraction for hub clients. +/// +public abstract class HubClientBase : IHubClient { - /// - /// Base abstraction for hub clients. - /// - public abstract class HubClientBase : IHubClient - { - /// - public abstract Task Connect(); + /// + public abstract Task Connect(); - /// - public abstract Task InvokeAsync(string methodName); + /// + public abstract Task InvokeAsync(string methodName); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposes of resources. - /// - /// A value indicating disposal. - protected virtual void Dispose(bool disposing) + /// + /// Disposes of resources. + /// + /// A value indicating disposal. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - } } } } \ No newline at end of file diff --git a/src/Data/Hub/IHubClient.cs b/src/Data/Hub/IHubClient.cs index e361b7f09..a06a5b7e9 100644 --- a/src/Data/Hub/IHubClient.cs +++ b/src/Data/Hub/IHubClient.cs @@ -1,25 +1,24 @@ using System; using System.Threading.Tasks; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface representing a hub client. +/// +public interface IHubClient : IDisposable { /// - /// Interface representing a hub client. + /// Connect to the Hub. /// - public interface IHubClient : IDisposable - { - /// - /// Connect to the Hub. - /// - /// A task to monitor the progress. - Task Connect(); + /// A task to monitor the progress. + Task Connect(); - /// - /// Invokes a method with the provided name. - /// - /// The method name. - /// The return type. - /// A completion value. - Task InvokeAsync(string methodName); - } + /// + /// Invokes a method with the provided name. + /// + /// The method name. + /// The return type. + /// A completion value. + Task InvokeAsync(string methodName); } \ No newline at end of file diff --git a/src/Data/Jokes/ChuckNorris/ChuckNorrisJoke.cs b/src/Data/Jokes/ChuckNorris/ChuckNorrisJoke.cs index 8b6174375..55ac5cb44 100644 --- a/src/Data/Jokes/ChuckNorris/ChuckNorrisJoke.cs +++ b/src/Data/Jokes/ChuckNorris/ChuckNorrisJoke.cs @@ -2,53 +2,52 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Represents a joke from https://api.chucknorris.io/. +/// +public class ChuckNorrisJoke : IHaveIdentifier { /// - /// Represents a joke from https://api.chucknorris.io/. + /// Gets or sets the id. + /// + [JsonProperty("id")] + public string Id { get; set; } + + /// + /// Gets or sets the icon url. + /// + [JsonProperty("icon_url")] + public Uri IconUrl { get; set; } + + /// + /// Gets or sets the url. + /// + [JsonProperty("url")] + public Uri Url { get; set; } + + /// + /// Gets or sets the value. + /// + [JsonProperty("value")] + public string Value { get; set; } + + /// + /// Gets or sets the categories. + /// + [JsonProperty("categories")] + public IEnumerable Categories { get; set; } + + /// + /// Gets or sets the date of creation. + /// + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + /// + /// Gets or sets the last updated date. /// - public class ChuckNorrisJoke : IHaveIdentifier - { - /// - /// Gets or sets the id. - /// - [JsonProperty("id")] - public string Id { get; set; } - - /// - /// Gets or sets the icon url. - /// - [JsonProperty("icon_url")] - public Uri IconUrl { get; set; } - - /// - /// Gets or sets the url. - /// - [JsonProperty("url")] - public Uri Url { get; set; } - - /// - /// Gets or sets the value. - /// - [JsonProperty("value")] - public string Value { get; set; } - - /// - /// Gets or sets the categories. - /// - [JsonProperty("categories")] - public IEnumerable Categories { get; set; } - - /// - /// Gets or sets the date of creation. - /// - [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } - - /// - /// Gets or sets the last updated date. - /// - [JsonProperty("updated_at")] - public DateTimeOffset UpdatedAt { get; set; } - } + [JsonProperty("updated_at")] + public DateTimeOffset UpdatedAt { get; set; } } \ No newline at end of file diff --git a/src/Data/Jokes/ChuckNorris/ChuckNorrisJokeService.cs b/src/Data/Jokes/ChuckNorris/ChuckNorrisJokeService.cs index 08d21934c..44e21db05 100644 --- a/src/Data/Jokes/ChuckNorris/ChuckNorrisJokeService.cs +++ b/src/Data/Jokes/ChuckNorris/ChuckNorrisJokeService.cs @@ -3,59 +3,58 @@ using System.Reactive.Linq; using DynamicData; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Represents a service that produces . +/// +public class ChuckNorrisJokeService : IChuckNorrisJokeService { + private readonly IChuckNorrisJokeApiClient _chuckNorrisJokeApiClient; + private readonly SourceCache _jokes = new SourceCache(x => x.Id); + /// - /// Represents a service that produces . + /// Initializes a new instance of the class. /// - public class ChuckNorrisJokeService : IChuckNorrisJokeService - { - private readonly IChuckNorrisJokeApiClient _chuckNorrisJokeApiClient; - private readonly SourceCache _jokes = new SourceCache(x => x.Id); - - /// - /// Initializes a new instance of the class. - /// - /// The api client. - public ChuckNorrisJokeService(IChuckNorrisJokeApiClient chuckNorrisJokeApiClient) => _chuckNorrisJokeApiClient = chuckNorrisJokeApiClient; - - /// - public IObservable Random() => Observable - .Create(observer => + /// The api client. + public ChuckNorrisJokeService(IChuckNorrisJokeApiClient chuckNorrisJokeApiClient) => _chuckNorrisJokeApiClient = chuckNorrisJokeApiClient; + + /// + public IObservable Random() => Observable + .Create(observer => + _chuckNorrisJokeApiClient + .Random() + .Cache(_jokes) + .Subscribe(observer)); + + /// + public IObservable Random(params string[] categories) => Observable.Create( + observer => + { + var disposable = new CompositeDisposable(); + + foreach (var category in categories) + { _chuckNorrisJokeApiClient - .Random() + .RandomFromCategory(category) + .SelectMany(jokes => jokes) .Cache(_jokes) - .Subscribe(observer)); + .Subscribe(observer) + .DisposeWith(disposable); + } + + return disposable; + }); - /// - public IObservable Random(params string[] categories) => Observable.Create( + /// + public IObservable> Query(string query) => Query(query, true); + + /// + public IObservable> Query(string query, bool clearCache) => Observable + .Create>( observer => - { - var disposable = new CompositeDisposable(); - - foreach (var category in categories) - { - _chuckNorrisJokeApiClient - .RandomFromCategory(category) - .SelectMany(jokes => jokes) - .Cache(_jokes) - .Subscribe(observer) - .DisposeWith(disposable); - } - - return disposable; - }); - - /// - public IObservable> Query(string query) => Query(query, true); - - /// - public IObservable> Query(string query, bool clearCache) => Observable - .Create>( - observer => - _chuckNorrisJokeApiClient - .Search(query) - .Cache(_jokes, clearCache) - .Subscribe(observer)); - } + _chuckNorrisJokeApiClient + .Search(query) + .Cache(_jokes, clearCache) + .Subscribe(observer)); } \ No newline at end of file diff --git a/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeApiClient.cs b/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeApiClient.cs index b3883b09d..a8be0a7b7 100644 --- a/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeApiClient.cs +++ b/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeApiClient.cs @@ -3,43 +3,42 @@ using System.Diagnostics.CodeAnalysis; using Refit; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface that defines an api client for https://api.chucknorris.io/. +/// +/// https://api.chucknorris.io +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "Url")] +public interface IChuckNorrisJokeApiClient { /// - /// Interface that defines an api client for https://api.chucknorris.io/. + /// Gets a random . /// - /// https://api.chucknorris.io - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "Url")] - public interface IChuckNorrisJokeApiClient - { - /// - /// Gets a random . - /// - /// An representing the result of the asynchronous operation. - [Get("/jokes/random")] - IObservable Random(); + /// An representing the result of the asynchronous operation. + [Get("/jokes/random")] + IObservable Random(); - /// - /// Gets a random . - /// - /// The category. - /// An representing the result of the asynchronous operation. - [Get("/jokes/random?category={category}")] - IObservable> RandomFromCategory(string category); + /// + /// Gets a random . + /// + /// The category. + /// An representing the result of the asynchronous operation. + [Get("/jokes/random?category={category}")] + IObservable> RandomFromCategory(string category); - /// - /// Gets a random . - /// - /// An representing the result of the asynchronous operation. - [Get("/jokes/categories")] - IObservable> Categories(); + /// + /// Gets a random . + /// + /// An representing the result of the asynchronous operation. + [Get("/jokes/categories")] + IObservable> Categories(); - /// - /// Gets a random . - /// - /// The query. - /// An representing the result of the asynchronous operation. - [Get("/jokes/search?query={query}")] - IObservable> Search(string query); - } + /// + /// Gets a random . + /// + /// The query. + /// An representing the result of the asynchronous operation. + [Get("/jokes/search?query={query}")] + IObservable> Search(string query); } \ No newline at end of file diff --git a/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeService.cs b/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeService.cs index 14a485040..d680763f5 100644 --- a/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeService.cs +++ b/src/Data/Jokes/ChuckNorris/IChuckNorrisJokeService.cs @@ -1,39 +1,38 @@ using System; using DynamicData; -namespace Rocket.Surgery.Airframe.Data +namespace Rocket.Surgery.Airframe.Data; + +/// +/// Interface representing a service. +/// +public interface IChuckNorrisJokeService { /// - /// Interface representing a service. + /// Gets a random chuck norris joke. /// - public interface IChuckNorrisJokeService - { - /// - /// Gets a random chuck norris joke. - /// - /// An observable of chang sets. - IObservable Random(); + /// An observable of chang sets. + IObservable Random(); - /// - /// Gets a random chuck norris joke from the provided categories. - /// - /// The categories. - /// An observable of chang sets. - IObservable Random(params string[] categories); + /// + /// Gets a random chuck norris joke from the provided categories. + /// + /// The categories. + /// An observable of chang sets. + IObservable Random(params string[] categories); - /// - /// Queries chuck norris jokes. - /// - /// The query. - /// An observable of chang sets. - IObservable> Query(string query); + /// + /// Queries chuck norris jokes. + /// + /// The query. + /// An observable of chang sets. + IObservable> Query(string query); - /// - /// Queries chuck norris jokes. - /// - /// The query. - /// A value indicating whether to clear the cache. - /// An observable of chang sets. - IObservable> Query(string query, bool clearCache); - } + /// + /// Queries chuck norris jokes. + /// + /// The query. + /// A value indicating whether to clear the cache. + /// An observable of chang sets. + IObservable> Query(string query, bool clearCache); } \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/ConfigurationOptions.cs b/src/MicrosoftDependencyInjection/ConfigurationOptions.cs index 56dcc8385..a5ff48e35 100644 --- a/src/MicrosoftDependencyInjection/ConfigurationOptions.cs +++ b/src/MicrosoftDependencyInjection/ConfigurationOptions.cs @@ -1,58 +1,57 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Represents a configuration options configurator. +/// +public class ConfigurationOptions { + private readonly IServiceCollection _serviceCollection; + + /// + /// Initializes a new instance of the class. + /// + /// The service collection. + public ConfigurationOptions(IServiceCollection serviceCollection) => _serviceCollection = serviceCollection; + /// - /// Represents a configuration options configurator. + /// Adds an to the container. /// - public class ConfigurationOptions + /// The operation type. + /// The option configuration. + public ConfigurationOptions ConfigureOption() + where T : class { - private readonly IServiceCollection _serviceCollection; - - /// - /// Initializes a new instance of the class. - /// - /// The service collection. - public ConfigurationOptions(IServiceCollection serviceCollection) => _serviceCollection = serviceCollection; - - /// - /// Adds an to the container. - /// - /// The operation type. - /// The option configuration. - public ConfigurationOptions ConfigureOption() - where T : class - { - _serviceCollection - .AddOptions() - .Configure((T settings, IConfiguration config) => config.Bind(settings)); - - return this; - } - - /// - /// Configure the section as . - /// - /// The section type. - /// The configuration options. - public ConfigurationOptions ConfigureSection() - where T : class => ConfigureSection(typeof(T).Name); - - /// - /// Configure the section as . - /// - /// The section. - /// The section type. - /// The configuration options. - public ConfigurationOptions ConfigureSection(string section) - where T : class - { - _serviceCollection - .AddOptions() - .Configure((T settings, IConfiguration config) => config.GetSection(section).Bind(settings)); - - return this; - } + _serviceCollection + .AddOptions() + .Configure((T settings, IConfiguration config) => config.Bind(settings)); + + return this; + } + + /// + /// Configure the section as . + /// + /// The section type. + /// The configuration options. + public ConfigurationOptions ConfigureSection() + where T : class => ConfigureSection(typeof(T).Name); + + /// + /// Configure the section as . + /// + /// The section. + /// The section type. + /// The configuration options. + public ConfigurationOptions ConfigureSection(string section) + where T : class + { + _serviceCollection + .AddOptions() + .Configure((T settings, IConfiguration config) => config.GetSection(section).Bind(settings)); + + return this; } } \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/DependencyInjectionExtensions.cs b/src/MicrosoftDependencyInjection/DependencyInjectionExtensions.cs index de1639ec1..67a340d56 100644 --- a/src/MicrosoftDependencyInjection/DependencyInjectionExtensions.cs +++ b/src/MicrosoftDependencyInjection/DependencyInjectionExtensions.cs @@ -3,206 +3,205 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Extensions for . +/// +public static class DependencyInjectionExtensions { /// - /// Extensions for . + /// Adds the to the . /// - public static class DependencyInjectionExtensions - { - /// - /// Adds the to the . - /// - /// The service collection. - /// The platform initializer. - /// The service collection with platform dependencies registered. - public static IServiceCollection AddPlatform(this IServiceCollection serviceCollection, IPlatformInitializer platformInitializer) => - platformInitializer.Initialize(serviceCollection); - - /// - /// Adds the to the . - /// - /// The service collection. - /// The target that owns the platform initializer. - /// The startup. - /// The target type. - /// The service collection with platform dependencies registered. - public static IServiceCollection AddPlatform(this IServiceCollection serviceCollection, TTarget target, Func startup) => - startup(target).Initialize(serviceCollection); - - /// - /// Registers an to the service collection. - /// - /// The service collection. - /// The startup options. - /// The startup type. - /// The service collection with startup dependencies registered. - public static IServiceCollection AddStartup(this IServiceCollection serviceCollection, Action? options = null) - where T : class, IApplicationStartup - { - serviceCollection.AddTransient(); + /// The service collection. + /// The platform initializer. + /// The service collection with platform dependencies registered. + public static IServiceCollection AddPlatform(this IServiceCollection serviceCollection, IPlatformInitializer platformInitializer) => + platformInitializer.Initialize(serviceCollection); - if (options != null) - { - var startupOption = new StartupOption(serviceCollection); - options.Invoke(startupOption); - } + /// + /// Adds the to the . + /// + /// The service collection. + /// The target that owns the platform initializer. + /// The startup. + /// The target type. + /// The service collection with platform dependencies registered. + public static IServiceCollection AddPlatform(this IServiceCollection serviceCollection, TTarget target, Func startup) => + startup(target).Initialize(serviceCollection); - return serviceCollection; - } + /// + /// Registers an to the service collection. + /// + /// The service collection. + /// The startup options. + /// The startup type. + /// The service collection with startup dependencies registered. + public static IServiceCollection AddStartup(this IServiceCollection serviceCollection, Action? options = null) + where T : class, IApplicationStartup + { + serviceCollection.AddTransient(); - /// - /// Configures the app settings for the service collection. - /// - /// The service collection. - /// The service collection with configuration dependencies registered. - public static IServiceCollection ConfigureAppSettings(this IServiceCollection serviceCollection) => - ConfigureAppSettings( - serviceCollection, - new ConfigurationBuilder()); - - /// - /// Configures the app settings for the service collection. - /// - /// The service collection. - /// The configuration builder. - /// The service collection with configuration dependencies registered. - public static IServiceCollection ConfigureAppSettings(this IServiceCollection serviceCollection, Action builder) + if (options != null) { - var configurationBuilder = new ConfigurationBuilder(); - builder.Invoke(configurationBuilder); - - return ConfigureAppSettings(serviceCollection, configurationBuilder); + var startupOption = new StartupOption(serviceCollection); + options.Invoke(startupOption); } - /// - /// Configures the app settings for the service collection. - /// - /// The service collection. - /// The configuration builder. - /// The service collection with configuration dependencies registered. - public static IServiceCollection ConfigureAppSettings(this IServiceCollection serviceCollection, IConfigurationBuilder configurationBuilder) => - ConfigureAppSettings(serviceCollection, configurationBuilder.Build()); - - /// - /// Configures the app settings for the service collection. - /// - /// The service collection. - /// The configuration. - /// The service collection with configuration dependencies registered. - public static IServiceCollection ConfigureAppSettings( - this IServiceCollection serviceCollection, - IConfiguration configuration) - { - var builder = new ConfigurationBuilder(); + return serviceCollection; + } + + /// + /// Configures the app settings for the service collection. + /// + /// The service collection. + /// The service collection with configuration dependencies registered. + public static IServiceCollection ConfigureAppSettings(this IServiceCollection serviceCollection) => + ConfigureAppSettings( + serviceCollection, + new ConfigurationBuilder()); - return serviceCollection.AddSingleton(provider => - { - provider.GetService>()?.Invoke(builder); + /// + /// Configures the app settings for the service collection. + /// + /// The service collection. + /// The configuration builder. + /// The service collection with configuration dependencies registered. + public static IServiceCollection ConfigureAppSettings(this IServiceCollection serviceCollection, Action builder) + { + var configurationBuilder = new ConfigurationBuilder(); + builder.Invoke(configurationBuilder); - return builder.AddConfiguration(configuration).Build(); - }); - } + return ConfigureAppSettings(serviceCollection, configurationBuilder); + } - /// - /// Configures the for the service collection. - /// - /// The service collection. - /// The option type. - /// The service collection with options registered. - public static IServiceCollection ConfigureSectionAsOptions(this IServiceCollection serviceCollection) - where T : class => ConfigureSectionAsOptions(serviceCollection, typeof(T).Name); - - /// - /// Configures the for the service collection. - /// - /// The service collection. - /// The app settings section. - /// The option type. - /// The service collection with options registered. - public static IServiceCollection ConfigureSectionAsOptions(this IServiceCollection serviceCollection, string section) - where T : class - { - serviceCollection - .AddOptions() - .Configure((T settings, IConfiguration config) => config.GetSection(section).Bind(settings)); + /// + /// Configures the app settings for the service collection. + /// + /// The service collection. + /// The configuration builder. + /// The service collection with configuration dependencies registered. + public static IServiceCollection ConfigureAppSettings(this IServiceCollection serviceCollection, IConfigurationBuilder configurationBuilder) => + ConfigureAppSettings(serviceCollection, configurationBuilder.Build()); - return serviceCollection; - } + /// + /// Configures the app settings for the service collection. + /// + /// The service collection. + /// The configuration. + /// The service collection with configuration dependencies registered. + public static IServiceCollection ConfigureAppSettings( + this IServiceCollection serviceCollection, + IConfiguration configuration) + { + var builder = new ConfigurationBuilder(); - /// - /// Configures the for the service collection. - /// - /// The service collection. - /// The option type. - /// The service collection with options registered. - public static IServiceCollection ConfigureOptions(this IServiceCollection serviceCollection) - where T : class + return serviceCollection.AddSingleton(provider => { - serviceCollection - .AddOptions() - .Configure((T settings, IConfiguration config) => config.Bind(settings)); + provider.GetService>()?.Invoke(builder); - return serviceCollection; - } + return builder.AddConfiguration(configuration).Build(); + }); + } - /// - /// Registers a builder delegate for use in application configuration construction. - /// - /// The service collection. - /// The configuration builder. - /// The service collection with startup dependencies registered. - public static IServiceCollection ConfigureBuilder(this IServiceCollection serviceCollection, Action configurationBuilder) => - serviceCollection.AddSingleton>(_ => configurationBuilder); - - /// - /// Registers an to the service collection. - /// - /// The service collection. - /// The configuration builder. - /// The startup options. - /// The service collection with startup dependencies registered. - public static IServiceCollection ConfigureSettings( - this IServiceCollection serviceCollection, - Action? configuration, - Action? options) - { - if (options == null) - { - return serviceCollection; - } + /// + /// Configures the for the service collection. + /// + /// The service collection. + /// The option type. + /// The service collection with options registered. + public static IServiceCollection ConfigureSectionAsOptions(this IServiceCollection serviceCollection) + where T : class => ConfigureSectionAsOptions(serviceCollection, typeof(T).Name); + + /// + /// Configures the for the service collection. + /// + /// The service collection. + /// The app settings section. + /// The option type. + /// The service collection with options registered. + public static IServiceCollection ConfigureSectionAsOptions(this IServiceCollection serviceCollection, string section) + where T : class + { + serviceCollection + .AddOptions() + .Configure((T settings, IConfiguration config) => config.GetSection(section).Bind(settings)); - var configurationBuilder = new ConfigurationBuilder(); + return serviceCollection; + } - configuration?.Invoke(configurationBuilder); + /// + /// Configures the for the service collection. + /// + /// The service collection. + /// The option type. + /// The service collection with options registered. + public static IServiceCollection ConfigureOptions(this IServiceCollection serviceCollection) + where T : class + { + serviceCollection + .AddOptions() + .Configure((T settings, IConfiguration config) => config.Bind(settings)); - ConfigureAppSettings(serviceCollection, configurationBuilder); + return serviceCollection; + } - var startupOption = new ConfigurationOptions(serviceCollection); - options.Invoke(startupOption); + /// + /// Registers a builder delegate for use in application configuration construction. + /// + /// The service collection. + /// The configuration builder. + /// The service collection with startup dependencies registered. + public static IServiceCollection ConfigureBuilder(this IServiceCollection serviceCollection, Action configurationBuilder) => + serviceCollection.AddSingleton>(_ => configurationBuilder); + /// + /// Registers an to the service collection. + /// + /// The service collection. + /// The configuration builder. + /// The startup options. + /// The service collection with startup dependencies registered. + public static IServiceCollection ConfigureSettings( + this IServiceCollection serviceCollection, + Action? configuration, + Action? options) + { + if (options == null) + { return serviceCollection; } - /// - /// Registers an to the service collection. - /// - /// The service collection. - /// The startup options. - /// The service collection with startup dependencies registered. - public static IServiceCollection ConfigureOptions( - this IServiceCollection serviceCollection, - Action? options) - { - if (options == null) - { - return serviceCollection; - } + var configurationBuilder = new ConfigurationBuilder(); - var startupOption = new ConfigurationOptions(serviceCollection); - options.Invoke(startupOption); + configuration?.Invoke(configurationBuilder); + + ConfigureAppSettings(serviceCollection, configurationBuilder); + + var startupOption = new ConfigurationOptions(serviceCollection); + options.Invoke(startupOption); + return serviceCollection; + } + + /// + /// Registers an to the service collection. + /// + /// The service collection. + /// The startup options. + /// The service collection with startup dependencies registered. + public static IServiceCollection ConfigureOptions( + this IServiceCollection serviceCollection, + Action? options) + { + if (options == null) + { return serviceCollection; } + + var startupOption = new ConfigurationOptions(serviceCollection); + options.Invoke(startupOption); + + return serviceCollection; } -} +} \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/IPlatformInitializer.cs b/src/MicrosoftDependencyInjection/IPlatformInitializer.cs index 476c07ee8..db05c0a13 100644 --- a/src/MicrosoftDependencyInjection/IPlatformInitializer.cs +++ b/src/MicrosoftDependencyInjection/IPlatformInitializer.cs @@ -1,17 +1,16 @@ using Microsoft.Extensions.DependencyInjection; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Represents an initializer for a specific platform. +/// +public interface IPlatformInitializer { /// - /// Represents an initializer for a specific platform. + /// Initialize the platform. /// - public interface IPlatformInitializer - { - /// - /// Initialize the platform. - /// - /// The service collection. - /// The service collection with platform dependencies registered. - public IServiceCollection Initialize(IServiceCollection serviceCollection); - } + /// The service collection. + /// The service collection with platform dependencies registered. + public IServiceCollection Initialize(IServiceCollection serviceCollection); } \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/IServiceCollectionModule.cs b/src/MicrosoftDependencyInjection/IServiceCollectionModule.cs index f50f67592..013c24398 100644 --- a/src/MicrosoftDependencyInjection/IServiceCollectionModule.cs +++ b/src/MicrosoftDependencyInjection/IServiceCollectionModule.cs @@ -1,17 +1,16 @@ using Microsoft.Extensions.DependencyInjection; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Interface that represents a module that groups registrations to the . +/// +public interface IServiceCollectionModule { /// - /// Interface that represents a module that groups registrations to the . + /// Loads the provided with . /// - public interface IServiceCollectionModule - { - /// - /// Loads the provided with . - /// - /// The service collection. - /// The service collection with dependencies registered. - IServiceCollection Load(IServiceCollection serviceCollection); - } + /// The service collection. + /// The service collection with dependencies registered. + IServiceCollection Load(IServiceCollection serviceCollection); } \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/ServiceCollectionModule.cs b/src/MicrosoftDependencyInjection/ServiceCollectionModule.cs index e893b7612..e89737354 100644 --- a/src/MicrosoftDependencyInjection/ServiceCollectionModule.cs +++ b/src/MicrosoftDependencyInjection/ServiceCollectionModule.cs @@ -1,20 +1,19 @@ using Microsoft.Extensions.DependencyInjection; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Represents a module to register dependencies against an . +/// +public abstract class ServiceCollectionModule : IServiceCollectionModule { + /// + IServiceCollection IServiceCollectionModule.Load(IServiceCollection serviceCollection) => Load(serviceCollection); + /// - /// Represents a module to register dependencies against an . + /// Loads the provided with . /// - public abstract class ServiceCollectionModule : IServiceCollectionModule - { - /// - IServiceCollection IServiceCollectionModule.Load(IServiceCollection serviceCollection) => Load(serviceCollection); - - /// - /// Loads the provided with . - /// - /// The service collection. - /// The service collection with dependencies registered. - protected abstract IServiceCollection Load(IServiceCollection serviceCollection); - } + /// The service collection. + /// The service collection with dependencies registered. + protected abstract IServiceCollection Load(IServiceCollection serviceCollection); } \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/ServiceCollectionModuleExtensions.cs b/src/MicrosoftDependencyInjection/ServiceCollectionModuleExtensions.cs index cd7dd0f29..6e52532f2 100644 --- a/src/MicrosoftDependencyInjection/ServiceCollectionModuleExtensions.cs +++ b/src/MicrosoftDependencyInjection/ServiceCollectionModuleExtensions.cs @@ -1,29 +1,28 @@ using Microsoft.Extensions.DependencyInjection; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Extension methods for registering an . +/// +public static class ServiceCollectionModuleExtensions { /// - /// Extension methods for registering an . + /// Adds the provided to the . /// - public static class ServiceCollectionModuleExtensions - { - /// - /// Adds the provided to the . - /// - /// The service collection. - /// The module. - /// The type. - /// The service collection with dependencies registered. - public static IServiceCollection AddModule(this IServiceCollection serviceCollection, T module) - where T : IServiceCollectionModule => module.Load(serviceCollection); + /// The service collection. + /// The module. + /// The type. + /// The service collection with dependencies registered. + public static IServiceCollection AddModule(this IServiceCollection serviceCollection, T module) + where T : IServiceCollectionModule => module.Load(serviceCollection); - /// - /// Adds the provided to the . - /// - /// The service collection. - /// The type. - /// The service collection with dependencies registered. - public static IServiceCollection AddModule(this IServiceCollection serviceCollection) - where T : IServiceCollectionModule, new() => new T().Load(serviceCollection); - } + /// + /// Adds the provided to the . + /// + /// The service collection. + /// The type. + /// The service collection with dependencies registered. + public static IServiceCollection AddModule(this IServiceCollection serviceCollection) + where T : IServiceCollectionModule, new() => new T().Load(serviceCollection); } \ No newline at end of file diff --git a/src/MicrosoftDependencyInjection/StartupOption.cs b/src/MicrosoftDependencyInjection/StartupOption.cs index a6d952023..9763cfda9 100644 --- a/src/MicrosoftDependencyInjection/StartupOption.cs +++ b/src/MicrosoftDependencyInjection/StartupOption.cs @@ -1,32 +1,31 @@ using Microsoft.Extensions.DependencyInjection; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection; + +/// +/// Represents a startup options configurator. +/// +public class StartupOption { + private readonly IServiceCollection _serviceCollection; + /// - /// Represents a startup options configurator. + /// Initializes a new instance of the class. /// - public class StartupOption - { - private readonly IServiceCollection _serviceCollection; - - /// - /// Initializes a new instance of the class. - /// - /// The service collection. - public StartupOption(IServiceCollection serviceCollection) => - _serviceCollection = serviceCollection; + /// The service collection. + public StartupOption(IServiceCollection serviceCollection) => + _serviceCollection = serviceCollection; - /// - /// Adds an to the container. - /// - /// The operation type. - /// The option configuration. - public StartupOption AddOperation() - where T : class, IStartupOperation - { - _serviceCollection.AddTransient(); + /// + /// Adds an to the container. + /// + /// The operation type. + /// The option configuration. + public StartupOption AddOperation() + where T : class, IStartupOperation + { + _serviceCollection.AddTransient(); - return this; - } + return this; } } \ No newline at end of file diff --git a/src/Synthetic/ClientMock.cs b/src/Synthetic/ClientMock.cs index 1b61db954..5e8423386 100644 --- a/src/Synthetic/ClientMock.cs +++ b/src/Synthetic/ClientMock.cs @@ -3,57 +3,56 @@ using System.Threading.Tasks; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic; + +/// +/// Represents a Mock implementation. +/// +/// The entity type. +public abstract class ClientMock : IClient + where T : IDto { /// - /// Represents a Mock implementation. + /// Gets or sets the list of items. /// - /// The entity type. - public abstract class ClientMock : IClient - where T : IDto - { - /// - /// Gets or sets the list of items. - /// - protected List Items { get; set; } = new List(); + protected List Items { get; set; } = new List(); - /// - public virtual Task Get(Guid id) - where T : IDto => Task.FromResult((T)(object)Items.Find(item => item.Id == id)); + /// + public virtual Task Get(Guid id) + where T : IDto => Task.FromResult((T)(object)Items.Find(item => item.Id == id)); - /// - public virtual Task> GetAll() - where T : IDto => Task.FromResult((IEnumerable)Items); + /// + public virtual Task> GetAll() + where T : IDto => Task.FromResult((IEnumerable)Items); - /// - public virtual Task Post(T entity) - where T : IDto => Task.FromResult(entity); + /// + public virtual Task Post(T entity) + where T : IDto => Task.FromResult(entity); - /// - public virtual Task Patch(T entity) - where T : IDto => Task.FromResult(entity); + /// + public virtual Task Patch(T entity) + where T : IDto => Task.FromResult(entity); - /// - public virtual Task Delete(Guid id) - where T : IDto => Task.FromResult((T)(object)Items.Find(x => x.Id == id)); + /// + public virtual Task Delete(Guid id) + where T : IDto => Task.FromResult((T)(object)Items.Find(x => x.Id == id)); - /// - public virtual Task Delete(T entity) - where T : IDto => Task.FromResult(entity); + /// + public virtual Task Delete(T entity) + where T : IDto => Task.FromResult(entity); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - protected virtual void Dispose(bool disposing) + /// + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - } } } } \ No newline at end of file diff --git a/src/Synthetic/Coffee/CoffeeClientMock.cs b/src/Synthetic/Coffee/CoffeeClientMock.cs index c5788941b..37b4c27d7 100644 --- a/src/Synthetic/Coffee/CoffeeClientMock.cs +++ b/src/Synthetic/Coffee/CoffeeClientMock.cs @@ -1,53 +1,52 @@ using System.Collections.Generic; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Coffee +namespace Rocket.Surgery.Airframe.Synthetic.Coffee; + +/// +/// Represents an that returns . +/// +public class CoffeeClientMock : ClientMock { /// - /// Represents an that returns . + /// Initializes a new instance of the class. /// - public class CoffeeClientMock : ClientMock + public CoffeeClientMock() => Items = new List { - /// - /// Initializes a new instance of the class. - /// - public CoffeeClientMock() => Items = new List + new CoffeeDto + { + Name = "Arusha", + Species = Species.Arabica, + Regions = new[] { "Mount Meru, Tanzania", "Papua New Guinea" } + }, + new CoffeeDto { Name = "Benguet", Species = Species.Arabica, Regions = new[] { Regions.Philippines } }, + new CoffeeDto { Name = "Bergendal", Species = Species.Arabica, Regions = new[] { Regions.Indonesia } }, + new CoffeeDto { Name = "Bernardina", Species = Species.Arabica, Regions = new[] { "El Salvador" } }, + new CoffeeDto + { + Name = "Blue Mountain", + Species = Species.Arabica, + Regions = new[] { "Blue Mountains, Jamaica", "Kenya", "Hawaii", "Papu New Guinea", Regions.Cameroon } + }, + new CoffeeDto + { + Name = "Bourbon", + Species = Species.Arabica, + Regions = new[] { "Reunion", "Rwanda", Regions.LatinAmerica } + }, + new CoffeeDto + { + Name = "Catuai", + Species = Species.Arabica, + Regions = new[] { Regions.LatinAmerica } + }, + new CoffeeDto { - new CoffeeDto - { - Name = "Arusha", - Species = Species.Arabica, - Regions = new[] { "Mount Meru, Tanzania", "Papua New Guinea" } - }, - new CoffeeDto { Name = "Benguet", Species = Species.Arabica, Regions = new[] { Regions.Philippines } }, - new CoffeeDto { Name = "Bergendal", Species = Species.Arabica, Regions = new[] { Regions.Indonesia } }, - new CoffeeDto { Name = "Bernardina", Species = Species.Arabica, Regions = new[] { "El Salvador" } }, - new CoffeeDto - { - Name = "Blue Mountain", - Species = Species.Arabica, - Regions = new[] { "Blue Mountains, Jamaica", "Kenya", "Hawaii", "Papu New Guinea", Regions.Cameroon } - }, - new CoffeeDto - { - Name = "Bourbon", - Species = Species.Arabica, - Regions = new[] { "Reunion", "Rwanda", Regions.LatinAmerica } - }, - new CoffeeDto - { - Name = "Catuai", - Species = Species.Arabica, - Regions = new[] { Regions.LatinAmerica } - }, - new CoffeeDto - { - Name = "Catimor", - Species = Species.Arabica, - Regions = new[] { Regions.LatinAmerica, Regions.Indonesia, Regions.India, Regions.China } - }, - new CoffeeDto { Name = "Caturra", Species = Species.Arabica, Regions = new[] { Regions.LatinAmerica } }, - new CoffeeDto { Name = "Charrier", Species = Species.Charrieriana, Regions = new[] { Regions.Cameroon } } - }; - } + Name = "Catimor", + Species = Species.Arabica, + Regions = new[] { Regions.LatinAmerica, Regions.Indonesia, Regions.India, Regions.China } + }, + new CoffeeDto { Name = "Caturra", Species = Species.Arabica, Regions = new[] { Regions.LatinAmerica } }, + new CoffeeDto { Name = "Charrier", Species = Species.Charrieriana, Regions = new[] { Regions.Cameroon } } + }; } \ No newline at end of file diff --git a/src/Synthetic/Coffee/CoffeeDataService.cs b/src/Synthetic/Coffee/CoffeeDataService.cs index b950adf74..b09f2523d 100644 --- a/src/Synthetic/Coffee/CoffeeDataService.cs +++ b/src/Synthetic/Coffee/CoffeeDataService.cs @@ -1,19 +1,18 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Coffee +namespace Rocket.Surgery.Airframe.Synthetic.Coffee; + +/// +/// Represents a coffee data service. +/// +public class CoffeeDataService : DataServiceBase, ICoffeeDataService { /// - /// Represents a coffee data service. + /// Initializes a new instance of the class. /// - public class CoffeeDataService : DataServiceBase, ICoffeeDataService + /// The client. + public CoffeeDataService(IClient client) + : base(client) { - /// - /// Initializes a new instance of the class. - /// - /// The client. - public CoffeeDataService(IClient client) - : base(client) - { - } } } \ No newline at end of file diff --git a/src/Synthetic/Coffee/CoffeeDto.cs b/src/Synthetic/Coffee/CoffeeDto.cs index 6c7d2485f..2a7cef67c 100644 --- a/src/Synthetic/Coffee/CoffeeDto.cs +++ b/src/Synthetic/Coffee/CoffeeDto.cs @@ -1,26 +1,25 @@ using System.Collections.Generic; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Coffee +namespace Rocket.Surgery.Airframe.Synthetic.Coffee; + +/// +/// A coffee data transfer object. +/// +public class CoffeeDto : Dto { /// - /// A coffee data transfer object. + /// Gets or sets the name. /// - public class CoffeeDto : Dto - { - /// - /// Gets or sets the name. - /// - public string Name { get; set; } + public string Name { get; set; } - /// - /// Gets or sets the species. - /// - public string Species { get; set; } + /// + /// Gets or sets the species. + /// + public string Species { get; set; } - /// - /// Gets or sets the regions. - /// - public IEnumerable Regions { get; set; } - } + /// + /// Gets or sets the regions. + /// + public IEnumerable Regions { get; set; } } \ No newline at end of file diff --git a/src/Synthetic/Coffee/ICoffeeDataService.cs b/src/Synthetic/Coffee/ICoffeeDataService.cs index 7ae456463..7b0b33f16 100644 --- a/src/Synthetic/Coffee/ICoffeeDataService.cs +++ b/src/Synthetic/Coffee/ICoffeeDataService.cs @@ -1,11 +1,10 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Coffee +namespace Rocket.Surgery.Airframe.Synthetic.Coffee; + +/// +/// Interface representing a coffee data service. +/// +public interface ICoffeeDataService : IDataService { - /// - /// Interface representing a coffee data service. - /// - public interface ICoffeeDataService : IDataService - { - } } \ No newline at end of file diff --git a/src/Synthetic/Drinks/DrinkClientMock.cs b/src/Synthetic/Drinks/DrinkClientMock.cs index e34828602..79d3f505c 100644 --- a/src/Synthetic/Drinks/DrinkClientMock.cs +++ b/src/Synthetic/Drinks/DrinkClientMock.cs @@ -1,128 +1,127 @@ using System.Collections.Generic; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Drinks +namespace Rocket.Surgery.Airframe.Synthetic.Drinks; + +/// +/// Represents an that returns . +/// +public class DrinkClientMock : ClientMock { /// - /// Represents an that returns . + /// Initializes a new instance of the class. /// - public class DrinkClientMock : ClientMock + public DrinkClientMock() => Items = new List { - /// - /// Initializes a new instance of the class. - /// - public DrinkClientMock() => Items = new List - { - new DrinkDto - { - Title = "Americano", - Type = DrinkType.Americano, - Description = "Dark. Strong" - }, - new DrinkDto - { - Title = "Blonde Americano", - Type = DrinkType.Americano, - Description = "Dark. Strong" - }, - new DrinkDto - { - Title = "Blonde Roast", - Type = DrinkType.Brewed - }, - new DrinkDto - { - Title = "Caffe Misto", - Type = DrinkType.Brewed - }, - new DrinkDto - { - Title = "Dark Roast", - Type = DrinkType.Brewed - }, - new DrinkDto - { - Title = "Medium Roast", - Type = DrinkType.Brewed - }, - new DrinkDto - { - Title = "Espresso", - Type = DrinkType.Espresso, - Description = "Hot. Bold." - }, - new DrinkDto - { - Title = "Cappuccino", - Type = DrinkType.Cappuccino, - Description = "Foamy. Light." - }, - new DrinkDto - { - Title = "Blonde Cappuccino", - Type = DrinkType.Cappuccino, - Description = "Foamy. Light." - }, - new DrinkDto - { - Title = "Flat White", - Type = DrinkType.FlatWhite, - Description = "Heavy. Full." - }, - new DrinkDto - { - Title = "Blonde Flat White", - Type = DrinkType.FlatWhite, - Description = "Heavy. Full." - }, - new DrinkDto - { - Title = "Caffe Latte", - Type = DrinkType.Latte, - Description = "Smooth. Bold." - }, - new DrinkDto - { - Title = "Vanilla Latte", - Type = DrinkType.Latte, - Description = "Smooth. Bold." - }, - new DrinkDto - { - Title = "Burnt Honey Latte", - Type = DrinkType.Latte, - Description = "Smooth. Bold." - }, - new DrinkDto - { - Title = "Hazelnut Latte", - Type = DrinkType.Latte, - Description = "Smooth. Bold." - }, - new DrinkDto - { - Title = "Macchiato", - Type = DrinkType.Macchiato, - Description = "Hot. Bold." - }, - new DrinkDto - { - Title = "Carmel Macchiato", - Type = DrinkType.Macchiato, - Description = "Rich. Sweet." - }, - new DrinkDto - { - Title = "Latte Macchiato", - Type = DrinkType.Macchiato, - Description = "Hot. Bold." - }, - new DrinkDto - { - Title = "Hazelnut Macchiato", - Type = DrinkType.Macchiato, - Description = "Hot. Bold." - } - }; - } + new DrinkDto + { + Title = "Americano", + Type = DrinkType.Americano, + Description = "Dark. Strong" + }, + new DrinkDto + { + Title = "Blonde Americano", + Type = DrinkType.Americano, + Description = "Dark. Strong" + }, + new DrinkDto + { + Title = "Blonde Roast", + Type = DrinkType.Brewed + }, + new DrinkDto + { + Title = "Caffe Misto", + Type = DrinkType.Brewed + }, + new DrinkDto + { + Title = "Dark Roast", + Type = DrinkType.Brewed + }, + new DrinkDto + { + Title = "Medium Roast", + Type = DrinkType.Brewed + }, + new DrinkDto + { + Title = "Espresso", + Type = DrinkType.Espresso, + Description = "Hot. Bold." + }, + new DrinkDto + { + Title = "Cappuccino", + Type = DrinkType.Cappuccino, + Description = "Foamy. Light." + }, + new DrinkDto + { + Title = "Blonde Cappuccino", + Type = DrinkType.Cappuccino, + Description = "Foamy. Light." + }, + new DrinkDto + { + Title = "Flat White", + Type = DrinkType.FlatWhite, + Description = "Heavy. Full." + }, + new DrinkDto + { + Title = "Blonde Flat White", + Type = DrinkType.FlatWhite, + Description = "Heavy. Full." + }, + new DrinkDto + { + Title = "Caffe Latte", + Type = DrinkType.Latte, + Description = "Smooth. Bold." + }, + new DrinkDto + { + Title = "Vanilla Latte", + Type = DrinkType.Latte, + Description = "Smooth. Bold." + }, + new DrinkDto + { + Title = "Burnt Honey Latte", + Type = DrinkType.Latte, + Description = "Smooth. Bold." + }, + new DrinkDto + { + Title = "Hazelnut Latte", + Type = DrinkType.Latte, + Description = "Smooth. Bold." + }, + new DrinkDto + { + Title = "Macchiato", + Type = DrinkType.Macchiato, + Description = "Hot. Bold." + }, + new DrinkDto + { + Title = "Carmel Macchiato", + Type = DrinkType.Macchiato, + Description = "Rich. Sweet." + }, + new DrinkDto + { + Title = "Latte Macchiato", + Type = DrinkType.Macchiato, + Description = "Hot. Bold." + }, + new DrinkDto + { + Title = "Hazelnut Macchiato", + Type = DrinkType.Macchiato, + Description = "Hot. Bold." + } + }; } \ No newline at end of file diff --git a/src/Synthetic/Drinks/DrinkDataService.cs b/src/Synthetic/Drinks/DrinkDataService.cs index 9f35469dd..7656b3f7d 100644 --- a/src/Synthetic/Drinks/DrinkDataService.cs +++ b/src/Synthetic/Drinks/DrinkDataService.cs @@ -1,19 +1,18 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Drinks +namespace Rocket.Surgery.Airframe.Synthetic.Drinks; + +/// +/// Represents a coffee data service. +/// +public class DrinkDataService : DataServiceBase, IDrinkService { /// - /// Represents a coffee data service. + /// Initializes a new instance of the class. /// - public class DrinkDataService : DataServiceBase, IDrinkService + /// The client. + public DrinkDataService(IClient client) + : base(client) { - /// - /// Initializes a new instance of the class. - /// - /// The client. - public DrinkDataService(IClient client) - : base(client) - { - } } } \ No newline at end of file diff --git a/src/Synthetic/Drinks/DrinkDto.cs b/src/Synthetic/Drinks/DrinkDto.cs index 37ba0a11d..fb05033c0 100644 --- a/src/Synthetic/Drinks/DrinkDto.cs +++ b/src/Synthetic/Drinks/DrinkDto.cs @@ -1,35 +1,34 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Drinks +namespace Rocket.Surgery.Airframe.Synthetic.Drinks; + +/// +/// A coffee drink data transfer object. +/// +public class DrinkDto : Dto { /// - /// A coffee drink data transfer object. + /// Gets or sets the title. /// - public class DrinkDto : Dto - { - /// - /// Gets or sets the title. - /// - public string Title { get; set; } + public string Title { get; set; } - /// - /// Gets or sets the description. - /// - public string Description { get; set; } + /// + /// Gets or sets the description. + /// + public string Description { get; set; } - /// - /// Gets or sets the image. - /// - public string Image { get; set; } + /// + /// Gets or sets the image. + /// + public string Image { get; set; } - /// - /// Gets or sets the price. - /// - public double Price { get; set; } + /// + /// Gets or sets the price. + /// + public double Price { get; set; } - /// - /// Gets or sets the type. - /// - public DrinkType Type { get; set; } - } + /// + /// Gets or sets the type. + /// + public DrinkType Type { get; set; } } \ No newline at end of file diff --git a/src/Synthetic/Drinks/DrinkType.cs b/src/Synthetic/Drinks/DrinkType.cs index a378761ab..37530b86a 100644 --- a/src/Synthetic/Drinks/DrinkType.cs +++ b/src/Synthetic/Drinks/DrinkType.cs @@ -1,46 +1,45 @@ using System.Diagnostics.CodeAnalysis; -namespace Rocket.Surgery.Airframe.Synthetic.Drinks +namespace Rocket.Surgery.Airframe.Synthetic.Drinks; + +/// +/// Enumeration representing espresso drink types. +/// +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "enum")] +public enum DrinkType { /// - /// Enumeration representing espresso drink types. + /// Caffe Americano. + /// + Americano, + + /// + /// Drip Coffee. + /// + Brewed, + + /// + /// Cappuccino. + /// + Cappuccino, + + /// + /// Espresso Shots. + /// + Espresso, + + /// + /// Flat White. + /// + FlatWhite, + + /// + /// Caffe Latte. + /// + Latte, + + /// + /// Macchiato. /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "enum")] - public enum DrinkType - { - /// - /// Caffe Americano. - /// - Americano, - - /// - /// Drip Coffee. - /// - Brewed, - - /// - /// Cappuccino. - /// - Cappuccino, - - /// - /// Espresso Shots. - /// - Espresso, - - /// - /// Flat White. - /// - FlatWhite, - - /// - /// Caffe Latte. - /// - Latte, - - /// - /// Macchiato. - /// - Macchiato - } + Macchiato } \ No newline at end of file diff --git a/src/Synthetic/Drinks/IDrinkService.cs b/src/Synthetic/Drinks/IDrinkService.cs index 552bccefa..752183fcd 100644 --- a/src/Synthetic/Drinks/IDrinkService.cs +++ b/src/Synthetic/Drinks/IDrinkService.cs @@ -1,11 +1,10 @@ using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic.Drinks +namespace Rocket.Surgery.Airframe.Synthetic.Drinks; + +/// +/// Interface representing a coffee drink data service. +/// +public interface IDrinkService : IDataService { - /// - /// Interface representing a coffee drink data service. - /// - public interface IDrinkService : IDataService - { - } } \ No newline at end of file diff --git a/src/Synthetic/HubClientMock.cs b/src/Synthetic/HubClientMock.cs index 70cbabd3e..67cbbcfa4 100644 --- a/src/Synthetic/HubClientMock.cs +++ b/src/Synthetic/HubClientMock.cs @@ -1,17 +1,16 @@ using System.Threading.Tasks; using Rocket.Surgery.Airframe.Data; -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic; + +/// +/// Represents a SignalR a hub client. +/// +public class HubClientMock : HubClientBase { - /// - /// Represents a SignalR a hub client. - /// - public class HubClientMock : HubClientBase - { - /// - public override Task Connect() => Task.CompletedTask; + /// + public override Task Connect() => Task.CompletedTask; - /// - public override Task InvokeAsync(string methodName) => Task.FromResult(default(T)); - } + /// + public override Task InvokeAsync(string methodName) => Task.FromResult(default(T)); } \ No newline at end of file diff --git a/src/Synthetic/Regions.cs b/src/Synthetic/Regions.cs index 48604d4ab..01c915b38 100644 --- a/src/Synthetic/Regions.cs +++ b/src/Synthetic/Regions.cs @@ -1,48 +1,47 @@ -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic; + +/// +/// Static Regions. +/// +public static class Regions { /// - /// Static Regions. - /// - public static class Regions - { - /// - /// Gets the latin america region. - /// - public const string LatinAmerica = nameof(LatinAmerica); - - /// - /// Gets the latin america region. - /// - public const string Philippines = nameof(Philippines); - - /// - /// Gets the latin america region. - /// - public const string Indonesia = nameof(Indonesia); - - /// - /// Gets the latin america region. - /// - public const string Kenya = nameof(Kenya); - - /// - /// Gets the latin america region. - /// - public const string Hawaii = nameof(Hawaii); - - /// - /// Gets the latin america region. - /// - public const string India = nameof(India); - - /// - /// Gets the latin america region. - /// - public const string China = nameof(China); - - /// - /// Gets the latin america region. - /// - public const string Cameroon = nameof(Cameroon); - } + /// Gets the latin america region. + /// + public const string LatinAmerica = nameof(LatinAmerica); + + /// + /// Gets the latin america region. + /// + public const string Philippines = nameof(Philippines); + + /// + /// Gets the latin america region. + /// + public const string Indonesia = nameof(Indonesia); + + /// + /// Gets the latin america region. + /// + public const string Kenya = nameof(Kenya); + + /// + /// Gets the latin america region. + /// + public const string Hawaii = nameof(Hawaii); + + /// + /// Gets the latin america region. + /// + public const string India = nameof(India); + + /// + /// Gets the latin america region. + /// + public const string China = nameof(China); + + /// + /// Gets the latin america region. + /// + public const string Cameroon = nameof(Cameroon); } \ No newline at end of file diff --git a/src/Synthetic/Species.cs b/src/Synthetic/Species.cs index 06c90f304..5f4c18438 100644 --- a/src/Synthetic/Species.cs +++ b/src/Synthetic/Species.cs @@ -1,18 +1,17 @@ -namespace Rocket.Surgery.Airframe.Synthetic +namespace Rocket.Surgery.Airframe.Synthetic; + +/// +/// Static species. +/// +public static class Species { /// - /// Static species. + /// Gets the Arabica species. /// - public static class Species - { - /// - /// Gets the Arabica species. - /// - public const string Arabica = nameof(Arabica); + public const string Arabica = nameof(Arabica); - /// - /// Gets the Charrieriana species. - /// - public const string Charrieriana = nameof(Charrieriana); - } + /// + /// Gets the Charrieriana species. + /// + public const string Charrieriana = nameof(Charrieriana); } \ No newline at end of file diff --git a/src/Timers/DecrementTimer.cs b/src/Timers/DecrementTimer.cs index 3f8eec723..d468754ea 100644 --- a/src/Timers/DecrementTimer.cs +++ b/src/Timers/DecrementTimer.cs @@ -1,26 +1,25 @@ using System; using JetBrains.Annotations; -namespace Rocket.Surgery.Airframe.Timers +namespace Rocket.Surgery.Airframe.Timers; + +/// +/// Represents an . +/// +public class DecrementTimer : ObservableTimer, IDecrement { /// - /// Represents an . + /// Initializes a new instance of the class. /// - public class DecrementTimer : ObservableTimer, IDecrement + /// The scheduler provider. + public DecrementTimer([NotNull] ISchedulerProvider schedulerProvider) + : base(schedulerProvider) { - /// - /// Initializes a new instance of the class. - /// - /// The scheduler provider. - public DecrementTimer([NotNull] ISchedulerProvider schedulerProvider) - : base(schedulerProvider) - { - } + } - /// - protected override TimeSpan TimeAccumulator(TimeSpan accumulated) => accumulated - TimeSpans.RefreshInterval; + /// + protected override TimeSpan TimeAccumulator(TimeSpan accumulated) => accumulated - TimeSpans.RefreshInterval; - /// - protected override bool Elapse(TimeSpan elapsed) => elapsed <= TimeSpan.Zero; - } -} + /// + protected override bool Elapse(TimeSpan elapsed) => elapsed <= TimeSpan.Zero; +} \ No newline at end of file diff --git a/src/Timers/DivisibleTimer.cs b/src/Timers/DivisibleTimer.cs index a0f82f883..ef0afde8d 100644 --- a/src/Timers/DivisibleTimer.cs +++ b/src/Timers/DivisibleTimer.cs @@ -1,72 +1,71 @@ using System; using System.Reactive.Linq; -namespace Rocket.Surgery.Airframe.Timers +namespace Rocket.Surgery.Airframe.Timers; + +/// +/// A timer that partitions time base on a provided partition number.. +/// +public class DivisibleTimer : TimerBase { + private ObservableTimer _currentTimer; + /// - /// A timer that partitions time base on a provided partition number.. + /// Initializes a new instance of the class. /// - public class DivisibleTimer : TimerBase + /// The scheduler. + public DivisibleTimer(ISchedulerProvider schedulerProvider) + : base(schedulerProvider) { - private ObservableTimer _currentTimer; - - /// - /// Initializes a new instance of the class. - /// - /// The scheduler. - public DivisibleTimer(ISchedulerProvider schedulerProvider) - : base(schedulerProvider) - { - Interval = Observable.Empty(); - Timer = Observable.Empty(); - } + Interval = Observable.Empty(); + Timer = Observable.Empty(); + } - /// - /// Gets the interval timer. - /// - public IObservable Interval { get; private set; } + /// + /// Gets the interval timer. + /// + public IObservable Interval { get; private set; } - /// - /// Gets the over all timer. - /// - public IObservable Timer { get; private set; } + /// + /// Gets the over all timer. + /// + public IObservable Timer { get; private set; } - /// - /// Gets the interval time. - /// - public TimeSpan IntervalTime { get; private set; } + /// + /// Gets the interval time. + /// + public TimeSpan IntervalTime { get; private set; } - /// - /// Started the timer. - /// - /// The partition. - /// The overall duration. - public void Start(int partition, TimeSpan duration) - { - var refreshInterval = TimeSpan.FromMilliseconds(1000); + /// + /// Started the timer. + /// + /// The partition. + /// The overall duration. + public void Start(int partition, TimeSpan duration) + { + var refreshInterval = TimeSpan.FromMilliseconds(1000); - long ticks = Math.DivRem(duration.Ticks, partition, out var remainder); + long ticks = Math.DivRem(duration.Ticks, partition, out var remainder); - TimeSpan timePerPartition = TimeSpan.FromTicks(ticks); + TimeSpan timePerPartition = TimeSpan.FromTicks(ticks); - Timer = - Observable - .Range(0, partition) - .Select(_ => - { - _currentTimer = new DecrementTimer(SchedulerProvider); - return Observable.Empty(); - }) - .Concat(); + Timer = + Observable + .Range(0, partition) + .Select(_ => + { + _currentTimer = new DecrementTimer(SchedulerProvider); + return Observable.Empty(); + }) + .Concat(); - IntervalTime = timePerPartition; + IntervalTime = timePerPartition; - // TODO: [rlittlesii: January 11, 2021] Fix this math. The interval should be - Interval = - Observable - .Interval(refreshInterval, SchedulerProvider.BackgroundThread) - .Scan(TimeSpan.Zero, (acc, _) => acc + refreshInterval) - .TakeUntil(x => x <= timePerPartition); - } + // TODO: [rlittlesii: January 11, 2021] Fix this math. The interval should be + Interval = + Observable + .Interval(refreshInterval, SchedulerProvider.BackgroundThread) + .Scan(TimeSpan.Zero, (acc, _) => acc + refreshInterval) + .TakeUntil(x => x <= timePerPartition); } } \ No newline at end of file diff --git a/src/Timers/Events/TimerEvent.cs b/src/Timers/Events/TimerEvent.cs index 00c448247..254bcd064 100644 --- a/src/Timers/Events/TimerEvent.cs +++ b/src/Timers/Events/TimerEvent.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe.Timers.Events +namespace Rocket.Surgery.Airframe.Timers.Events; + +/// +/// A timer changed notification. +/// +public class TimerEvent { - /// - /// A timer changed notification. - /// - public class TimerEvent - { - } } \ No newline at end of file diff --git a/src/Timers/Events/TimerResetEvent.cs b/src/Timers/Events/TimerResetEvent.cs index aeb219b6b..01e529fdc 100644 --- a/src/Timers/Events/TimerResetEvent.cs +++ b/src/Timers/Events/TimerResetEvent.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe.Timers.Events +namespace Rocket.Surgery.Airframe.Timers.Events; + +/// +/// Indicates a timer has reset. +/// +public class TimerResetEvent : TimerEvent { - /// - /// Indicates a timer has reset. - /// - public class TimerResetEvent : TimerEvent - { - } } \ No newline at end of file diff --git a/src/Timers/Events/TimerResumeEvent.cs b/src/Timers/Events/TimerResumeEvent.cs index 3def5dd4f..b0f8d150e 100644 --- a/src/Timers/Events/TimerResumeEvent.cs +++ b/src/Timers/Events/TimerResumeEvent.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe.Timers.Events +namespace Rocket.Surgery.Airframe.Timers.Events; + +/// +/// Indicates a timer has resumed. +/// +public class TimerResumeEvent : TimerEvent { - /// - /// Indicates a timer has resumed. - /// - public class TimerResumeEvent : TimerEvent - { - } } \ No newline at end of file diff --git a/src/Timers/Events/TimerStartEvent.cs b/src/Timers/Events/TimerStartEvent.cs index b34644c70..6eeb73f4e 100644 --- a/src/Timers/Events/TimerStartEvent.cs +++ b/src/Timers/Events/TimerStartEvent.cs @@ -1,21 +1,20 @@ using System; -namespace Rocket.Surgery.Airframe.Timers.Events +namespace Rocket.Surgery.Airframe.Timers.Events; + +/// +/// Indicates a timer has started. +/// +public class TimerStartEvent : TimerEvent { /// - /// Indicates a timer has started. + /// Initializes a new instance of the class. /// - public class TimerStartEvent : TimerEvent - { - /// - /// Initializes a new instance of the class. - /// - /// The duration. - public TimerStartEvent(TimeSpan duration) => Duration = duration; + /// The duration. + public TimerStartEvent(TimeSpan duration) => Duration = duration; - /// - /// Gets the duration of the even that is starting. - /// - public TimeSpan Duration { get; } - } + /// + /// Gets the duration of the even that is starting. + /// + public TimeSpan Duration { get; } } \ No newline at end of file diff --git a/src/Timers/Events/TimerStopEvent.cs b/src/Timers/Events/TimerStopEvent.cs index aaf926d42..4e44dfc9d 100644 --- a/src/Timers/Events/TimerStopEvent.cs +++ b/src/Timers/Events/TimerStopEvent.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe.Timers.Events +namespace Rocket.Surgery.Airframe.Timers.Events; + +/// +/// Indicates a timer has stopped. +/// +public class TimerStopEvent : TimerEvent { - /// - /// Indicates a timer has stopped. - /// - public class TimerStopEvent : TimerEvent - { - } } \ No newline at end of file diff --git a/src/Timers/IncrementTimer.cs b/src/Timers/IncrementTimer.cs index a64c47393..db8bc60cf 100644 --- a/src/Timers/IncrementTimer.cs +++ b/src/Timers/IncrementTimer.cs @@ -1,26 +1,25 @@ using System; using JetBrains.Annotations; -namespace Rocket.Surgery.Airframe.Timers +namespace Rocket.Surgery.Airframe.Timers; + +/// +/// Represents an . +/// +public class IncrementTimer : ObservableTimer, IIncrement { /// - /// Represents an . + /// Initializes a new instance of the class. /// - public class IncrementTimer : ObservableTimer, IIncrement + /// The scheduler provider. + public IncrementTimer([NotNull] ISchedulerProvider schedulerProvider) + : base(schedulerProvider) { - /// - /// Initializes a new instance of the class. - /// - /// The scheduler provider. - public IncrementTimer([NotNull] ISchedulerProvider schedulerProvider) - : base(schedulerProvider) - { - } + } - /// - protected override TimeSpan TimeAccumulator(TimeSpan accumulated) => accumulated + TimeSpans.RefreshInterval; + /// + protected override TimeSpan TimeAccumulator(TimeSpan accumulated) => accumulated + TimeSpans.RefreshInterval; - /// - protected override bool Elapse(TimeSpan elapsed) => false; - } + /// + protected override bool Elapse(TimeSpan elapsed) => false; } \ No newline at end of file diff --git a/src/Timers/ObservableTimer.cs b/src/Timers/ObservableTimer.cs index be326f8f9..65163b57b 100644 --- a/src/Timers/ObservableTimer.cs +++ b/src/Timers/ObservableTimer.cs @@ -5,103 +5,102 @@ using ReactiveUI; using Rocket.Surgery.Airframe.Timers.Events; -namespace Rocket.Surgery.Airframe.Timers +namespace Rocket.Surgery.Airframe.Timers; + +/// +/// Represents a default implementation of . +/// +public abstract class ObservableTimer : ReactiveObject, ITimer, IDisposable { + private readonly ISubject _timerEvents = new Subject(); + private readonly ObservableAsPropertyHelper _isRunning; + private readonly IObservable _elapsed; + private TimeSpan _resumeTime = TimeSpan.Zero; + /// - /// Represents a default implementation of . + /// Initializes a new instance of the class. /// - public abstract class ObservableTimer : ReactiveObject, ITimer, IDisposable + /// The scheduler provider. + protected ObservableTimer(ISchedulerProvider schedulerProvider) { - private readonly ISubject _timerEvents = new Subject(); - private readonly ObservableAsPropertyHelper _isRunning; - private readonly IObservable _elapsed; - private TimeSpan _resumeTime = TimeSpan.Zero; - - /// - /// Initializes a new instance of the class. - /// - /// The scheduler provider. - protected ObservableTimer(ISchedulerProvider schedulerProvider) - { + _timerEvents + .Select(x => x is TimerStartEvent) + .ToProperty(this, nameof(IsRunning), out _isRunning) + .DisposeWith(Garbage); + + _elapsed = _timerEvents - .Select(x => x is TimerStartEvent) - .ToProperty(this, nameof(IsRunning), out _isRunning) - .DisposeWith(Garbage); - - _elapsed = - _timerEvents - .CombineLatest( - _timerEvents - .OfType() - .Select(x => x.Duration), - (timerEvent, duration) => (duration, isRunning: timerEvent is TimerStartEvent)) - .Select( - x => x.isRunning - ? Observable - .Interval(TimeSpans.RefreshInterval, schedulerProvider.BackgroundThread) - .Scan(x.duration, (duration, _) => Accumulator(duration)) - .TakeUntil(Elapsed) - .Do(elapsed => _resumeTime = elapsed, () => _resumeTime = x.duration) - : Observable.Return(_resumeTime)) - .Switch(); - } + .CombineLatest( + _timerEvents + .OfType() + .Select(x => x.Duration), + (timerEvent, duration) => (duration, isRunning: timerEvent is TimerStartEvent)) + .Select( + x => x.isRunning + ? Observable + .Interval(TimeSpans.RefreshInterval, schedulerProvider.BackgroundThread) + .Scan(x.duration, (duration, _) => Accumulator(duration)) + .TakeUntil(Elapsed) + .Do(elapsed => _resumeTime = elapsed, () => _resumeTime = x.duration) + : Observable.Return(_resumeTime)) + .Switch(); + } - /// - public bool IsRunning => _isRunning.Value; + /// + public bool IsRunning => _isRunning.Value; - /// - /// Gets the garbage. - /// - protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); + /// + /// Gets the garbage. + /// + protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); - /// - public void Start(TimeSpan timeSpan) => _timerEvents.OnNext(new TimerStartEvent(timeSpan)); + /// + public void Start(TimeSpan timeSpan) => _timerEvents.OnNext(new TimerStartEvent(timeSpan)); - /// - public void Start() => _timerEvents.OnNext(new TimerStartEvent(_resumeTime)); + /// + public void Start() => _timerEvents.OnNext(new TimerStartEvent(_resumeTime)); - /// - public void Stop() => _timerEvents.OnNext(new TimerStopEvent()); + /// + public void Stop() => _timerEvents.OnNext(new TimerStopEvent()); - /// - public IDisposable Subscribe(IObserver observer) => - _elapsed.Subscribe(observer); + /// + public IDisposable Subscribe(IObserver observer) => + _elapsed.Subscribe(observer); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Accumulates the provided time. - /// - /// The accumulated value. - /// The new time. - protected abstract TimeSpan TimeAccumulator(TimeSpan accumulated); - - /// - /// Gets a value indicating whether the time has elapsed. - /// - /// The elapsed time. - /// Whether the time has elapsed. - protected abstract bool Elapse(TimeSpan elapsed); - - /// - /// Dispose. - /// - /// A value indicating whether or not you are disposing. - protected virtual void Dispose(bool disposing) + /// + /// Accumulates the provided time. + /// + /// The accumulated value. + /// The new time. + protected abstract TimeSpan TimeAccumulator(TimeSpan accumulated); + + /// + /// Gets a value indicating whether the time has elapsed. + /// + /// The elapsed time. + /// Whether the time has elapsed. + protected abstract bool Elapse(TimeSpan elapsed); + + /// + /// Dispose. + /// + /// A value indicating whether or not you are disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - Garbage.Dispose(); - } + Garbage.Dispose(); } + } - private TimeSpan Accumulator(TimeSpan accumulated) => TimeAccumulator(accumulated); + private TimeSpan Accumulator(TimeSpan accumulated) => TimeAccumulator(accumulated); - private bool Elapsed(TimeSpan elapsed) => Elapse(elapsed); - } + private bool Elapsed(TimeSpan elapsed) => Elapse(elapsed); } \ No newline at end of file diff --git a/src/Timers/TimeSpans.cs b/src/Timers/TimeSpans.cs index 06a3bfc85..b2a70d092 100644 --- a/src/Timers/TimeSpans.cs +++ b/src/Timers/TimeSpans.cs @@ -1,15 +1,14 @@ using System; -namespace Rocket.Surgery.Airframe.Timers +namespace Rocket.Surgery.Airframe.Timers; + +/// +/// Represents common . +/// +public static class TimeSpans { /// - /// Represents common . + /// Gets the default refresh . /// - public static class TimeSpans - { - /// - /// Gets the default refresh . - /// - public static TimeSpan RefreshInterval { get; } = TimeSpan.FromSeconds(1); - } + public static TimeSpan RefreshInterval { get; } = TimeSpan.FromSeconds(1); } \ No newline at end of file diff --git a/src/Timers/TimerBase.cs b/src/Timers/TimerBase.cs index f7e988c86..ded2c2e65 100644 --- a/src/Timers/TimerBase.cs +++ b/src/Timers/TimerBase.cs @@ -3,46 +3,45 @@ using System.Reactive.Subjects; using ReactiveUI; -namespace Rocket.Surgery.Airframe.Timers +namespace Rocket.Surgery.Airframe.Timers; + +/// +/// Represents a base abstraction for a timer. +/// +public abstract class TimerBase : ReactiveObject, IDisposable { /// - /// Represents a base abstraction for a timer. + /// Initializes a new instance of the class. /// - public abstract class TimerBase : ReactiveObject, IDisposable - { - /// - /// Initializes a new instance of the class. - /// - /// The scheduler. - protected TimerBase(ISchedulerProvider schedulerProvider) => SchedulerProvider = schedulerProvider; + /// The scheduler. + protected TimerBase(ISchedulerProvider schedulerProvider) => SchedulerProvider = schedulerProvider; - /// - protected ISchedulerProvider SchedulerProvider { get; set; } + /// + protected ISchedulerProvider SchedulerProvider { get; set; } - /// - protected Subject Running { get; } = new Subject(); + /// + protected Subject Running { get; } = new Subject(); - /// - protected CompositeDisposable TimesUp { get; } = new CompositeDisposable(); + /// + protected CompositeDisposable TimesUp { get; } = new CompositeDisposable(); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposes of resources. - /// - /// A value indicating whether it is disposing. - protected virtual void Dispose(bool disposing) + /// + /// Disposes of resources. + /// + /// A value indicating whether it is disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - TimesUp?.Dispose(); - Running?.Dispose(); - } + TimesUp?.Dispose(); + Running?.Dispose(); } } } \ No newline at end of file diff --git a/src/ViewModels/INetworkAware.cs b/src/ViewModels/INetworkAware.cs index 2fcaa120c..5e09aac9f 100644 --- a/src/ViewModels/INetworkAware.cs +++ b/src/ViewModels/INetworkAware.cs @@ -1,16 +1,14 @@ using System; -using Rocket.Surgery.Airframe.Connectivity; -namespace Rocket.Surgery.Airframe.ViewModels +namespace Rocket.Surgery.Airframe.ViewModels; + +/// +/// Interface representing an element that subscribes to network connectivity changes. +/// +public interface INetworkAware { /// - /// Interface representing an element that subscribes to network connectivity changes. + /// Gets the connectivity. /// - public interface INetworkAware - { - /// - /// Gets the connectivity. - /// - IObservable Connectivity { get; } - } -} + IObservable Connectivity { get; } +} \ No newline at end of file diff --git a/src/ViewModels/NavigableViewModelBase.cs b/src/ViewModels/NavigableViewModelBase.cs index 384b2632a..09551701f 100644 --- a/src/ViewModels/NavigableViewModelBase.cs +++ b/src/ViewModels/NavigableViewModelBase.cs @@ -3,60 +3,59 @@ using System.Reactive.Subjects; using Rocket.Surgery.Airframe.Navigation; -namespace Rocket.Surgery.Airframe.ViewModels +namespace Rocket.Surgery.Airframe.ViewModels; + +/// +/// Base view model for navigation. +/// +public abstract class NavigableViewModelBase : ViewModelBase, INavigated, IDestructible, IInitialize { + /// + void IInitialize.OnInitialize(IArguments arguments) + { + _initialize.OnNext(arguments); + _initialize.OnCompleted(); + } + + /// + void INavigated.OnNavigatedTo(IArguments arguments) => _navigatedTo.OnNext(arguments); + + /// + void INavigated.OnNavigatedFrom(IArguments arguments) => _navigatedFrom.OnNext(arguments); + /// - /// Base view model for navigation. + /// Gets the initial to . /// - public abstract class NavigableViewModelBase : ViewModelBase, INavigated, IDestructible, IInitialize + /// The arguments. + protected IObservable Initialize => _initialize.AsObservable().Publish().RefCount(); + + /// + /// Gets the navigated to . + /// + /// The arguments. + protected IObservable NavigatedTo => _navigatedTo.AsObservable().Publish().RefCount(); + + /// + /// Gets the navigated from . + /// + /// The arguments. + protected IObservable NavigatedFrom => _navigatedFrom.AsObservable().Publish().RefCount(); + + /// + void IDestructible.Destroy() { - /// - void IInitialize.OnInitialize(IArguments arguments) - { - _initialize.OnNext(arguments); - _initialize.OnCompleted(); - } - - /// - void INavigated.OnNavigatedTo(IArguments arguments) => _navigatedTo.OnNext(arguments); - - /// - void INavigated.OnNavigatedFrom(IArguments arguments) => _navigatedFrom.OnNext(arguments); - - /// - /// Gets the initial to . - /// - /// The arguments. - protected IObservable Initialize => _initialize.AsObservable().Publish().RefCount(); - - /// - /// Gets the navigated to . - /// - /// The arguments. - protected IObservable NavigatedTo => _navigatedTo.AsObservable().Publish().RefCount(); - - /// - /// Gets the navigated from . - /// - /// The arguments. - protected IObservable NavigatedFrom => _navigatedFrom.AsObservable().Publish().RefCount(); - - /// - void IDestructible.Destroy() - { - Destroy(); - Dispose(); - } - - /// - /// Template method to destroy the view model. - /// - protected virtual void Destroy() - { - } - - private readonly AsyncSubject _initialize = new AsyncSubject(); - private readonly Subject _navigatedTo = new Subject(); - private readonly Subject _navigatedFrom = new Subject(); + Destroy(); + Dispose(); } + + /// + /// Template method to destroy the view model. + /// + protected virtual void Destroy() + { + } + + private readonly AsyncSubject _initialize = new AsyncSubject(); + private readonly Subject _navigatedTo = new Subject(); + private readonly Subject _navigatedFrom = new Subject(); } \ No newline at end of file diff --git a/src/ViewModels/ReactiveDisposable.cs b/src/ViewModels/ReactiveDisposable.cs index 2154d740d..96c49e568 100644 --- a/src/ViewModels/ReactiveDisposable.cs +++ b/src/ViewModels/ReactiveDisposable.cs @@ -2,35 +2,34 @@ using System.Reactive.Disposables; using ReactiveUI; -namespace Rocket.Surgery.Airframe.ViewModels +namespace Rocket.Surgery.Airframe.ViewModels; + +/// +/// Represents a base object for garbage collection. +/// +public abstract class ReactiveDisposable : ReactiveObject, IDisposable { /// - /// Represents a base object for garbage collection. + /// Gets the collection of disposables. /// - public abstract class ReactiveDisposable : ReactiveObject, IDisposable - { - /// - /// Gets the collection of disposables. - /// - protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); + protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposes of the garbage. - /// - /// Whether the object is disposing. - protected virtual void Dispose(bool disposing) + /// + /// Disposes of the garbage. + /// + /// Whether the object is disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - Garbage.Dispose(); - } + Garbage.Dispose(); } } } \ No newline at end of file diff --git a/src/ViewModels/ViewModelBase.cs b/src/ViewModels/ViewModelBase.cs index b09d6ea0a..e2f5b16a4 100644 --- a/src/ViewModels/ViewModelBase.cs +++ b/src/ViewModels/ViewModelBase.cs @@ -2,40 +2,39 @@ using System.Reactive.Disposables; using ReactiveMarbles.Mvvm; -namespace Rocket.Surgery.Airframe.ViewModels +namespace Rocket.Surgery.Airframe.ViewModels; + +/// +/// Base ReactiveUI View Model. +/// +public abstract class ViewModelBase : RxObject, IDisposable { /// - /// Base ReactiveUI View Model. + /// Gets or sets a value indicating whether this view model is loading. /// - public abstract class ViewModelBase : RxObject, IDisposable - { - /// - /// Gets or sets a value indicating whether this view model is loading. - /// - public bool IsLoading { get; protected set; } + public bool IsLoading { get; protected set; } - /// - /// Gets the collection of disposables. - /// - protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); + /// + /// Gets the collection of disposables. + /// + protected CompositeDisposable Garbage { get; } = new CompositeDisposable(); - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - /// - /// Disposes of the garbage. - /// - /// Whether the object is disposing. - protected virtual void Dispose(bool disposing) + /// + /// Disposes of the garbage. + /// + /// Whether the object is disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) { - if (disposing) - { - Garbage.Dispose(); - } + Garbage.Dispose(); } } } \ No newline at end of file diff --git a/test/Airframe.Tests/NoExceptionHandlerStub.cs b/test/Airframe.Tests/NoExceptionHandlerStub.cs index 5a9bb5fcf..f4416936a 100644 --- a/test/Airframe.Tests/NoExceptionHandlerStub.cs +++ b/test/Airframe.Tests/NoExceptionHandlerStub.cs @@ -1,24 +1,23 @@ using System; -namespace Rocket.Surgery.Airframe.Tests +namespace Rocket.Surgery.Airframe.Tests; + +internal sealed class NoExceptionHandlerStub : IObserver { - internal sealed class NoExceptionHandlerStub : IObserver - { - public static readonly NoExceptionHandlerStub Instance = new NoExceptionHandlerStub(); + public static readonly NoExceptionHandlerStub Instance = new NoExceptionHandlerStub(); - /// - public void OnCompleted() - { - } + /// + public void OnCompleted() + { + } - /// - public void OnError(Exception error) - { - } + /// + public void OnError(Exception error) + { + } - /// - public void OnNext(Exception exception) - { - } + /// + public void OnNext(Exception exception) + { } } \ No newline at end of file diff --git a/test/Airframe.Tests/TestBase.cs b/test/Airframe.Tests/TestBase.cs index acc2dbe6a..ab7fac3fa 100644 --- a/test/Airframe.Tests/TestBase.cs +++ b/test/Airframe.Tests/TestBase.cs @@ -1,11 +1,10 @@ using ReactiveUI; -namespace Rocket.Surgery.Airframe.Tests +namespace Rocket.Surgery.Airframe.Tests; + +public abstract class TestBase { - public abstract class TestBase - { - protected TestBase() => Initialize(); + protected TestBase() => Initialize(); - private static void Initialize() => RxApp.DefaultExceptionHandler = NoExceptionHandlerStub.Instance; - } + private static void Initialize() => RxApp.DefaultExceptionHandler = NoExceptionHandlerStub.Instance; } \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs b/test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs deleted file mode 100644 index f977f3bd0..000000000 --- a/test/Core.Tests/Connectivity/ConnectivityChangedEventFixture.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Rocket.Surgery.Airframe.Connectivity; -using Rocket.Surgery.Extensions.Testing.Fixtures; -using System.Linq; - -namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; - -internal sealed class ConnectivityChangedEventFixture : ITestFixtureBuilder -{ - public static implicit operator NetworkStateChangedEvent(ConnectivityChangedEventFixture fixture) => fixture.Build(); - - public ConnectivityChangedEventFixture WithDefault() => WithDefaultAccess().WithDefaultProfiles(); - - public ConnectivityChangedEventFixture WithDefaultAccess() => this.With(ref _networkAccess, NetworkAccess.Internet); - - public ConnectivityChangedEventFixture WithDefaultProfiles() => WithProfiles( - ConnectionProfile.Bluetooth, - ConnectionProfile.Ethernet, - ConnectionProfile.WiFi - ); - - public ConnectivityChangedEventFixture WithProfiles(params ConnectionProfile[] profiles) => this.With(ref _profiles, profiles); - - private NetworkStateChangedEvent Build() => new NetworkStateChangedEvent(_networkAccess, _profiles.ToArray()); - - private NetworkAccess _networkAccess = NetworkAccess.Internet; - private ConnectionProfile[] _profiles = { ConnectionProfile.WiFi }; -} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs b/test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs deleted file mode 100644 index c76050606..000000000 --- a/test/Core.Tests/Connectivity/ConnectivityChangedEventTests.cs +++ /dev/null @@ -1,76 +0,0 @@ -using FluentAssertions; -using Rocket.Surgery.Airframe.Connectivity; -using Xunit; - -namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity -{ - public class ConnectivityChangedEventTests - { - [Theory] - [InlineData(ConnectionProfile.Bluetooth)] - [InlineData(ConnectionProfile.Ethernet)] - [InlineData(ConnectionProfile.Cellular)] - [InlineData(ConnectionProfile.WiFi)] - public void GivenValidProfile_WhenHasValidProfile_ThenResultTrue(ConnectionProfile profile) - { - // Given, When - NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithProfiles(profile); - - // Then - sut - .HasValidProfile() - .Should() - .BeTrue(); - } - - [Theory] - [InlineData(ConnectionProfile.Unknown)] - public void GivenValidProfile_WhenHasValidProfile_ThenResultFalse(ConnectionProfile profile) - { - // Given, When - NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithProfiles(profile); - - // Then - sut - .HasValidProfile() - .Should() - .BeFalse(); - } - - [Fact] - public void GivenDefaultEventArg_WhenHasAccess_ThenResultTrue() - { - // Given, When - NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithDefault(); - - // Then - sut.HasSignal() - .Should() - .BeTrue(); - } - - [Fact] - public void GivenDefaultEventArg_WhenToString_ThenResultCorrect() - { - // Given, When - NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithDefault(); - - // Then - sut.ToString() - .Should() - .Be("NetworkAccess: Internet, ConnectionProfiles: [Bluetooth, Ethernet, WiFi]"); - } - - [Fact] - public void GivenDefaultEventArg_WhenDegraded_ThenResultTrue() - { - // Given, When - NetworkStateChangedEvent sut = new ConnectivityChangedEventFixture().WithProfiles(ConnectionProfile.Unknown); - - // Then - sut.Degraded() - .Should() - .BeTrue(); - } - } -} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/NetworkStateChangedEventFixture.cs b/test/Core.Tests/Connectivity/NetworkStateChangedEventFixture.cs new file mode 100644 index 000000000..5adf5c061 --- /dev/null +++ b/test/Core.Tests/Connectivity/NetworkStateChangedEventFixture.cs @@ -0,0 +1,26 @@ +using Rocket.Surgery.Extensions.Testing.Fixtures; +using System.Linq; + +namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; + +internal sealed class NetworkStateChangedEventFixture : ITestFixtureBuilder +{ + public static implicit operator NetworkStateChangedEvent(NetworkStateChangedEventFixture fixture) => fixture.Build(); + + public NetworkStateChangedEventFixture WithDefault() => WithDefaultAccess().WithDefaultProfiles(); + + public NetworkStateChangedEventFixture WithDefaultAccess() => this.With(ref _networkAccess, NetworkAccess.Internet); + + public NetworkStateChangedEventFixture WithDefaultProfiles() => WithProfiles( + NetworkConnection.Bluetooth, + NetworkConnection.Ethernet, + NetworkConnection.WiFi + ); + + public NetworkStateChangedEventFixture WithProfiles(params NetworkConnection[] profiles) => this.With(ref _profiles, profiles); + + private NetworkStateChangedEvent Build() => new NetworkStateChangedEvent(_networkAccess, _profiles.ToArray()); + + private NetworkAccess _networkAccess = NetworkAccess.Internet; + private NetworkConnection[] _profiles = { NetworkConnection.WiFi }; +} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/NetworkStateChangedEventTests.cs b/test/Core.Tests/Connectivity/NetworkStateChangedEventTests.cs new file mode 100644 index 000000000..725a5b116 --- /dev/null +++ b/test/Core.Tests/Connectivity/NetworkStateChangedEventTests.cs @@ -0,0 +1,74 @@ +using FluentAssertions; +using Xunit; + +namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; + +public class NetworkStateChangedEventTests +{ + [Theory] + [InlineData(NetworkConnection.Bluetooth)] + [InlineData(NetworkConnection.Ethernet)] + [InlineData(NetworkConnection.Cellular)] + [InlineData(NetworkConnection.WiFi)] + public void GivenValidProfile_WhenHasValidProfile_ThenResultTrue(NetworkConnection profile) + { + // Given, When + NetworkStateChangedEvent sut = new NetworkStateChangedEventFixture().WithProfiles(profile); + + // Then + sut + .HasValidConnection() + .Should() + .BeTrue(); + } + + [Theory] + [InlineData(NetworkConnection.Unknown)] + public void GivenValidProfile_WhenHasValidProfile_ThenResultFalse(NetworkConnection profile) + { + // Given, When + NetworkStateChangedEvent sut = new NetworkStateChangedEventFixture().WithProfiles(profile); + + // Then + sut + .HasValidConnection() + .Should() + .BeFalse(); + } + + [Fact] + public void GivenDefaultEventArg_WhenHasAccess_ThenResultTrue() + { + // Given, When + NetworkStateChangedEvent sut = new NetworkStateChangedEventFixture().WithDefault(); + + // Then + sut.HasSignal() + .Should() + .BeTrue(); + } + + [Fact] + public void GivenDefaultEventArg_WhenToString_ThenResultCorrect() + { + // Given, When + NetworkStateChangedEvent sut = new NetworkStateChangedEventFixture().WithDefault(); + + // Then + sut.ToString() + .Should() + .Be("Access: Internet, Connections: [Bluetooth, Ethernet, WiFi]"); + } + + [Fact] + public void GivenDefaultEventArg_WhenDegraded_ThenResultTrue() + { + // Given, When + NetworkStateChangedEvent sut = new NetworkStateChangedEventFixture().WithProfiles(NetworkConnection.Unknown); + + // Then + sut.Degraded() + .Should() + .BeTrue(); + } +} \ No newline at end of file diff --git a/test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs b/test/Core.Tests/Connectivity/NetworkStateDefaultInterfaceTests.cs similarity index 84% rename from test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs rename to test/Core.Tests/Connectivity/NetworkStateDefaultInterfaceTests.cs index 4cc2e668a..979900b32 100644 --- a/test/Core.Tests/Connectivity/ConnectivityInterfaceTests.cs +++ b/test/Core.Tests/Connectivity/NetworkStateDefaultInterfaceTests.cs @@ -1,17 +1,16 @@ using FluentAssertions; -using Rocket.Surgery.Airframe.Connectivity; using System; using Xunit; namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; -public class ConnectivityInterfaceTests +public class NetworkStateDefaultInterfaceTests { [Theory] [InlineData(NetworkAccess.Internet)] [InlineData(NetworkAccess.Local)] [InlineData(NetworkAccess.ConstrainedInternet)] - public void GivenImplementation_WhenConnectivityChanged_ThenHasSignal(NetworkAccess access) + public void GivenImplementation_WhenNetworkStateChanged_ThenHasSignal(NetworkAccess access) { // Given var sut = new NetworkStateMock(); @@ -19,7 +18,7 @@ public void GivenImplementation_WhenConnectivityChanged_ThenHasSignal(NetworkAcc using var _ = sut.As().HasSignal().Subscribe(actual => result = actual); // When - sut.Notify(new NetworkStateChangedEvent(access, ConnectionProfile.WiFi)); + sut.Notify(new NetworkStateChangedEvent(access, NetworkConnection.WiFi)); // Then result @@ -34,7 +33,7 @@ public void GivenImplementation_WhenConnectivityChanged_ThenHasSignal(NetworkAcc [Theory] [InlineData(NetworkAccess.None)] [InlineData(NetworkAccess.Unknown)] - public void GivenImplementation_WhenConnectivityChanged_ThenHasNoSignal(NetworkAccess access) + public void GivenImplementation_WhenNetworkStateChanged_ThenHasNoSignal(NetworkAccess access) { // Given var sut = new NetworkStateMock(); @@ -58,7 +57,7 @@ public void GivenImplementation_WhenConnectivityChanged_ThenHasNoSignal(NetworkA [InlineData(NetworkAccess.Internet)] [InlineData(NetworkAccess.Local)] [InlineData(NetworkAccess.ConstrainedInternet)] - public void GivenImplementation_WhenConnectivityChanged_ThenSignalDegraded(NetworkAccess access) + public void GivenImplementation_WhenNetworkStateChanged_ThenSignalDegraded(NetworkAccess access) { // Given var sut = new NetworkStateMock(); @@ -81,7 +80,7 @@ public void GivenImplementation_WhenConnectivityChanged_ThenSignalDegraded(Netwo [Theory] [InlineData(NetworkAccess.None)] [InlineData(NetworkAccess.Unknown)] - public void GivenImplementation_WhenConnectivityChanged_ThenSignalNotDegraded(NetworkAccess access) + public void GivenImplementation_WhenNetworkStateChanged_ThenSignalNotDegraded(NetworkAccess access) { // Given var sut = new NetworkStateMock(); diff --git a/test/Core.Tests/Connectivity/NetworkStateMock.cs b/test/Core.Tests/Connectivity/NetworkStateMock.cs index b15154e9c..9678a957a 100644 --- a/test/Core.Tests/Connectivity/NetworkStateMock.cs +++ b/test/Core.Tests/Connectivity/NetworkStateMock.cs @@ -1,7 +1,5 @@ -using Rocket.Surgery.Airframe.Connectivity; using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Subjects; namespace Rocket.Surgery.Airframe.Core.Tests.Connectivity; @@ -10,13 +8,12 @@ internal class NetworkStateMock : INetworkState { public NetworkAccess NetworkAccess { get; } = NetworkAccess.Internet; - public IReadOnlyList Profiles { get; } = new[] { ConnectionProfile.WiFi }; + public IReadOnlyList Profiles { get; } = new[] { NetworkConnection.WiFi }; - public IObservable ConnectivityChanged => _connectivity.AsObservable(); + public void Notify(NetworkStateChangedEvent networkStateChangedEvent) => _networkState.OnNext(networkStateChangedEvent); - public void Notify(NetworkStateChangedEvent networkStateChangedEvent) => _connectivity.OnNext(networkStateChangedEvent); + /// + public IDisposable Subscribe(IObserver observer) => _networkState.Subscribe(observer); - public IDisposable Subscribe(IObserver observer) => _connectivity.Subscribe(observer); - - private readonly Subject _connectivity = new Subject(); + private readonly Subject _networkState = new Subject(); } \ No newline at end of file diff --git a/test/Core.Tests/LoggerMock.cs b/test/Core.Tests/LoggerMock.cs index 741c894e5..a5c18f9b3 100644 --- a/test/Core.Tests/LoggerMock.cs +++ b/test/Core.Tests/LoggerMock.cs @@ -6,29 +6,28 @@ [assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312:Variable names should begin with lower-case letter", Justification = "Discarded variable.")] -namespace Rocket.Surgery.Airframe.Core.Tests +namespace Rocket.Surgery.Airframe.Core.Tests; + +internal class LoggerMock : ILogger { - internal class LoggerMock : ILogger - { - private readonly ITestOutputHelper _testOutputHelper; + private readonly ITestOutputHelper _testOutputHelper; - /// - /// Initializes a new instance of the class. - /// - /// The test output. - public LoggerMock(ITestOutputHelper testOutputHelper) => _testOutputHelper = testOutputHelper; + /// + /// Initializes a new instance of the class. + /// + /// The test output. + public LoggerMock(ITestOutputHelper testOutputHelper) => _testOutputHelper = testOutputHelper; - /// - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) => - LogToOutputHelper(eventId, state, exception, formatter); + /// + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) => + LogToOutputHelper(eventId, state, exception, formatter); - /// - public bool IsEnabled(LogLevel logLevel) => true; + /// + public bool IsEnabled(LogLevel logLevel) => true; - /// - public IDisposable BeginScope(TState state) => Disposable.Empty; + /// + public IDisposable BeginScope(TState state) => Disposable.Empty; - private void LogToOutputHelper(EventId eventId, TState state, Exception exception, Func formatter) => - _testOutputHelper.WriteLine(formatter(state, exception)); - } + private void LogToOutputHelper(EventId eventId, TState state, Exception exception, Func formatter) => + _testOutputHelper.WriteLine(formatter(state, exception)); } \ No newline at end of file diff --git a/test/Core.Tests/Operations/Startup/ApplicationStartupFixture.cs b/test/Core.Tests/Operations/Startup/ApplicationStartupFixture.cs index c97f65ee8..43700b140 100644 --- a/test/Core.Tests/Operations/Startup/ApplicationStartupFixture.cs +++ b/test/Core.Tests/Operations/Startup/ApplicationStartupFixture.cs @@ -4,20 +4,19 @@ using System.Collections.Generic; using System.Linq; -namespace Rocket.Surgery.Airframe.Core.Tests +namespace Rocket.Surgery.Airframe.Core.Tests; + +internal class ApplicationStartupFixture : ITestFixtureBuilder { - internal class ApplicationStartupFixture : ITestFixtureBuilder - { - private IEnumerable _startupOperations = Enumerable.Empty(); - private ILoggerFactory _loggerFactory = Substitute.For(); + private IEnumerable _startupOperations = Enumerable.Empty(); + private ILoggerFactory _loggerFactory = Substitute.For(); - public static implicit operator ApplicationStartup(ApplicationStartupFixture fixture) => fixture.Build(); + public static implicit operator ApplicationStartup(ApplicationStartupFixture fixture) => fixture.Build(); - public ApplicationStartupFixture WithStartupOperations(params StartupOperationBase[] startupOperations) - => this.With(ref _startupOperations, startupOperations); + public ApplicationStartupFixture WithStartupOperations(params StartupOperationBase[] startupOperations) + => this.With(ref _startupOperations, startupOperations); - public IApplicationStartup AsInterface() => Build(); + public IApplicationStartup AsInterface() => Build(); - private ApplicationStartup Build() => new(_loggerFactory, _startupOperations); - } + private ApplicationStartup Build() => new(_loggerFactory, _startupOperations); } \ No newline at end of file diff --git a/test/Core.Tests/Operations/Startup/ApplicationStartupTest.cs b/test/Core.Tests/Operations/Startup/ApplicationStartupTest.cs index 34ca3439a..b1a9aea53 100644 --- a/test/Core.Tests/Operations/Startup/ApplicationStartupTest.cs +++ b/test/Core.Tests/Operations/Startup/ApplicationStartupTest.cs @@ -5,94 +5,93 @@ using System.Reactive; using Xunit; -namespace Rocket.Surgery.Airframe.Core.Tests +namespace Rocket.Surgery.Airframe.Core.Tests; + +public class ApplicationStartupTest { - public class ApplicationStartupTest + [Fact] + public void GivenOperation_WhenStartupComplete_ThenCompletionRecieved() + { + // Given + Unit? result = null; + var testScheduler = new TestScheduler(); + var sut = + new ApplicationStartupFixture() + .WithStartupOperations(new ScheduledTestOperation(testScheduler, TimeSpan.FromSeconds(3))) + .AsInterface(); + + // When + using var _ = + sut.Startup() + .Subscribe(unit => + { + // Then + result = unit; + }); + testScheduler.AdvanceByMs(1000); + + // Then + result.Should().BeNull(); + testScheduler.AdvanceByMs(2001); + result.Should().NotBeNull(); + } + + [Fact] + public void GivenOperationCannotExecute_WhenStartup_ThenNotExecuted() { - [Fact] - public void GivenOperation_WhenStartupComplete_ThenCompletionRecieved() - { - // Given - Unit? result = null; - var testScheduler = new TestScheduler(); - var sut = - new ApplicationStartupFixture() - .WithStartupOperations(new ScheduledTestOperation(testScheduler, TimeSpan.FromSeconds(3))) - .AsInterface(); - - // When - using var _ = - sut.Startup() - .Subscribe(unit => - { - // Then - result = unit; - }); - testScheduler.AdvanceByMs(1000); - - // Then - result.Should().BeNull(); - testScheduler.AdvanceByMs(2001); - result.Should().NotBeNull(); - } - - [Fact] - public void GivenOperationCannotExecute_WhenStartup_ThenNotExecuted() - { - // Given - var testOperation = new TestOperation(false); - var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); - - // When - using var _ = sut.Startup().Subscribe(); - - // Then - testOperation.Executed.Should().BeFalse(); - } - - [Fact] - public void GivenOperationCanExecute_WhenStartup_ThenExecuted() - { - // Given - var testOperation = new TestOperation(); - var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); - - // When - using var _ = sut.Startup().Subscribe(); - - // Then - testOperation.Executed.Should().BeTrue(); - } - - [Fact] - public void GivenScheduler_WhenStartup_ThenExecuted() - { - // Given - var testScheduler = new TestScheduler(); - var testOperation = new TestOperation(); - var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); - using var _ = sut.Startup(1, testScheduler).Subscribe(); - - // When - testScheduler.Start(); - - // Then - testOperation.Executed.Should().BeTrue(); - } - - [Fact] - public void GivenScheduler_WhenStartup_ThenNotExecuted() - { - // Given - var testScheduler = new TestScheduler(); - var testOperation = new TestOperation(); - var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); - - // When - using var _ = sut.Startup(1, testScheduler).Subscribe(); - - // Then - testOperation.Executed.Should().BeFalse(); - } + // Given + var testOperation = new TestOperation(false); + var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); + + // When + using var _ = sut.Startup().Subscribe(); + + // Then + testOperation.Executed.Should().BeFalse(); + } + + [Fact] + public void GivenOperationCanExecute_WhenStartup_ThenExecuted() + { + // Given + var testOperation = new TestOperation(); + var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); + + // When + using var _ = sut.Startup().Subscribe(); + + // Then + testOperation.Executed.Should().BeTrue(); + } + + [Fact] + public void GivenScheduler_WhenStartup_ThenExecuted() + { + // Given + var testScheduler = new TestScheduler(); + var testOperation = new TestOperation(); + var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); + using var _ = sut.Startup(1, testScheduler).Subscribe(); + + // When + testScheduler.Start(); + + // Then + testOperation.Executed.Should().BeTrue(); + } + + [Fact] + public void GivenScheduler_WhenStartup_ThenNotExecuted() + { + // Given + var testScheduler = new TestScheduler(); + var testOperation = new TestOperation(); + var sut = new ApplicationStartupFixture().WithStartupOperations(testOperation).AsInterface(); + + // When + using var _ = sut.Startup(1, testScheduler).Subscribe(); + + // Then + testOperation.Executed.Should().BeFalse(); } } \ No newline at end of file diff --git a/test/Core.Tests/Operations/Startup/OperationTests.cs b/test/Core.Tests/Operations/Startup/OperationTests.cs index 2adcbd31e..77ca529fb 100644 --- a/test/Core.Tests/Operations/Startup/OperationTests.cs +++ b/test/Core.Tests/Operations/Startup/OperationTests.cs @@ -2,47 +2,46 @@ using System; using Xunit; -namespace Rocket.Surgery.Airframe.Core.Tests +namespace Rocket.Surgery.Airframe.Core.Tests; + +public class OperationTests { - public class OperationTests + [Theory] + [InlineData(true)] + [InlineData(false)] + public void CanExecute(bool canExecute) => + + // Given, When, Then + new TestOperationFixture() + .WithCanExecute(canExecute) + .AsOperation() + .CanExecute() + .Should() + .Be(canExecute); + + [Fact] + public void GivenOperation_WhenExecute_ThenExecuted() + { + // Given + var operation = new TestOperationFixture().AsOperation(); + + // When + using var _ = operation.Execute().Subscribe(); + + // Then + operation.As().Executed.Should().BeTrue(); + } + + [Fact] + public void GivenStartupOperation_WhenExecute_ThenExecuted() { - [Theory] - [InlineData(true)] - [InlineData(false)] - public void CanExecute(bool canExecute) => - - // Given, When, Then - new TestOperationFixture() - .WithCanExecute(canExecute) - .AsOperation() - .CanExecute() - .Should() - .Be(canExecute); - - [Fact] - public void GivenOperation_WhenExecute_ThenExecuted() - { - // Given - var operation = new TestOperationFixture().AsOperation(); - - // When - using var _ = operation.Execute().Subscribe(); - - // Then - operation.As().Executed.Should().BeTrue(); - } - - [Fact] - public void GivenStartupOperation_WhenExecute_ThenExecuted() - { - // Given - var operation = new TestOperationFixture().AsStartupOperation(); - - // When - using var _ = operation.Start().Subscribe(); - - // Then - operation.As().Executed.Should().BeTrue(); - } + // Given + var operation = new TestOperationFixture().AsStartupOperation(); + + // When + using var _ = operation.Start().Subscribe(); + + // Then + operation.As().Executed.Should().BeTrue(); } } \ No newline at end of file diff --git a/test/Core.Tests/Operations/Startup/ScheduledTestOperation.cs b/test/Core.Tests/Operations/Startup/ScheduledTestOperation.cs index 68cf41be2..f97411c08 100644 --- a/test/Core.Tests/Operations/Startup/ScheduledTestOperation.cs +++ b/test/Core.Tests/Operations/Startup/ScheduledTestOperation.cs @@ -3,27 +3,26 @@ using System.Reactive.Concurrency; using System.Reactive.Linq; -namespace Rocket.Surgery.Airframe.Core.Tests -{ - internal class ScheduledTestOperation : TestOperation - { - private readonly IScheduler _scheduler; - private readonly TimeSpan _delay; +namespace Rocket.Surgery.Airframe.Core.Tests; - /// - /// Initializes a new instance of the class. - /// - /// The scheduler. - /// The delay. - /// Whether the instance can execute. - public ScheduledTestOperation(IScheduler scheduler, TimeSpan delay, bool canExecute = true) - : base(canExecute) - { - _scheduler = scheduler; - _delay = delay; - } +internal class ScheduledTestOperation : TestOperation +{ + private readonly IScheduler _scheduler; + private readonly TimeSpan _delay; - /// - protected override IObservable Start() => Observable.Return(Unit.Default).Delay(_delay, _scheduler).Finally(() => Executed = true); + /// + /// Initializes a new instance of the class. + /// + /// The scheduler. + /// The delay. + /// Whether the instance can execute. + public ScheduledTestOperation(IScheduler scheduler, TimeSpan delay, bool canExecute = true) + : base(canExecute) + { + _scheduler = scheduler; + _delay = delay; } + + /// + protected override IObservable Start() => Observable.Return(Unit.Default).Delay(_delay, _scheduler).Finally(() => Executed = true); } \ No newline at end of file diff --git a/test/Core.Tests/Operations/Startup/TestOperation.cs b/test/Core.Tests/Operations/Startup/TestOperation.cs index a2522dfa0..8646c6434 100644 --- a/test/Core.Tests/Operations/Startup/TestOperation.cs +++ b/test/Core.Tests/Operations/Startup/TestOperation.cs @@ -2,24 +2,23 @@ using System.Reactive; using System.Reactive.Linq; -namespace Rocket.Surgery.Airframe.Core.Tests +namespace Rocket.Surgery.Airframe.Core.Tests; + +internal class TestOperation : StartupOperationBase { - internal class TestOperation : StartupOperationBase - { - private readonly bool _canExecute; + private readonly bool _canExecute; - /// - /// Initializes a new instance of the class. - /// - /// Whether this instance can execute. - public TestOperation(bool canExecute = true) => _canExecute = canExecute; + /// + /// Initializes a new instance of the class. + /// + /// Whether this instance can execute. + public TestOperation(bool canExecute = true) => _canExecute = canExecute; - public bool Executed { get; protected set; } + public bool Executed { get; protected set; } - /// - protected override IObservable Start() => Observable.Return(Unit.Default).Finally(() => Executed = true); + /// + protected override IObservable Start() => Observable.Return(Unit.Default).Finally(() => Executed = true); - /// - protected override bool CanExecute() => _canExecute; - } + /// + protected override bool CanExecute() => _canExecute; } \ No newline at end of file diff --git a/test/Core.Tests/Operations/Startup/TestOperationFixture.cs b/test/Core.Tests/Operations/Startup/TestOperationFixture.cs index 67e835541..d2edf7396 100644 --- a/test/Core.Tests/Operations/Startup/TestOperationFixture.cs +++ b/test/Core.Tests/Operations/Startup/TestOperationFixture.cs @@ -1,19 +1,18 @@ using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Rocket.Surgery.Airframe.Core.Tests +namespace Rocket.Surgery.Airframe.Core.Tests; + +internal sealed class TestOperationFixture : ITestFixtureBuilder { - internal sealed class TestOperationFixture : ITestFixtureBuilder - { - private bool _canExecute = true; + private bool _canExecute = true; - public static implicit operator TestOperation(TestOperationFixture fixture) => fixture.Build(); + public static implicit operator TestOperation(TestOperationFixture fixture) => fixture.Build(); - public TestOperationFixture WithCanExecute(bool canExecute) => this.With(ref _canExecute, canExecute); + public TestOperationFixture WithCanExecute(bool canExecute) => this.With(ref _canExecute, canExecute); - public IOperation AsOperation() => Build(); + public IOperation AsOperation() => Build(); - public IStartupOperation AsStartupOperation() => Build(); + public IStartupOperation AsStartupOperation() => Build(); - private TestOperation Build() => new(_canExecute); - } + private TestOperation Build() => new(_canExecute); } \ No newline at end of file diff --git a/test/Data.Tests/DuckGo/DuckDuckGoFunctionTests.cs b/test/Data.Tests/DuckGo/DuckDuckGoFunctionTests.cs index 5f9f6f9b2..26fb73a49 100644 --- a/test/Data.Tests/DuckGo/DuckDuckGoFunctionTests.cs +++ b/test/Data.Tests/DuckGo/DuckDuckGoFunctionTests.cs @@ -6,19 +6,19 @@ using System.Reactive.Linq; using Xunit; -namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo +namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo; + +public class DuckDuckGoFunctionTests { - public class DuckDuckGoFunctionTests + [Fact] + public void Should_Return_ChangeSet() { - [Fact] - public void Should_Return_ChangeSet() - { - // Given - using var sourceCache = new SourceCache(topic => topic.FirstUrl); + // Given + using var sourceCache = new SourceCache(topic => topic.FirstUrl); - // When - using var disposable = - Observable.Return( + // When + using var disposable = + Observable.Return( new List { new() @@ -32,29 +32,29 @@ public void Should_Return_ChangeSet() .Bind(out var result) .Subscribe(); - // Then - result - .Should() - .HaveCount(1); - } + // Then + result + .Should() + .HaveCount(1); + } - [Fact] - public void Should_Return_Cached() - { - // Given - using var sourceCache = new SourceCache(topic => topic.FirstUrl); - var firstResultGuid = Guid.NewGuid().ToString(); - sourceCache.AddOrUpdate( - new RelatedTopic - { - FirstUrl = firstResultGuid, - Result = "result one", - Text = "text", - }); + [Fact] + public void Should_Return_Cached() + { + // Given + using var sourceCache = new SourceCache(topic => topic.FirstUrl); + var firstResultGuid = Guid.NewGuid().ToString(); + sourceCache.AddOrUpdate( + new RelatedTopic + { + FirstUrl = firstResultGuid, + Result = "result one", + Text = "text", + }); - // When - using var disposable = - Observable.Return( + // When + using var disposable = + Observable.Return( new List { new() @@ -74,28 +74,28 @@ public void Should_Return_Cached() .Bind(out var result) .Subscribe(); - // Then - result - .Should() - .HaveCount(2); - } + // Then + result + .Should() + .HaveCount(2); + } - [Fact] - public void Should_Clear_Cached() - { - // Given - using var sourceCache = new SourceCache(topic => topic.FirstUrl); - sourceCache.AddOrUpdate( - new RelatedTopic - { - FirstUrl = Guid.NewGuid().ToString(), - Result = "result one", - Text = "text", - }); + [Fact] + public void Should_Clear_Cached() + { + // Given + using var sourceCache = new SourceCache(topic => topic.FirstUrl); + sourceCache.AddOrUpdate( + new RelatedTopic + { + FirstUrl = Guid.NewGuid().ToString(), + Result = "result one", + Text = "text", + }); - // When - using var disposable = - Observable.Return( + // When + using var disposable = + Observable.Return( new List { new() @@ -109,10 +109,9 @@ public void Should_Clear_Cached() .Bind(out var result) .Subscribe(); - // Then - result - .Should() - .ContainSingle(topic => topic.Result == "result two"); - } + // Then + result + .Should() + .ContainSingle(topic => topic.Result == "result two"); } } \ No newline at end of file diff --git a/test/Data.Tests/DuckGo/DuckDuckGoServiceFixture.cs b/test/Data.Tests/DuckGo/DuckDuckGoServiceFixture.cs index 75141dc61..0a535cafc 100644 --- a/test/Data.Tests/DuckGo/DuckDuckGoServiceFixture.cs +++ b/test/Data.Tests/DuckGo/DuckDuckGoServiceFixture.cs @@ -2,16 +2,15 @@ using Rocket.Surgery.Airframe.Data.DuckDuckGo; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo +namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo; + +internal class DuckDuckGoServiceFixture : ITestFixtureBuilder { - internal class DuckDuckGoServiceFixture : ITestFixtureBuilder - { - public static implicit operator DuckDuckGoService(DuckDuckGoServiceFixture fixture) => fixture.Build(); + public static implicit operator DuckDuckGoService(DuckDuckGoServiceFixture fixture) => fixture.Build(); - public DuckDuckGoServiceFixture WithClient(IDuckDuckGoApiClient client) => this.With(ref _client, client); + public DuckDuckGoServiceFixture WithClient(IDuckDuckGoApiClient client) => this.With(ref _client, client); - private DuckDuckGoService Build() => new(_client); + private DuckDuckGoService Build() => new(_client); - private IDuckDuckGoApiClient _client = Substitute.For(); - } + private IDuckDuckGoApiClient _client = Substitute.For(); } \ No newline at end of file diff --git a/test/Data.Tests/DuckGo/DuckDuckGoServiceTests.cs b/test/Data.Tests/DuckGo/DuckDuckGoServiceTests.cs index 08aacffd5..871e17c98 100644 --- a/test/Data.Tests/DuckGo/DuckDuckGoServiceTests.cs +++ b/test/Data.Tests/DuckGo/DuckDuckGoServiceTests.cs @@ -7,38 +7,37 @@ using System.Reactive.Linq; using Xunit; -namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo +namespace Rocket.Surgery.Airframe.Data.Tests.DuckGo; + +public class DuckDuckGoServiceTests { - public class DuckDuckGoServiceTests + [Fact] + public void Should_Return_Query_Results() { - [Fact] - public void Should_Return_Query_Results() - { - // Given - var client = Substitute.For(); - client.Search(Arg.Any()).Returns( - Observable.Return( - new SearchResult + // Given + var client = Substitute.For(); + client.Search(Arg.Any()).Returns( + Observable.Return( + new SearchResult + { + RelatedTopics = new List { - RelatedTopics = new List + new() { - new() - { - FirstUrl = Guid.NewGuid().ToString(), - Result = "result one", - Text = "text", - }, + FirstUrl = Guid.NewGuid().ToString(), + Result = "result one", + Text = "text", }, - })); - DuckDuckGoService sut = new DuckDuckGoServiceFixture().WithClient(client); + }, + })); + DuckDuckGoService sut = new DuckDuckGoServiceFixture().WithClient(client); - // When - sut.Query(string.Empty) - .Bind(out var results) - .Subscribe(); + // When + sut.Query(string.Empty) + .Bind(out var results) + .Subscribe(); - // Then - results.Should().NotBeEmpty(); - } + // Then + results.Should().NotBeEmpty(); } } \ No newline at end of file diff --git a/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeApiClientMock.cs b/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeApiClientMock.cs index 2e96e12d9..034bd5d84 100644 --- a/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeApiClientMock.cs +++ b/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeApiClientMock.cs @@ -4,36 +4,35 @@ using System.Reactive.Linq; using System.Reactive.Subjects; -namespace Rocket.Surgery.Airframe.Data.Tests.Jokes.ChuckNorris +namespace Rocket.Surgery.Airframe.Data.Tests.Jokes.ChuckNorris; + +public class ChuckNorrisJokeApiClientMock : IChuckNorrisJokeApiClient { - public class ChuckNorrisJokeApiClientMock : IChuckNorrisJokeApiClient - { - private readonly IObservable> _jokeClient; - private Subject> _jokes = new Subject>(); - - /// - /// Initializes a new instance of the class. - /// - public ChuckNorrisJokeApiClientMock() => _jokeClient = _jokes.AsObservable(); - - /// - public IObservable Random() => - Observable.Create(observer => _jokes.SelectMany(jokes => jokes).Subscribe(observer)); - - /// - public IObservable> RandomFromCategory(string category) => - Observable.Create>(observer => - _jokes.Select(jokes => - jokes.Where(x => x.Categories.Contains(category))) - .Subscribe(observer)); - - /// - public IObservable> Categories() => null; - - /// - public IObservable> Search(string query) => - Observable.Create>(observer => _jokes.Subscribe(observer)); - - public void Notify(params ChuckNorrisJoke[] jokes) => _jokes.OnNext(jokes); - } + private readonly IObservable> _jokeClient; + private Subject> _jokes = new Subject>(); + + /// + /// Initializes a new instance of the class. + /// + public ChuckNorrisJokeApiClientMock() => _jokeClient = _jokes.AsObservable(); + + /// + public IObservable Random() => + Observable.Create(observer => _jokes.SelectMany(jokes => jokes).Subscribe(observer)); + + /// + public IObservable> RandomFromCategory(string category) => + Observable.Create>(observer => + _jokes.Select(jokes => + jokes.Where(x => x.Categories.Contains(category))) + .Subscribe(observer)); + + /// + public IObservable> Categories() => null; + + /// + public IObservable> Search(string query) => + Observable.Create>(observer => _jokes.Subscribe(observer)); + + public void Notify(params ChuckNorrisJoke[] jokes) => _jokes.OnNext(jokes); } \ No newline at end of file diff --git a/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeServiceTests.cs b/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeServiceTests.cs index 149b91255..18e206c6c 100644 --- a/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeServiceTests.cs +++ b/test/Data.Tests/Jokes/ChuckNorris/ChuckNorrisJokeServiceTests.cs @@ -8,117 +8,116 @@ using System.Linq; using Xunit; -namespace Rocket.Surgery.Airframe.Data.Tests.Jokes.ChuckNorris +namespace Rocket.Surgery.Airframe.Data.Tests.Jokes.ChuckNorris; + +[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312:Variable names should begin with lower-case letter", Justification = "Discarded variable.")] +public class ChuckNorrisJokeServiceTests { - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312:Variable names should begin with lower-case letter", Justification = "Discarded variable.")] - public class ChuckNorrisJokeServiceTests + [Fact] + public void GivenApiClient_WhenRandom_ThenChuckNorrisJokeReturned() { - [Fact] - public void GivenApiClient_WhenRandom_ThenChuckNorrisJokeReturned() - { - // Given - var client = new ChuckNorrisJokeApiClientMock(); - ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); - ChuckNorrisJoke? result = null; - using var _ = sut.Random().Subscribe(next => result = next); - - // When - client.Notify(new ChuckNorrisJoke() { Id = Guid.NewGuid().ToString() }); - - // Then - result - .Should() - .NotBeNull() - .And - .BeOfType(); - } - - [Theory] - [ClassData(typeof(CategoryTests))] - public void GivenApiClient_WhenRandomFromCategory_ThenChuckNorrisJokeReturned(IEnumerable include, IEnumerable exclude) - { - // Given - var client = new ChuckNorrisJokeApiClientMock(); - ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); - ChuckNorrisJoke? result = null; - var categories = include.ToArray(); - using var _ = sut.Random(categories).Subscribe(next => result = next); - - // When - client.Notify(new ChuckNorrisJoke { Id = Guid.NewGuid().ToString(), Categories = categories }); - - // Then - result - .Should() - .NotBeNull() - .And - .BeOfType(); - } - - [Theory] - [ClassData(typeof(CategoryTests))] - public void GivenJokeWithCategory_WhenRandomFromCategory_ThenNothingReturned(IEnumerable include, IEnumerable exclude) - { - // Given - var client = new ChuckNorrisJokeApiClientMock(); - ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); - ChuckNorrisJoke? result = null; - var categories = include.ToArray(); - using var _ = sut.Random(exclude.ToArray()).Subscribe(next => result = next); - - // When - client.Notify(new ChuckNorrisJoke { Id = Guid.NewGuid().ToString(), Categories = categories }); - - // Then - result - .Should() - .BeNull(); - } - - [Theory] - [ClassData(typeof(CategoryTests))] - public void GivenJokeWithoutCategory_WhenRandomFromCategory_ThenNothingReturned(IEnumerable include, IEnumerable exclude) - { - // Given - var client = new ChuckNorrisJokeApiClientMock(); - ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); - ChuckNorrisJoke? result = null; - var categories = exclude.ToArray(); - using var _ = sut.Random(include.ToArray()).Subscribe(next => result = next); - - // When - client.Notify(new ChuckNorrisJoke { Id = Guid.NewGuid().ToString(), Categories = categories }); - - // Then - result - .Should() - .BeNull(); - } + // Given + var client = new ChuckNorrisJokeApiClientMock(); + ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); + ChuckNorrisJoke? result = null; + using var _ = sut.Random().Subscribe(next => result = next); + + // When + client.Notify(new ChuckNorrisJoke() { Id = Guid.NewGuid().ToString() }); + + // Then + result + .Should() + .NotBeNull() + .And + .BeOfType(); } - internal sealed class ChuckNorrisJokeServiceFixture : ITestFixtureBuilder + [Theory] + [ClassData(typeof(CategoryTests))] + public void GivenApiClient_WhenRandomFromCategory_ThenChuckNorrisJokeReturned(IEnumerable include, IEnumerable exclude) { - public static implicit operator ChuckNorrisJokeService(ChuckNorrisJokeServiceFixture fixture) => fixture.Build(); - - public ChuckNorrisJokeServiceFixture WithApiClient(IChuckNorrisJokeApiClient client) => this.With(ref _chuckNorrisJokeApiClient, client); - - private ChuckNorrisJokeService Build() => new ChuckNorrisJokeService(_chuckNorrisJokeApiClient); + // Given + var client = new ChuckNorrisJokeApiClientMock(); + ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); + ChuckNorrisJoke? result = null; + var categories = include.ToArray(); + using var _ = sut.Random(categories).Subscribe(next => result = next); + + // When + client.Notify(new ChuckNorrisJoke { Id = Guid.NewGuid().ToString(), Categories = categories }); + + // Then + result + .Should() + .NotBeNull() + .And + .BeOfType(); + } - private IChuckNorrisJokeApiClient _chuckNorrisJokeApiClient = Substitute.For(); + [Theory] + [ClassData(typeof(CategoryTests))] + public void GivenJokeWithCategory_WhenRandomFromCategory_ThenNothingReturned(IEnumerable include, IEnumerable exclude) + { + // Given + var client = new ChuckNorrisJokeApiClientMock(); + ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); + ChuckNorrisJoke? result = null; + var categories = include.ToArray(); + using var _ = sut.Random(exclude.ToArray()).Subscribe(next => result = next); + + // When + client.Notify(new ChuckNorrisJoke { Id = Guid.NewGuid().ToString(), Categories = categories }); + + // Then + result + .Should() + .BeNull(); } - internal class CategoryTests : IEnumerable + [Theory] + [ClassData(typeof(CategoryTests))] + public void GivenJokeWithoutCategory_WhenRandomFromCategory_ThenNothingReturned(IEnumerable include, IEnumerable exclude) { - private readonly IEnumerable _exclude = new[] { "One Fish", "Two Fish" }; - private readonly IEnumerable _include = new[] { "Red Fish", "Blue Fish" }; + // Given + var client = new ChuckNorrisJokeApiClientMock(); + ChuckNorrisJokeService sut = new ChuckNorrisJokeServiceFixture().WithApiClient(client); + ChuckNorrisJoke? result = null; + var categories = exclude.ToArray(); + using var _ = sut.Random(include.ToArray()).Subscribe(next => result = next); + + // When + client.Notify(new ChuckNorrisJoke { Id = Guid.NewGuid().ToString(), Categories = categories }); + + // Then + result + .Should() + .BeNull(); + } +} + +internal sealed class ChuckNorrisJokeServiceFixture : ITestFixtureBuilder +{ + public static implicit operator ChuckNorrisJokeService(ChuckNorrisJokeServiceFixture fixture) => fixture.Build(); + + public ChuckNorrisJokeServiceFixture WithApiClient(IChuckNorrisJokeApiClient client) => this.With(ref _chuckNorrisJokeApiClient, client); - /// - public IEnumerator GetEnumerator() - { - yield return new object[] { _include, _exclude }; - } + private ChuckNorrisJokeService Build() => new ChuckNorrisJokeService(_chuckNorrisJokeApiClient); - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + private IChuckNorrisJokeApiClient _chuckNorrisJokeApiClient = Substitute.For(); +} + +internal class CategoryTests : IEnumerable +{ + private readonly IEnumerable _exclude = new[] { "One Fish", "Two Fish" }; + private readonly IEnumerable _include = new[] { "Red Fish", "Blue Fish" }; + + /// + public IEnumerator GetEnumerator() + { + yield return new object[] { _include, _exclude }; } + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs index 098c2b233..07502caac 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorObject.cs @@ -1,7 +1,6 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; + +public class AncestorObject { - public class AncestorObject - { - public ParentObject Parent { get; set; } - } + public ParentObject Parent { get; set; } } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorOptionsTestData.cs index ed32f2843..469c2535a 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/AncestorOptionsTestData.cs @@ -4,31 +4,30 @@ using System.Collections; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; + +internal class AncestorOptionsTestData : IEnumerable { - internal class AncestorOptionsTestData : IEnumerable + /// + /// Initializes a new instance of the class. + /// + public AncestorOptionsTestData() { - /// - /// Initializes a new instance of the class. - /// - public AncestorOptionsTestData() - { - var serviceCollection = new ServiceCollection(); - _buildServiceProvider = serviceCollection - .ConfigureAppSettings(builder => builder.AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false)) - .ConfigureOptions() - .BuildServiceProvider(); - } + var serviceCollection = new ServiceCollection(); + _buildServiceProvider = serviceCollection + .ConfigureAppSettings(builder => builder.AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false)) + .ConfigureOptions() + .BuildServiceProvider(); + } - /// - public IEnumerator GetEnumerator() - { - yield return new object[] { _buildServiceProvider }; - } + /// + public IEnumerator GetEnumerator() + { + yield return new object[] { _buildServiceProvider }; + } - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - private readonly IServiceProvider _buildServiceProvider; - } + private readonly IServiceProvider _buildServiceProvider; } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs index b478760e0..e95924a26 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexObject.cs @@ -1,7 +1,6 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; + +public class ComplexObject { - public class ComplexObject - { - public string Thing { get; set; } - } + public string Thing { get; set; } } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs index 435f74271..b2c5eb311 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ComplexSettings.cs @@ -1,11 +1,10 @@ using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; + +public class ComplexSettings { - public class ComplexSettings - { - public FlatSettings Flat { get; set; } + public FlatSettings Flat { get; set; } - public LevelSettings Levels { get; set; } - } + public LevelSettings Levels { get; set; } } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs index f4f94f2ac..6a6fcdac0 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/LevelSettings.cs @@ -1,7 +1,6 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; + +public class LevelSettings { - public class LevelSettings - { - public AncestorObject Generations { get; set; } - } + public AncestorObject Generations { get; set; } } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs index 94d0dd22b..e91cd9f33 100644 --- a/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs +++ b/test/MicrosoftDependencyInjection.Tests/ComplexOptions/ParentObject.cs @@ -1,7 +1,6 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; + +public class ParentObject { - public class ParentObject - { - public ComplexObject Complex { get; set; } - } + public ComplexObject Complex { get; set; } } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs b/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs index 024f32d78..86bdaafe1 100644 --- a/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/ConfigurationBuilderTestData.cs @@ -3,27 +3,26 @@ using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests -{ - internal class ConfigurationBuilderTestData : TestClassData - { - /// - /// Initializes a new instance of the class. - /// - public ConfigurationBuilderTestData() => _buildServiceProvider = new ServiceCollection() - .ConfigureBuilder( - builder => builder.AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false)) - .ConfigureOptions(option => option - .ConfigureOption()) - .ConfigureAppSettings() - .BuildServiceProvider(); +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests; - /// - protected override IEnumerator Enumerator() - { - yield return new object[] { _buildServiceProvider }; - } +internal class ConfigurationBuilderTestData : TestClassData +{ + /// + /// Initializes a new instance of the class. + /// + public ConfigurationBuilderTestData() => _buildServiceProvider = new ServiceCollection() + .ConfigureBuilder( + builder => builder.AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false)) + .ConfigureOptions(option => option + .ConfigureOption()) + .ConfigureAppSettings() + .BuildServiceProvider(); - private readonly ServiceProvider _buildServiceProvider; + /// + protected override IEnumerator Enumerator() + { + yield return new object[] { _buildServiceProvider }; } + + private readonly ServiceProvider _buildServiceProvider; } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs index 1352b1ae1..894205b86 100644 --- a/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/ConfigurationOptionsTestData.cs @@ -3,26 +3,25 @@ using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.ComplexOptions; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests -{ - internal class ConfigurationOptionsTestData : TestClassData - { - /// - /// Initializes a new instance of the class. - /// - public ConfigurationOptionsTestData() => _buildServiceProvider = new ServiceCollection() - .ConfigureSettings( - builder => builder.AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false), - option => option - .ConfigureOption()) - .BuildServiceProvider(); +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests; - /// - protected override IEnumerator Enumerator() - { - yield return new object[] { _buildServiceProvider }; - } +internal class ConfigurationOptionsTestData : TestClassData +{ + /// + /// Initializes a new instance of the class. + /// + public ConfigurationOptionsTestData() => _buildServiceProvider = new ServiceCollection() + .ConfigureSettings( + builder => builder.AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false), + option => option + .ConfigureOption()) + .BuildServiceProvider(); - private readonly ServiceProvider _buildServiceProvider; + /// + protected override IEnumerator Enumerator() + { + yield return new object[] { _buildServiceProvider }; } + + private readonly ServiceProvider _buildServiceProvider; } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/DefaultOptions/DefaultOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/DefaultOptions/DefaultOptionsTestData.cs index 2b0ebcbc4..83c9a4020 100644 --- a/test/MicrosoftDependencyInjection.Tests/DefaultOptions/DefaultOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/DefaultOptions/DefaultOptionsTestData.cs @@ -4,31 +4,30 @@ using System.Collections; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.DefaultOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.DefaultOptions; + +internal class DefaultOptionsTestData : IEnumerable { - internal class DefaultOptionsTestData : IEnumerable + /// + /// Initializes a new instance of the class. + /// + public DefaultOptionsTestData() { - /// - /// Initializes a new instance of the class. - /// - public DefaultOptionsTestData() - { - var serviceCollection = new ServiceCollection(); - _buildServiceProvider = serviceCollection - .ConfigureAppSettings(builder => builder.AddJsonFile("DefaultOptions/defaultoptions.json", optional: false)) - .ConfigureSectionAsOptions() - .BuildServiceProvider(); - } + var serviceCollection = new ServiceCollection(); + _buildServiceProvider = serviceCollection + .ConfigureAppSettings(builder => builder.AddJsonFile("DefaultOptions/defaultoptions.json", optional: false)) + .ConfigureSectionAsOptions() + .BuildServiceProvider(); + } - /// - public IEnumerator GetEnumerator() - { - yield return new object[] { _buildServiceProvider }; - } + /// + public IEnumerator GetEnumerator() + { + yield return new object[] { _buildServiceProvider }; + } - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - private readonly IServiceProvider _buildServiceProvider; - } + private readonly IServiceProvider _buildServiceProvider; } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatOptionsTestData.cs index e9734920b..cc9138d76 100644 --- a/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatOptionsTestData.cs @@ -3,24 +3,23 @@ using System; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions -{ - internal class FlatOptionsTestData : TestClassData - { - /// - /// Initializes a new instance of the class. - /// - public FlatOptionsTestData() => _buildServiceProvider = new ServiceCollection() - .ConfigureAppSettings(builder => builder.AddJsonFile("FlatOptions/flatsettings.json", optional: false)) - .ConfigureOptions() - .BuildServiceProvider(); +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions; - /// - protected override IEnumerator Enumerator() - { - yield return new object[] { _buildServiceProvider }; - } +internal class FlatOptionsTestData : TestClassData +{ + /// + /// Initializes a new instance of the class. + /// + public FlatOptionsTestData() => _buildServiceProvider = new ServiceCollection() + .ConfigureAppSettings(builder => builder.AddJsonFile("FlatOptions/flatsettings.json", optional: false)) + .ConfigureOptions() + .BuildServiceProvider(); - private readonly IServiceProvider _buildServiceProvider; + /// + protected override IEnumerator Enumerator() + { + yield return new object[] { _buildServiceProvider }; } + + private readonly IServiceProvider _buildServiceProvider; } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatSettings.cs b/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatSettings.cs index 65579e427..4a1ca6d4d 100644 --- a/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatSettings.cs +++ b/test/MicrosoftDependencyInjection.Tests/FlatOptions/FlatSettings.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions; + +public class FlatSettings { - public class FlatSettings - { - public string Stuff { get; set; } + public string Stuff { get; set; } - public string Things { get; set; } - } + public string Things { get; set; } } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs b/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs index df8103085..9df211c88 100644 --- a/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs +++ b/test/MicrosoftDependencyInjection.Tests/MultipleConfigurationOptionsTestData.cs @@ -4,31 +4,30 @@ using Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests.FlatOptions; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests -{ - internal class MultipleConfigurationOptionsTestData : TestClassData - { - /// - /// Initializes a new instance of the class. - /// - public MultipleConfigurationOptionsTestData() => _buildServiceProvider = new ServiceCollection() - .ConfigureSettings( - configuration => configuration - .AddJsonFile("DefaultOptions/defaultoptions.json", optional: false) - .AddJsonFile("FlatOptions/flatsettings.json", optional: false) - .AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false), - options => options - .ConfigureOption() - .ConfigureSection() - .ConfigureOption()) - .BuildServiceProvider(); +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests; - /// - protected override IEnumerator Enumerator() - { - yield return new object[] { _buildServiceProvider }; - } +internal class MultipleConfigurationOptionsTestData : TestClassData +{ + /// + /// Initializes a new instance of the class. + /// + public MultipleConfigurationOptionsTestData() => _buildServiceProvider = new ServiceCollection() + .ConfigureSettings( + configuration => configuration + .AddJsonFile("DefaultOptions/defaultoptions.json", optional: false) + .AddJsonFile("FlatOptions/flatsettings.json", optional: false) + .AddJsonFile("ComplexOptions/multilevelsettings.json", optional: false), + options => options + .ConfigureOption() + .ConfigureSection() + .ConfigureOption()) + .BuildServiceProvider(); - private readonly ServiceProvider _buildServiceProvider; + /// + protected override IEnumerator Enumerator() + { + yield return new object[] { _buildServiceProvider }; } + + private readonly ServiceProvider _buildServiceProvider; } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/OptionsTests.cs b/test/MicrosoftDependencyInjection.Tests/OptionsTests.cs index 137a52a42..a82c6b041 100644 --- a/test/MicrosoftDependencyInjection.Tests/OptionsTests.cs +++ b/test/MicrosoftDependencyInjection.Tests/OptionsTests.cs @@ -8,196 +8,195 @@ using System; using Xunit; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests; + +public class OptionsTests { - public class OptionsTests + [Theory] + [ClassData(typeof(DefaultOptionsTestData))] + public void GivenDefaultOptions_WhenGetOptions_ThenOptionsNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(DefaultOptionsTestData))] + public void GivenDefaultOptions_WhenGetOptions_ThenStuffHasValue(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Enabled + .Should() + .BeTrue(); + + [Theory] + [ClassData(typeof(FlatOptionsTestData))] + public void GivenFlatSettings_WhenGetOptions_ThenOptionsNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(FlatOptionsTestData))] + public void GivenFlatSettings_WhenGetOptions_ThenStuffHasValue(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Stuff + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(FlatOptionsTestData))] + public void GivenFlatSettings_WhenGetOptions_ThenThingsHasValue(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Things + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(AncestorOptionsTestData))] + public void GivenLevelSettings_WhenGetOptions_ThenOptionsNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(AncestorOptionsTestData))] + public void GivenLevelSettings_WhenGetOptions_ThenGenerationsNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Generations + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(AncestorOptionsTestData))] + public void GivenLevelSettings_WhenGetOptions_ThenParentNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Generations + .Parent + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(AncestorOptionsTestData))] + public void GivenLevelSettings_WhenGetOptions_ThenComplexNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Generations + .Parent + .Complex + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(AncestorOptionsTestData))] + public void GivenLevelSettings_WhenGetOptions_ThenThingNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Generations + .Parent + .Complex + .Thing + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(ConfigurationOptionsTestData))] + public void GivenUsedConfigurationOptions_WhenGetOptions_ThenThingNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Generations + .Parent + .Complex + .Thing + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(MultipleConfigurationOptionsTestData))] + public void GivenMultipleConfigurationSources_WhenGetOptions_ThenThingNotNull(IServiceProvider serviceProvider) { - [Theory] - [ClassData(typeof(DefaultOptionsTestData))] - public void GivenDefaultOptions_WhenGetOptions_ThenOptionsNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(DefaultOptionsTestData))] - public void GivenDefaultOptions_WhenGetOptions_ThenStuffHasValue(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Enabled - .Should() - .BeTrue(); - - [Theory] - [ClassData(typeof(FlatOptionsTestData))] - public void GivenFlatSettings_WhenGetOptions_ThenOptionsNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(FlatOptionsTestData))] - public void GivenFlatSettings_WhenGetOptions_ThenStuffHasValue(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Stuff - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(FlatOptionsTestData))] - public void GivenFlatSettings_WhenGetOptions_ThenThingsHasValue(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Things - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(AncestorOptionsTestData))] - public void GivenLevelSettings_WhenGetOptions_ThenOptionsNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(AncestorOptionsTestData))] - public void GivenLevelSettings_WhenGetOptions_ThenGenerationsNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Generations - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(AncestorOptionsTestData))] - public void GivenLevelSettings_WhenGetOptions_ThenParentNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Generations - .Parent - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(AncestorOptionsTestData))] - public void GivenLevelSettings_WhenGetOptions_ThenComplexNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Generations - .Parent - .Complex - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(AncestorOptionsTestData))] - public void GivenLevelSettings_WhenGetOptions_ThenThingNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Generations - .Parent - .Complex - .Thing - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(ConfigurationOptionsTestData))] - public void GivenUsedConfigurationOptions_WhenGetOptions_ThenThingNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Generations - .Parent - .Complex - .Thing - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(MultipleConfigurationOptionsTestData))] - public void GivenMultipleConfigurationSources_WhenGetOptions_ThenThingNotNull(IServiceProvider serviceProvider) - { - // Given, When, Then - serviceProvider - .GetService>()! - .Value - .Stuff - .Should() - .NotBeNull(); - - serviceProvider - .GetService>()! - .Value - .Enabled - .Should() - .BeTrue(); - - serviceProvider - .GetService>()! - .Value - .Generations - .Parent - .Complex - .Thing - .Should() - .NotBeNull(); - } - - [Theory] - [ClassData(typeof(ConfigurationBuilderTestData))] - public void GivenRegisteredConfigurationBuilder_WhenGetService_ThenNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Should() - .NotBeNull(); - - [Theory] - [ClassData(typeof(ConfigurationBuilderTestData))] - public void GivenRegisteredConfigurationBuilder_WhenGetOptions_ThenNotNull(IServiceProvider serviceProvider) => - - // Given, When, Then - serviceProvider - .GetService>()! - .Should() - .NotBeNull(); + // Given, When, Then + serviceProvider + .GetService>()! + .Value + .Stuff + .Should() + .NotBeNull(); + + serviceProvider + .GetService>()! + .Value + .Enabled + .Should() + .BeTrue(); + + serviceProvider + .GetService>()! + .Value + .Generations + .Parent + .Complex + .Thing + .Should() + .NotBeNull(); } + + [Theory] + [ClassData(typeof(ConfigurationBuilderTestData))] + public void GivenRegisteredConfigurationBuilder_WhenGetService_ThenNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Should() + .NotBeNull(); + + [Theory] + [ClassData(typeof(ConfigurationBuilderTestData))] + public void GivenRegisteredConfigurationBuilder_WhenGetOptions_ThenNotNull(IServiceProvider serviceProvider) => + + // Given, When, Then + serviceProvider + .GetService>()! + .Should() + .NotBeNull(); } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/TestClassData.cs b/test/MicrosoftDependencyInjection.Tests/TestClassData.cs index fe5b15647..12db382a5 100644 --- a/test/MicrosoftDependencyInjection.Tests/TestClassData.cs +++ b/test/MicrosoftDependencyInjection.Tests/TestClassData.cs @@ -1,20 +1,19 @@ using System.Collections; using System.Collections.Generic; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests; + +public abstract class TestClassData : IEnumerable { - public abstract class TestClassData : IEnumerable - { - /// - public IEnumerator GetEnumerator() => Enumerator(); + /// + public IEnumerator GetEnumerator() => Enumerator(); - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - /// - /// Gets the internal enumerator. - /// - /// The object array enumerator. - protected abstract IEnumerator Enumerator(); - } + /// + /// Gets the internal enumerator. + /// + /// The object array enumerator. + protected abstract IEnumerator Enumerator(); } \ No newline at end of file diff --git a/test/MicrosoftDependencyInjection.Tests/TransientFaultHandlingOptions.cs b/test/MicrosoftDependencyInjection.Tests/TransientFaultHandlingOptions.cs index 0bb1ae070..52e25a025 100644 --- a/test/MicrosoftDependencyInjection.Tests/TransientFaultHandlingOptions.cs +++ b/test/MicrosoftDependencyInjection.Tests/TransientFaultHandlingOptions.cs @@ -1,10 +1,9 @@ using System; -namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests +namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.Tests; + +public sealed class TransientFaultHandlingOptions { - public sealed class TransientFaultHandlingOptions - { - public bool Enabled { get; set; } - public TimeSpan AutoRetryDelay { get; set; } - } + public bool Enabled { get; set; } + public TimeSpan AutoRetryDelay { get; set; } } \ No newline at end of file diff --git a/test/Timers.Tests/DecrementTimerFixture.cs b/test/Timers.Tests/DecrementTimerFixture.cs index 4e8fd28ba..a0f7ba8f1 100644 --- a/test/Timers.Tests/DecrementTimerFixture.cs +++ b/test/Timers.Tests/DecrementTimerFixture.cs @@ -1,16 +1,15 @@ using Airframe.Testing; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +internal class DecrementTimerFixture : ITestFixtureBuilder { - internal class DecrementTimerFixture : ITestFixtureBuilder - { - public static implicit operator DecrementTimer(DecrementTimerFixture fixture) => fixture.Build(); + public static implicit operator DecrementTimer(DecrementTimerFixture fixture) => fixture.Build(); - public DecrementTimerFixture WithProvider(ISchedulerProvider schedulerProvider) => this.With(ref _schedulerProvider, schedulerProvider); + public DecrementTimerFixture WithProvider(ISchedulerProvider schedulerProvider) => this.With(ref _schedulerProvider, schedulerProvider); - private DecrementTimer Build() => new DecrementTimer(_schedulerProvider); + private DecrementTimer Build() => new DecrementTimer(_schedulerProvider); - private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); - } + private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); } \ No newline at end of file diff --git a/test/Timers.Tests/DecrementTimerTests.cs b/test/Timers.Tests/DecrementTimerTests.cs index e54709243..f737baaa9 100644 --- a/test/Timers.Tests/DecrementTimerTests.cs +++ b/test/Timers.Tests/DecrementTimerTests.cs @@ -6,102 +6,101 @@ using System; using Xunit; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +public class DecrementTimerTests : TestBase { - public class DecrementTimerTests : TestBase + private const int InitialMilliseconds = 1001; + private const int OneThousandMilliseconds = 1000; + + [Fact] + public void Should_Not_Be_Running_When_Constructed() + { + // Given, When + DecrementTimer sut = new DecrementTimerFixture(); + + // Then + sut.IsRunning.Should().BeFalse(); + } + + [Fact] + public void Should_Be_Running_When_Started() + { + // Given + var testScheduler = new TestScheduler(); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); + + // When + sut.Start(TimeSpan.FromMinutes(25)); + testScheduler.AdvanceByMs(InitialMilliseconds); + + // Then + sut.IsRunning.Should().BeTrue(); + } + + [Fact] + public void Should_Advance_When_Started() + { + // Given + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); + var timer = TimeSpan.Zero; + + using var _ = sut.Subscribe(x => timer = x); + + // When + sut.Start(TimeSpan.FromMinutes(1)); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + + // Then + timer.Should().Be(TimeSpan.FromSeconds(59)); + } + + [Fact] + public void Should_Resume_Where_Stopped() + { + // Given + var testScheduler = new TestScheduler(); + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); + DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); + var timer = TimeSpan.Zero; + sut.Start(TimeSpan.FromMinutes(1)); + + using var _ = sut.Subscribe(x => timer = x); + + sut.Start(TimeSpan.FromMinutes(1)); + testScheduler.AdvanceByMs(InitialMilliseconds); + sut.Stop(); + testScheduler.AdvanceByMs(OneThousandMilliseconds); + + // When + sut.Start(); + + // Then + timer.Should().Be(TimeSpan.FromSeconds(59)); + } + + [Fact] + public void Should_Resume_After_Stopped() { - private const int InitialMilliseconds = 1001; - private const int OneThousandMilliseconds = 1000; - - [Fact] - public void Should_Not_Be_Running_When_Constructed() - { - // Given, When - DecrementTimer sut = new DecrementTimerFixture(); - - // Then - sut.IsRunning.Should().BeFalse(); - } - - [Fact] - public void Should_Be_Running_When_Started() - { - // Given - var testScheduler = new TestScheduler(); - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); - DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); - - // When - sut.Start(TimeSpan.FromMinutes(25)); - testScheduler.AdvanceByMs(InitialMilliseconds); - - // Then - sut.IsRunning.Should().BeTrue(); - } - - [Fact] - public void Should_Advance_When_Started() - { - // Given - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); - var timer = TimeSpan.Zero; - - using var _ = sut.Subscribe(x => timer = x); - - // When - sut.Start(TimeSpan.FromMinutes(1)); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); - - // Then - timer.Should().Be(TimeSpan.FromSeconds(59)); - } - - [Fact] - public void Should_Resume_Where_Stopped() - { - // Given - var testScheduler = new TestScheduler(); - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture().WithTestScheduler(testScheduler); - DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); - var timer = TimeSpan.Zero; - sut.Start(TimeSpan.FromMinutes(1)); - - using var _ = sut.Subscribe(x => timer = x); - - sut.Start(TimeSpan.FromMinutes(1)); - testScheduler.AdvanceByMs(InitialMilliseconds); - sut.Stop(); - testScheduler.AdvanceByMs(OneThousandMilliseconds); - - // When - sut.Start(); - - // Then - timer.Should().Be(TimeSpan.FromSeconds(59)); - } - - [Fact] - public void Should_Resume_After_Stopped() - { - // Given - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); - var timer = TimeSpan.Zero; - - sut.Subscribe(x => timer = x); - - sut.Start(TimeSpan.FromMinutes(1)); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); - sut.Stop(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - - // When - sut.Start(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - - // Then - timer.Should().Be(TimeSpan.FromSeconds(58)); - } + // Given + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + DecrementTimer sut = new DecrementTimerFixture().WithProvider(schedulerProvider); + var timer = TimeSpan.Zero; + + sut.Subscribe(x => timer = x); + + sut.Start(TimeSpan.FromMinutes(1)); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + sut.Stop(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); + + // When + sut.Start(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); + + // Then + timer.Should().Be(TimeSpan.FromSeconds(58)); } } \ No newline at end of file diff --git a/test/Timers.Tests/DivisibleTimeSpanData.cs b/test/Timers.Tests/DivisibleTimeSpanData.cs index c19b33704..8e6438bc0 100644 --- a/test/Timers.Tests/DivisibleTimeSpanData.cs +++ b/test/Timers.Tests/DivisibleTimeSpanData.cs @@ -1,29 +1,28 @@ using System; using Xunit; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +internal class DivisibleTimeSpanData : TheoryData { - internal class DivisibleTimeSpanData : TheoryData + public DivisibleTimeSpanData() { - public DivisibleTimeSpanData() - { - AddRow(3, TimeSpan.FromHours(2)); - AddRow(108, TimeSpan.FromMinutes(45)); - AddRow(108, TimeSpan.FromMinutes(55)); - AddRow(108, TimeSpan.FromMinutes(65)); - AddRow(1, TimeSpan.FromMinutes(3)); - AddRow(10, TimeSpan.FromMinutes(30)); - AddRow(100, TimeSpan.FromMinutes(3000)); - AddRow(3, TimeSpan.FromMinutes(700)); - AddRow(2, TimeSpan.FromMinutes(5)); - AddRow(108, TimeSpan.FromSeconds(45)); - AddRow(108, TimeSpan.FromSeconds(55)); - AddRow(108, TimeSpan.FromSeconds(65)); - AddRow(1, TimeSpan.FromSeconds(3)); - AddRow(10, TimeSpan.FromSeconds(30)); - AddRow(100, TimeSpan.FromSeconds(3000)); - AddRow(3, TimeSpan.FromSeconds(700)); - AddRow(2, TimeSpan.FromSeconds(5)); - } + AddRow(3, TimeSpan.FromHours(2)); + AddRow(108, TimeSpan.FromMinutes(45)); + AddRow(108, TimeSpan.FromMinutes(55)); + AddRow(108, TimeSpan.FromMinutes(65)); + AddRow(1, TimeSpan.FromMinutes(3)); + AddRow(10, TimeSpan.FromMinutes(30)); + AddRow(100, TimeSpan.FromMinutes(3000)); + AddRow(3, TimeSpan.FromMinutes(700)); + AddRow(2, TimeSpan.FromMinutes(5)); + AddRow(108, TimeSpan.FromSeconds(45)); + AddRow(108, TimeSpan.FromSeconds(55)); + AddRow(108, TimeSpan.FromSeconds(65)); + AddRow(1, TimeSpan.FromSeconds(3)); + AddRow(10, TimeSpan.FromSeconds(30)); + AddRow(100, TimeSpan.FromSeconds(3000)); + AddRow(3, TimeSpan.FromSeconds(700)); + AddRow(2, TimeSpan.FromSeconds(5)); } } \ No newline at end of file diff --git a/test/Timers.Tests/DivisibleTimerFixture.cs b/test/Timers.Tests/DivisibleTimerFixture.cs index 0f870e1bf..9f91e73bf 100644 --- a/test/Timers.Tests/DivisibleTimerFixture.cs +++ b/test/Timers.Tests/DivisibleTimerFixture.cs @@ -1,16 +1,15 @@ using Airframe.Testing; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +internal class DivisibleTimerFixture : ITestFixtureBuilder { - internal class DivisibleTimerFixture : ITestFixtureBuilder - { - private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); + private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); - public static implicit operator DivisibleTimer(DivisibleTimerFixture fixture) => fixture.Build(); + public static implicit operator DivisibleTimer(DivisibleTimerFixture fixture) => fixture.Build(); - public DivisibleTimerFixture WithProvider(ISchedulerProvider scheduler) => this.With(ref _schedulerProvider, scheduler); + public DivisibleTimerFixture WithProvider(ISchedulerProvider scheduler) => this.With(ref _schedulerProvider, scheduler); - private DivisibleTimer Build() => new DivisibleTimer(_schedulerProvider); - } + private DivisibleTimer Build() => new DivisibleTimer(_schedulerProvider); } \ No newline at end of file diff --git a/test/Timers.Tests/DivisibleTimerTests.cs b/test/Timers.Tests/DivisibleTimerTests.cs index abaf51f80..88dedecb8 100644 --- a/test/Timers.Tests/DivisibleTimerTests.cs +++ b/test/Timers.Tests/DivisibleTimerTests.cs @@ -4,40 +4,39 @@ using System.Reactive.Linq; using Xunit; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +public sealed class DivisibleTimerTests { - public sealed class DivisibleTimerTests + [Theory] + [ClassData(typeof(DivisibleTimeSpanData))] + public void Should_Divide_TimeSpan_By_Partition(int partition, TimeSpan duration) { - [Theory] - [ClassData(typeof(DivisibleTimeSpanData))] - public void Should_Divide_TimeSpan_By_Partition(int partition, TimeSpan duration) - { - // Given - DivisibleTimer sut = new DivisibleTimerFixture(); + // Given + DivisibleTimer sut = new DivisibleTimerFixture(); - // When - sut.Start(partition, duration); + // When + sut.Start(partition, duration); - // Then - sut.IntervalTime.Should().Be(TimeSpan.FromTicks(Math.DivRem(duration.Ticks, partition, out var remainder))); - } + // Then + sut.IntervalTime.Should().Be(TimeSpan.FromTicks(Math.DivRem(duration.Ticks, partition, out var remainder))); + } - [Fact(Skip = "DivisibleTimer implementation not working correctly.")] - public void Should_Run_Correct_Partition_Count() - { - // Given - int count = 1; - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - DivisibleTimer sut = - new DivisibleTimerFixture().WithProvider(schedulerProvider); - sut.Interval.ObserveOn(schedulerProvider.UserInterfaceTestScheduler).Subscribe(_ => count++); + [Fact(Skip = "DivisibleTimer implementation not working correctly.")] + public void Should_Run_Correct_Partition_Count() + { + // Given + int count = 1; + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + DivisibleTimer sut = + new DivisibleTimerFixture().WithProvider(schedulerProvider); + sut.Interval.ObserveOn(schedulerProvider.UserInterfaceTestScheduler).Subscribe(_ => count++); - // When - sut.Start(4, TimeSpan.FromHours(1)); - schedulerProvider.UserInterfaceTestScheduler.AdvanceBy(TimeSpan.FromMinutes(30).Ticks); + // When + sut.Start(4, TimeSpan.FromHours(1)); + schedulerProvider.UserInterfaceTestScheduler.AdvanceBy(TimeSpan.FromMinutes(30).Ticks); - // Then - count.Should().Be(4); - } + // Then + count.Should().Be(4); } } \ No newline at end of file diff --git a/test/Timers.Tests/IncrementTimerFixture.cs b/test/Timers.Tests/IncrementTimerFixture.cs index 7af7d6365..360fc1826 100644 --- a/test/Timers.Tests/IncrementTimerFixture.cs +++ b/test/Timers.Tests/IncrementTimerFixture.cs @@ -1,16 +1,15 @@ using Airframe.Testing; using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +internal class IncrementTimerFixture : ITestFixtureBuilder { - internal class IncrementTimerFixture : ITestFixtureBuilder - { - public static implicit operator IncrementTimer(IncrementTimerFixture fixture) => fixture.Build(); + public static implicit operator IncrementTimer(IncrementTimerFixture fixture) => fixture.Build(); - public IncrementTimerFixture WithProvider(ISchedulerProvider schedulerProvider) => this.With(ref _schedulerProvider, schedulerProvider); + public IncrementTimerFixture WithProvider(ISchedulerProvider schedulerProvider) => this.With(ref _schedulerProvider, schedulerProvider); - private IncrementTimer Build() => new IncrementTimer(_schedulerProvider); + private IncrementTimer Build() => new IncrementTimer(_schedulerProvider); - private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); - } + private ISchedulerProvider _schedulerProvider = new SchedulerProviderFixture().AsInterface(); } \ No newline at end of file diff --git a/test/Timers.Tests/IncrementTimerTests.cs b/test/Timers.Tests/IncrementTimerTests.cs index a05e2d180..90818074e 100644 --- a/test/Timers.Tests/IncrementTimerTests.cs +++ b/test/Timers.Tests/IncrementTimerTests.cs @@ -5,104 +5,103 @@ using System; using Xunit; -namespace Rocket.Surgery.Airframe.Timers.Tests +namespace Rocket.Surgery.Airframe.Timers.Tests; + +public class IncrementTimerTests : TestBase { - public class IncrementTimerTests : TestBase + private const int InitialMilliseconds = 1001; + private const int OneThousandMilliseconds = 1000; + + [Fact] + public void Should_Not_Be_Running_When_Constructed() { - private const int InitialMilliseconds = 1001; - private const int OneThousandMilliseconds = 1000; + // Given, When + IncrementTimer sut = new IncrementTimerFixture(); - [Fact] - public void Should_Not_Be_Running_When_Constructed() - { - // Given, When - IncrementTimer sut = new IncrementTimerFixture(); + // Then + sut.IsRunning.Should().BeFalse(); + } - // Then - sut.IsRunning.Should().BeFalse(); - } + [Fact] + public void Should_Be_Running_When_Started() + { + // Given + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); - [Fact] - public void Should_Be_Running_When_Started() - { - // Given - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); + // When + sut.Start(TimeSpan.FromMinutes(25)); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); - // When - sut.Start(TimeSpan.FromMinutes(25)); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + // Then + sut.IsRunning.Should().BeTrue(); + } - // Then - sut.IsRunning.Should().BeTrue(); - } + [Fact] + public void Should_Advance_When_Started() + { + // Given + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); + var timer = TimeSpan.Zero; - [Fact] - public void Should_Advance_When_Started() - { - // Given - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); - var timer = TimeSpan.Zero; - - sut.Subscribe(x => - { - timer = x; - }); - - // When - sut.Start(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - - // Then - timer.Should().Be(TimeSpan.FromSeconds(2)); - } - - [Fact] - public void Should_Resume_Where_Stopped() + sut.Subscribe(x => { - // Given - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); - var timer = TimeSpan.Zero; - sut.Start(TimeSpan.FromMinutes(1)); + timer = x; + }); - using var _ = sut.Subscribe(x => timer = x); + // When + sut.Start(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - sut.Start(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); - sut.Stop(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); + // Then + timer.Should().Be(TimeSpan.FromSeconds(2)); + } + + [Fact] + public void Should_Resume_Where_Stopped() + { + // Given + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); + var timer = TimeSpan.Zero; + sut.Start(TimeSpan.FromMinutes(1)); - // When - sut.Start(); + using var _ = sut.Subscribe(x => timer = x); - // Then - timer.Should().Be(TimeSpan.FromSeconds(1)); - } + sut.Start(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + sut.Stop(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - [Fact] - public void Should_Resume_After_Stopped() - { - // Given - SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); - IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); - var timer = TimeSpan.Zero; + // When + sut.Start(); + + // Then + timer.Should().Be(TimeSpan.FromSeconds(1)); + } + + [Fact] + public void Should_Resume_After_Stopped() + { + // Given + SchedulerProviderMock schedulerProvider = new SchedulerProviderFixture(); + IncrementTimer sut = new IncrementTimerFixture().WithProvider(schedulerProvider); + var timer = TimeSpan.Zero; - sut.Subscribe(x => timer = x); + sut.Subscribe(x => timer = x); - sut.Start(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); - sut.Stop(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); + sut.Start(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(InitialMilliseconds); + sut.Stop(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - // When - sut.Start(); - schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); + // When + sut.Start(); + schedulerProvider.UserInterfaceTestScheduler.AdvanceByMs(OneThousandMilliseconds); - // Then - timer.Should().Be(TimeSpan.FromSeconds(2)); - } + // Then + timer.Should().Be(TimeSpan.FromSeconds(2)); } } \ No newline at end of file diff --git a/test/ViewModels.Tests/NavigableViewModelTests.cs b/test/ViewModels.Tests/NavigableViewModelTests.cs index e79e99cc8..d8cbc2863 100644 --- a/test/ViewModels.Tests/NavigableViewModelTests.cs +++ b/test/ViewModels.Tests/NavigableViewModelTests.cs @@ -3,56 +3,55 @@ using Rocket.Surgery.Airframe.Tests; using Xunit; -namespace Rocket.Surgery.Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests; + +public class NavigableViewModelTests : TestBase { - public class NavigableViewModelTests : TestBase + public class TheNavigatedToProperty { - public class TheNavigatedToProperty + [Fact] + public void Should_Have_Parameter() { - [Fact] - public void Should_Have_Parameter() - { - // Given - TestNavigationViewModel sut = new TestNavigationViewModelFixture(); - - // When - sut.As().OnNavigatedTo(new Arguments()); - - // Then - sut.NavigatedToParameter.Should().BeAssignableTo(); - } + // Given + TestNavigationViewModel sut = new TestNavigationViewModelFixture(); + + // When + sut.As().OnNavigatedTo(new Arguments()); + + // Then + sut.NavigatedToParameter.Should().BeAssignableTo(); } + } - public class TheNavigatedFromProperty + public class TheNavigatedFromProperty + { + [Fact] + public void Should_Have_Parameter() { - [Fact] - public void Should_Have_Parameter() - { - // Given - TestNavigationViewModel sut = new TestNavigationViewModelFixture(); - - // When - sut.As().OnNavigatedFrom(new Arguments()); - - // Then - sut.NavigatedFromParameter.Should().BeAssignableTo(); - } + // Given + TestNavigationViewModel sut = new TestNavigationViewModelFixture(); + + // When + sut.As().OnNavigatedFrom(new Arguments()); + + // Then + sut.NavigatedFromParameter.Should().BeAssignableTo(); } + } - public class TheInitializeProperty + public class TheInitializeProperty + { + [Fact] + public void Should_Have_Parameter() { - [Fact] - public void Should_Have_Parameter() - { - // Given - TestNavigationViewModel sut = new TestNavigationViewModelFixture(); - - // When - sut.As().OnInitialize(new Arguments()); - - // Then - sut.InitializeParameter.Should().BeAssignableTo(); - } + // Given + TestNavigationViewModel sut = new TestNavigationViewModelFixture(); + + // When + sut.As().OnInitialize(new Arguments()); + + // Then + sut.InitializeParameter.Should().BeAssignableTo(); } } } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestNavigationViewModel.cs b/test/ViewModels.Tests/TestNavigationViewModel.cs index ced466e14..460ec2bd2 100644 --- a/test/ViewModels.Tests/TestNavigationViewModel.cs +++ b/test/ViewModels.Tests/TestNavigationViewModel.cs @@ -3,40 +3,39 @@ using System.Diagnostics.CodeAnalysis; using System.Reactive.Disposables; -namespace Rocket.Surgery.Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests; + +[SuppressMessage("Usage", "CA2213:Disposable fields should be disposed")] +internal class TestNavigationViewModel : NavigableViewModelBase { - [SuppressMessage("Usage", "CA2213:Disposable fields should be disposed")] - internal class TestNavigationViewModel : NavigableViewModelBase + /// + /// Initializes a new instance of the class. + /// + public TestNavigationViewModel() { - /// - /// Initializes a new instance of the class. - /// - public TestNavigationViewModel() - { - _initializeParameter = - Initialize - .AsValue(_ => RaisePropertyChanged(nameof(InitializeParameter))) - .DisposeWith(Garbage)!; - - _navigatedToParameter = - NavigatedTo - .AsValue(_ => RaisePropertyChanged(nameof(NavigatedToParameter))) - .DisposeWith(Garbage)!; - - _navigatedFromParameter = - NavigatedFrom - .AsValue(_ => RaisePropertyChanged(nameof(NavigatedFromParameter))) - .DisposeWith(Garbage)!; - } - - public IArguments NavigatedToParameter => _navigatedToParameter.Value; - - public IArguments NavigatedFromParameter => _navigatedFromParameter.Value; - - public IArguments InitializeParameter => _initializeParameter.Value; - - private readonly ValueBinder _initializeParameter; - private readonly ValueBinder _navigatedToParameter; - private readonly ValueBinder _navigatedFromParameter; + _initializeParameter = + Initialize + .AsValue(_ => RaisePropertyChanged(nameof(InitializeParameter))) + .DisposeWith(Garbage)!; + + _navigatedToParameter = + NavigatedTo + .AsValue(_ => RaisePropertyChanged(nameof(NavigatedToParameter))) + .DisposeWith(Garbage)!; + + _navigatedFromParameter = + NavigatedFrom + .AsValue(_ => RaisePropertyChanged(nameof(NavigatedFromParameter))) + .DisposeWith(Garbage)!; } + + public IArguments NavigatedToParameter => _navigatedToParameter.Value; + + public IArguments NavigatedFromParameter => _navigatedFromParameter.Value; + + public IArguments InitializeParameter => _initializeParameter.Value; + + private readonly ValueBinder _initializeParameter; + private readonly ValueBinder _navigatedToParameter; + private readonly ValueBinder _navigatedFromParameter; } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs index 470179e3b..c72d7f1e8 100644 --- a/test/ViewModels.Tests/TestNavigationViewModelFixture.cs +++ b/test/ViewModels.Tests/TestNavigationViewModelFixture.cs @@ -1,9 +1,8 @@ -namespace Rocket.Surgery.Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests; + +internal class TestNavigationViewModelFixture { - internal class TestNavigationViewModelFixture - { - public static implicit operator TestNavigationViewModel(TestNavigationViewModelFixture fixture) => fixture.Build(); + public static implicit operator TestNavigationViewModel(TestNavigationViewModelFixture fixture) => fixture.Build(); - private TestNavigationViewModel Build() => new TestNavigationViewModel(); - } + private TestNavigationViewModel Build() => new TestNavigationViewModel(); } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestViewModel.cs b/test/ViewModels.Tests/TestViewModel.cs index 8542e2aac..e537318a1 100644 --- a/test/ViewModels.Tests/TestViewModel.cs +++ b/test/ViewModels.Tests/TestViewModel.cs @@ -1,7 +1,6 @@ -namespace Rocket.Surgery.Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests; + +internal class TestViewModel : ViewModelBase { - internal class TestViewModel : ViewModelBase - { - public bool IsLoading { get; } = true; - } + public bool IsLoading { get; } = true; } \ No newline at end of file diff --git a/test/ViewModels.Tests/TestViewModelFixture.cs b/test/ViewModels.Tests/TestViewModelFixture.cs index f6a3e045c..812c1e7e1 100644 --- a/test/ViewModels.Tests/TestViewModelFixture.cs +++ b/test/ViewModels.Tests/TestViewModelFixture.cs @@ -1,11 +1,10 @@ using Rocket.Surgery.Extensions.Testing.Fixtures; -namespace Rocket.Surgery.Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests; + +internal class TestViewModelFixture : ITestFixtureBuilder { - internal class TestViewModelFixture : ITestFixtureBuilder - { - public static implicit operator TestViewModel(TestViewModelFixture fixture) => fixture.Build(); + public static implicit operator TestViewModel(TestViewModelFixture fixture) => fixture.Build(); - private TestViewModel Build() => new TestViewModel(); - } + private TestViewModel Build() => new TestViewModel(); } \ No newline at end of file diff --git a/test/ViewModels.Tests/ViewModelTests.cs b/test/ViewModels.Tests/ViewModelTests.cs index 2080b7d1a..297c00996 100644 --- a/test/ViewModels.Tests/ViewModelTests.cs +++ b/test/ViewModels.Tests/ViewModelTests.cs @@ -1,22 +1,21 @@ using FluentAssertions; using Xunit; -namespace Rocket.Surgery.Airframe.ViewModels.Tests +namespace Rocket.Surgery.Airframe.ViewModels.Tests; + +public sealed class ViewModelTests { - public sealed class ViewModelTests + public class TheIsLoadingProperty { - public class TheIsLoadingProperty + [Fact] + public void Should_Return_True() { - [Fact] - public void Should_Return_True() - { - // Given, When - TestViewModel sut = - new TestViewModelFixture(); + // Given, When + TestViewModel sut = + new TestViewModelFixture(); - // Then - sut.IsLoading.Should().Be(true); - } + // Then + sut.IsLoading.Should().Be(true); } } } \ No newline at end of file From 1a02d557c4da1a04a48b23aa66725d3b64362dc9 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:21:17 -0600 Subject: [PATCH 08/14] =?UTF-8?q?chore:=20more=20scoped=20things=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmarks/Performance/Mocks/Test.cs | 4 +--- benchmarks/Performance/Mocks/TestReactiveObject.cs | 2 +- src/Core/Exceptions/IExceptionHandler.cs | 4 +--- src/Core/Locations/Events/HeadingUpdatedEvent.cs | 4 +--- src/Core/Locations/Events/RegionBeaconRangedEvent.cs | 4 +--- src/Core/Operations/IOperation.cs | 4 +--- src/Core/Timers/IDecrement.cs | 4 +--- src/Core/Timers/IIncrement.cs | 4 +--- src/Core/Timers/IObservableTimer.cs | 4 +--- src/Data/Data/IDto.cs | 4 +--- src/Synthetic/Coffee/ICoffeeDataService.cs | 4 +--- src/Synthetic/Drinks/IDrinkService.cs | 4 +--- src/Timers/Events/TimerEvent.cs | 4 +--- src/Timers/Events/TimerResetEvent.cs | 4 +--- src/Timers/Events/TimerResumeEvent.cs | 4 +--- src/Timers/Events/TimerStopEvent.cs | 4 +--- 16 files changed, 16 insertions(+), 46 deletions(-) diff --git a/benchmarks/Performance/Mocks/Test.cs b/benchmarks/Performance/Mocks/Test.cs index c712d77ee..c46241771 100644 --- a/benchmarks/Performance/Mocks/Test.cs +++ b/benchmarks/Performance/Mocks/Test.cs @@ -2,6 +2,4 @@ namespace Rocket.Surgery.Airframe.Performance; -public class Test : ViewModelBase -{ -} \ No newline at end of file +public class Test : ViewModelBase; \ No newline at end of file diff --git a/benchmarks/Performance/Mocks/TestReactiveObject.cs b/benchmarks/Performance/Mocks/TestReactiveObject.cs index eb2fee996..c6a432320 100644 --- a/benchmarks/Performance/Mocks/TestReactiveObject.cs +++ b/benchmarks/Performance/Mocks/TestReactiveObject.cs @@ -2,4 +2,4 @@ namespace Rocket.Surgery.Airframe.Performance; -public class TestReactiveObject : ReactiveObject { } \ No newline at end of file +public class TestReactiveObject : ReactiveObject; \ No newline at end of file diff --git a/src/Core/Exceptions/IExceptionHandler.cs b/src/Core/Exceptions/IExceptionHandler.cs index 2cd7437ae..7e8fae1e9 100644 --- a/src/Core/Exceptions/IExceptionHandler.cs +++ b/src/Core/Exceptions/IExceptionHandler.cs @@ -5,6 +5,4 @@ namespace Rocket.Surgery.Airframe.Exceptions; /// /// Interface representing an . /// -public interface IExceptionHandler : IObserver -{ -} \ No newline at end of file +public interface IExceptionHandler : IObserver; \ No newline at end of file diff --git a/src/Core/Locations/Events/HeadingUpdatedEvent.cs b/src/Core/Locations/Events/HeadingUpdatedEvent.cs index d0ed77d02..19270cafc 100644 --- a/src/Core/Locations/Events/HeadingUpdatedEvent.cs +++ b/src/Core/Locations/Events/HeadingUpdatedEvent.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe; /// /// Represents a heading update event. /// -public class HeadingUpdatedEvent -{ -} \ No newline at end of file +public class HeadingUpdatedEvent; \ No newline at end of file diff --git a/src/Core/Locations/Events/RegionBeaconRangedEvent.cs b/src/Core/Locations/Events/RegionBeaconRangedEvent.cs index 8357ec982..5fe8b5baa 100644 --- a/src/Core/Locations/Events/RegionBeaconRangedEvent.cs +++ b/src/Core/Locations/Events/RegionBeaconRangedEvent.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe; /// /// Represents a beacon ranged event. /// -public class RegionBeaconRangedEvent -{ -} \ No newline at end of file +public class RegionBeaconRangedEvent; \ No newline at end of file diff --git a/src/Core/Operations/IOperation.cs b/src/Core/Operations/IOperation.cs index f879d9f92..3dc07844e 100644 --- a/src/Core/Operations/IOperation.cs +++ b/src/Core/Operations/IOperation.cs @@ -6,9 +6,7 @@ namespace Rocket.Surgery.Airframe; /// /// Interface representing a base operation. /// -public interface IOperation : IOperation -{ -} +public interface IOperation : IOperation; /// /// Interface representing a base operation. diff --git a/src/Core/Timers/IDecrement.cs b/src/Core/Timers/IDecrement.cs index 6bf88e833..8f69591e2 100644 --- a/src/Core/Timers/IDecrement.cs +++ b/src/Core/Timers/IDecrement.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe; /// /// Interface representing an decrementing timer. /// -public interface IDecrement : ITimer -{ -} \ No newline at end of file +public interface IDecrement : ITimer; \ No newline at end of file diff --git a/src/Core/Timers/IIncrement.cs b/src/Core/Timers/IIncrement.cs index 284951dd2..2b03bd95e 100644 --- a/src/Core/Timers/IIncrement.cs +++ b/src/Core/Timers/IIncrement.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe; /// /// Interface representing an incrementing timer. /// -public interface IIncrement : ITimer -{ -} \ No newline at end of file +public interface IIncrement : ITimer; \ No newline at end of file diff --git a/src/Core/Timers/IObservableTimer.cs b/src/Core/Timers/IObservableTimer.cs index d1ed8f4db..ceb502b8c 100644 --- a/src/Core/Timers/IObservableTimer.cs +++ b/src/Core/Timers/IObservableTimer.cs @@ -5,6 +5,4 @@ namespace Rocket.Surgery.Airframe; /// /// Represents an that is observable. /// -public interface IObservableTimer : ITimer, IObservable -{ -} \ No newline at end of file +public interface IObservableTimer : ITimer, IObservable; \ No newline at end of file diff --git a/src/Data/Data/IDto.cs b/src/Data/Data/IDto.cs index ecb650a52..cfd5a668e 100644 --- a/src/Data/Data/IDto.cs +++ b/src/Data/Data/IDto.cs @@ -5,6 +5,4 @@ namespace Rocket.Surgery.Airframe.Data; /// /// Interface representing a data transfer object. /// -public interface IDto : IHaveIdentifier -{ -} \ No newline at end of file +public interface IDto : IHaveIdentifier; \ No newline at end of file diff --git a/src/Synthetic/Coffee/ICoffeeDataService.cs b/src/Synthetic/Coffee/ICoffeeDataService.cs index 7b0b33f16..d37da509d 100644 --- a/src/Synthetic/Coffee/ICoffeeDataService.cs +++ b/src/Synthetic/Coffee/ICoffeeDataService.cs @@ -5,6 +5,4 @@ namespace Rocket.Surgery.Airframe.Synthetic.Coffee; /// /// Interface representing a coffee data service. /// -public interface ICoffeeDataService : IDataService -{ -} \ No newline at end of file +public interface ICoffeeDataService : IDataService; \ No newline at end of file diff --git a/src/Synthetic/Drinks/IDrinkService.cs b/src/Synthetic/Drinks/IDrinkService.cs index 752183fcd..2d6e93eb2 100644 --- a/src/Synthetic/Drinks/IDrinkService.cs +++ b/src/Synthetic/Drinks/IDrinkService.cs @@ -5,6 +5,4 @@ namespace Rocket.Surgery.Airframe.Synthetic.Drinks; /// /// Interface representing a coffee drink data service. /// -public interface IDrinkService : IDataService -{ -} \ No newline at end of file +public interface IDrinkService : IDataService; \ No newline at end of file diff --git a/src/Timers/Events/TimerEvent.cs b/src/Timers/Events/TimerEvent.cs index 254bcd064..42ae8fd7a 100644 --- a/src/Timers/Events/TimerEvent.cs +++ b/src/Timers/Events/TimerEvent.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe.Timers.Events; /// /// A timer changed notification. /// -public class TimerEvent -{ -} \ No newline at end of file +public class TimerEvent; \ No newline at end of file diff --git a/src/Timers/Events/TimerResetEvent.cs b/src/Timers/Events/TimerResetEvent.cs index 01e529fdc..b13535e06 100644 --- a/src/Timers/Events/TimerResetEvent.cs +++ b/src/Timers/Events/TimerResetEvent.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe.Timers.Events; /// /// Indicates a timer has reset. /// -public class TimerResetEvent : TimerEvent -{ -} \ No newline at end of file +public class TimerResetEvent : TimerEvent; \ No newline at end of file diff --git a/src/Timers/Events/TimerResumeEvent.cs b/src/Timers/Events/TimerResumeEvent.cs index b0f8d150e..7ee98eaa6 100644 --- a/src/Timers/Events/TimerResumeEvent.cs +++ b/src/Timers/Events/TimerResumeEvent.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe.Timers.Events; /// /// Indicates a timer has resumed. /// -public class TimerResumeEvent : TimerEvent -{ -} \ No newline at end of file +public class TimerResumeEvent : TimerEvent; \ No newline at end of file diff --git a/src/Timers/Events/TimerStopEvent.cs b/src/Timers/Events/TimerStopEvent.cs index 4e44dfc9d..dc9d52dd3 100644 --- a/src/Timers/Events/TimerStopEvent.cs +++ b/src/Timers/Events/TimerStopEvent.cs @@ -3,6 +3,4 @@ namespace Rocket.Surgery.Airframe.Timers.Events; /// /// Indicates a timer has stopped. /// -public class TimerStopEvent : TimerEvent -{ -} \ No newline at end of file +public class TimerStopEvent : TimerEvent; \ No newline at end of file From 7a200c9270b5c22017b7828f808616b04dcfbbd7 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:24:42 -0600 Subject: [PATCH 09/14] chore: git version --- .config/dotnet-tools.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index bbdfa465d..a7e1a6f2e 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -2,10 +2,6 @@ "version": 1, "isRoot": true, "tools": { - "gitversion.tool": { - "version": "5.12.0", - "commands": ["dotnet-gitversion"] - }, "dotnet-outdated": { "version": "2.11.0", "commands": ["dotnet-outdated"] From 213929cee22fb7b62e10a294d86e4c13c363bd6c Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:45:08 -0600 Subject: [PATCH 10/14] chore: the purge continues --- .build/AirframeBuild.CI.cs | 88 ------------------ .build/AirframeBuild.GitHubActions.cs | 128 ++++++++++++++++++++++++++ .build/AirframeBuild.cs | 13 +-- .github/workflows/ci.yml | 8 ++ 4 files changed, 141 insertions(+), 96 deletions(-) delete mode 100644 .build/AirframeBuild.CI.cs create mode 100644 .build/AirframeBuild.GitHubActions.cs diff --git a/.build/AirframeBuild.CI.cs b/.build/AirframeBuild.CI.cs deleted file mode 100644 index 960136f92..000000000 --- a/.build/AirframeBuild.CI.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Nuke.Common.CI.GitHubActions; -using Rocket.Surgery.Nuke.ContinuousIntegration; -using Rocket.Surgery.Nuke.DotNetCore; -using Rocket.Surgery.Nuke.GithubActions; -using System; - -[GitHubActionsSteps("ci", GitHubActionsImage.MacOsLatest, - AutoGenerate = true, - On = [RocketSurgeonGitHubActionsTrigger.Push], - OnPushTags = ["v*"], - OnPushBranches = ["master", "next", "feature/*"], - OnPullRequestBranches = ["master", "next"], - InvokedTargets = [nameof(Default)], - NonEntryTargets = - [ - nameof(ICIEnvironment.CIEnvironment), - nameof(ITriggerCodeCoverageReports.TriggerCodeCoverageReports), - nameof(ITriggerCodeCoverageReports.GenerateCodeCoverageReportCobertura), - nameof(IGenerateCodeCoverageBadges.GenerateCodeCoverageBadges), - nameof(IGenerateCodeCoverageReport.GenerateCodeCoverageReport), - nameof(IGenerateCodeCoverageSummary.GenerateCodeCoverageSummary), - nameof(Default) - ], - ExcludedTargets = [nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore)], - Enhancements = [nameof(Middleware)] -)] -[PrintBuildVersion, PrintCIEnvironment, UploadLogs] -[LocalBuildConventions] -[ContinuousIntegrationConventions] -public partial class AirframeBuild -{ - public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) - { - var buildJob = configuration.Jobs.Cast().First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase)); - var checkoutStep = buildJob.Steps.OfType().Single(); - // For fetch all - checkoutStep.FetchDepth = 0; - buildJob.Steps.InsertRange(buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] { - new RunStep("Fetch all history for all tags and branches") { - Run = "git fetch --prune" - }, - new SetupDotNetStep("Use .NET 8 SDK") { - DotNetVersion = "8.0.101" - } - }); - - buildJob.Steps.Add(new UsingStep("Publish Coverage") - { - Uses = "codecov/codecov-action@v1", - With = new Dictionary - { - ["name"] = "actions-${{ matrix.os }}", - } - }); - - buildJob.Steps.Add(new UploadArtifactStep("Publish logs") - { - Name = "logs", - Path = "artifacts/logs/", - If = "always()" - }); - - buildJob.Steps.Add(new UploadArtifactStep("Publish coverage data") - { - Name = "coverage", - Path = "coverage/", - If = "always()" - }); - - buildJob.Steps.Add(new UploadArtifactStep("Publish test data") - { - Name = "test data", - Path = "artifacts/test/", - If = "always()" - }); - - buildJob.Steps.Add(new UploadArtifactStep("Publish NuGet Packages") - { - Name = "nuget", - Path = "artifacts/nuget/", - If = "always()" - }); - - return configuration; - } -} diff --git a/.build/AirframeBuild.GitHubActions.cs b/.build/AirframeBuild.GitHubActions.cs new file mode 100644 index 000000000..49c0124bc --- /dev/null +++ b/.build/AirframeBuild.GitHubActions.cs @@ -0,0 +1,128 @@ +using Nuke.Common; +using Nuke.Common.Tools.DotNet; +using System.Collections.Generic; +using System.Linq; +using Nuke.Common.CI.GitHubActions; +using Rocket.Surgery.Nuke.ContinuousIntegration; +using Rocket.Surgery.Nuke.DotNetCore; +using Rocket.Surgery.Nuke.GithubActions; +using System; +using static GitHubActionsTasks; + +[GitHubActionsSteps( + "ci", + GitHubActionsImage.MacOsLatest, + AutoGenerate = true, + On = [RocketSurgeonGitHubActionsTrigger.Push], + OnPushTags = ["v*"], + OnPushBranches = ["master", "next", "feature/*"], + OnPullRequestBranches = ["master", "next"], + InvokedTargets = [nameof(GitHubActions)], + NonEntryTargets = + [ + nameof(ICIEnvironment.CIEnvironment), + nameof(ITriggerCodeCoverageReports.TriggerCodeCoverageReports), + nameof(ITriggerCodeCoverageReports.GenerateCodeCoverageReportCobertura), + nameof(IGenerateCodeCoverageBadges.GenerateCodeCoverageBadges), + nameof(IGenerateCodeCoverageReport.GenerateCodeCoverageReport), + nameof(IGenerateCodeCoverageSummary.GenerateCodeCoverageSummary), + nameof(Default) + ], + ExcludedTargets = [nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore)], + Enhancements = [nameof(Middleware)] +)] +[PrintBuildVersion, PrintCIEnvironment, UploadLogs] +[LocalBuildConventions] +[ContinuousIntegrationConventions] +public partial class AirframeBuild +{ + public Target GitHubActions => definition => definition + .OnlyWhenStatic(IsRunningOnGitHubActions) + .DependsOn(Workloads) + .DependsOn(Restore) + .DependsOn(Build) + .DependsOn(Test) + .DependsOn(Pack) + .Executes(); + + public Target Workloads => definition => definition + .Before(Restore) + .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.SetWorkloadId("ios"))); + + public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) + { + var buildJob = configuration.Jobs.Cast().First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase)); + var checkoutStep = buildJob.Steps.OfType().Single(); + // For fetch all + checkoutStep.FetchDepth = 0; + buildJob.Steps.InsertRange( + buildJob.Steps.IndexOf(checkoutStep) + 1, + new BaseGitHubActionsStep[] + { + new RunStep("Fetch all history for all tags and branches") + { + Run = "git fetch --prune" + }, + new SetupDotNetStep("Use .NET 8 SDK") + { + DotNetVersion = "8.0.101" + } + } + ); + + buildJob.Steps.Add( + new UsingStep("Publish Coverage") + { + Uses = "codecov/codecov-action@v1", + With = new Dictionary + { + ["name"] = "actions-${{ matrix.os }}", + } + } + ); + + buildJob.Steps.Add( + new UploadArtifactStep("Publish logs") + { + Name = "logs", + Path = "artifacts/logs/", + If = "always()" + } + ); + + buildJob.Steps.Add( + new UploadArtifactStep("Publish coverage data") + { + Name = "coverage", + Path = "coverage/", + If = "always()" + } + ); + + buildJob.Steps.Add( + new UploadArtifactStep("Publish test data") + { + Name = "test data", + Path = "artifacts/test/", + If = "always()" + } + ); + + buildJob.Steps.Add( + new UploadArtifactStep("Publish NuGet Packages") + { + Name = "nuget", + Path = "artifacts/nuget/", + If = "always()" + } + ); + + return configuration; + } +} + +public static class GitHubActionsTasks +{ + public static Func IsRunningOnGitHubActions => () + => NukeBuild.Host is GitHubActions || Environment.GetEnvironmentVariable("GITHUB_ACTIONS") == true.ToString(); +} \ No newline at end of file diff --git a/.build/AirframeBuild.cs b/.build/AirframeBuild.cs index 80e8344dd..aceb483ff 100644 --- a/.build/AirframeBuild.cs +++ b/.build/AirframeBuild.cs @@ -53,14 +53,11 @@ public partial class AirframeBuild : NukeBuild, .DependsOn(Test) .DependsOn(Pack); - public Target Clean => definition => definition.Inherit(x => x.Clean); - public Target Restore => definition => definition.Inherit(x => x.CoreRestore); - public Target Build => definition => definition.Inherit(x => x.CoreBuild); - - public Target Test => definition => definition.Inherit(x => x.CoreTest); - - - public Target Pack => definition => definition.Inherit(x => x.CorePack) + public Target Clean => definition => definition.Inherit(canClean => canClean.Clean); + public Target Restore => definition => definition.Inherit(dotNetCore => dotNetCore.CoreRestore); + public Target Build => definition => definition.Inherit(dotNetCore => dotNetCore.CoreBuild); + public Target Test => definition => definition.Inherit(dotNetCore => dotNetCore.CoreTest); + public Target Pack => definition => definition.Inherit(dotNetCore => dotNetCore.CorePack) .DependsOn(Clean) .After(Test); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d82d054ed..da3c14964 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,10 @@ jobs: - name: 🎁 dotnet tool restore run: | dotnet tool restore + - name: Workloads + id: workloads + run: | + dotnet nuke Workloads --skip - name: 🎁 Restore id: restore run: | @@ -78,6 +82,10 @@ jobs: id: pack run: | dotnet nuke Pack --skip + - name: Git Hub Actions + id: gitHubActions + run: | + dotnet nuke GitHubActions --skip - name: 🐿 Publish Coverage uses: codecov/codecov-action@v3.1.4 with: From 49d1992c890af5322de0b698de5af475d25c9da3 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:46:44 -0600 Subject: [PATCH 11/14] chore: i believe Build is now build --- .build/AirframeBuild.GitHubActions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build/AirframeBuild.GitHubActions.cs b/.build/AirframeBuild.GitHubActions.cs index 49c0124bc..b704501b8 100644 --- a/.build/AirframeBuild.GitHubActions.cs +++ b/.build/AirframeBuild.GitHubActions.cs @@ -51,7 +51,7 @@ public partial class AirframeBuild public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) { - var buildJob = configuration.Jobs.Cast().First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase)); + var buildJob = configuration.Jobs.Cast().First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase)); var checkoutStep = buildJob.Steps.OfType().Single(); // For fetch all checkoutStep.FetchDepth = 0; From ad9adff31327a42ed1d8867a6ab2423fe0b87899 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:48:26 -0600 Subject: [PATCH 12/14] chore: maccatalyst --- .build/AirframeBuild.GitHubActions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build/AirframeBuild.GitHubActions.cs b/.build/AirframeBuild.GitHubActions.cs index b704501b8..13a6c34b5 100644 --- a/.build/AirframeBuild.GitHubActions.cs +++ b/.build/AirframeBuild.GitHubActions.cs @@ -47,7 +47,7 @@ public partial class AirframeBuild public Target Workloads => definition => definition .Before(Restore) - .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.SetWorkloadId("ios"))); + .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.SetWorkloadId("ios", "maccatalyst"))); public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) { From 6a7d449f6b81098e84e8372c6db77b23c167cde5 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:08:33 -0600 Subject: [PATCH 13/14] chore: add workload --- .build/AirframeBuild.GitHubActions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build/AirframeBuild.GitHubActions.cs b/.build/AirframeBuild.GitHubActions.cs index 13a6c34b5..2a253e22c 100644 --- a/.build/AirframeBuild.GitHubActions.cs +++ b/.build/AirframeBuild.GitHubActions.cs @@ -47,7 +47,7 @@ public partial class AirframeBuild public Target Workloads => definition => definition .Before(Restore) - .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.SetWorkloadId("ios", "maccatalyst"))); + .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.AddWorkloadId("ios", "maccatalyst"))); public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) { From 02382113bbba87e0d660ce9952ac12817ddb4ff7 Mon Sep 17 00:00:00 2001 From: rlittlesii <6969701+RLittlesII@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:00:27 -0600 Subject: [PATCH 14/14] chore: reduce the framework for the build sake --- .build/AirframeBuild.GitHubActions.cs | 2 +- src/Apple/Apple.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.build/AirframeBuild.GitHubActions.cs b/.build/AirframeBuild.GitHubActions.cs index 2a253e22c..24c938410 100644 --- a/.build/AirframeBuild.GitHubActions.cs +++ b/.build/AirframeBuild.GitHubActions.cs @@ -47,7 +47,7 @@ public partial class AirframeBuild public Target Workloads => definition => definition .Before(Restore) - .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.AddWorkloadId("ios", "maccatalyst"))); + .Executes(() => DotNetTasks.DotNetWorkloadInstall(configurator => configurator.AddWorkloadId("ios"))); public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) { diff --git a/src/Apple/Apple.csproj b/src/Apple/Apple.csproj index 679469fa7..4146fffbc 100644 --- a/src/Apple/Apple.csproj +++ b/src/Apple/Apple.csproj @@ -1,7 +1,7 @@ - net8.0-ios;net8.0-maccatalyst + net8.0-ios Rocket.Surgery.Airframe.Apple Rocket.Surgery.Airframe.Apple latest