From f396c32159999686831c2801d4b7c4a538fd54a3 Mon Sep 17 00:00:00 2001 From: Glenn <5834289+glennawatson@users.noreply.github.com> Date: Wed, 4 Sep 2019 20:22:35 +1000 Subject: [PATCH] housekeeping: Release 10.0 (#2102) --- .github/CODEOWNERS | 4 +- CONTRIBUTING.md | 4 +- README.md | 1 - integrationtests/Directory.Build.props | 2 +- .../IntegrationTests.Shared.Tests.csproj | 6 +- .../IntegrationTests.Shared.csproj | 1 + .../IntegrationTests.UWP.csproj | 4 +- .../IntegrationTests.WPF.csproj | 4 +- .../IntegrationTests.XamarinForms.UWP.csproj | 4 +- src/Directory.build.props | 2 +- src/Directory.build.targets | 2 +- .../ReactiveAppCompatActivity.cs | 18 +- .../ReactiveFragmentActivity.cs | 18 +- .../ReactiveRecyclerViewViewHolder.cs | 4 +- .../PlatformOperations.cs} | 16 +- .../Properties/launchSettings.json | 27 + .../ReactiveComponentBase.cs | 130 ++ .../ReactiveLayoutComponentBase.cs | 124 ++ .../ReactiveUI.Blazor.csproj | 16 + src/ReactiveUI.Blazor/Registrations.cs | 44 + .../{net461 => net4}/ObservableTrigger.cs | 0 src/ReactiveUI.Blend/ReactiveUI.Blend.csproj | 2 +- .../ReactiveUI.Events.WPF.csproj | 22 +- .../ReactiveUI.Events.Winforms.csproj | 26 +- .../ReactiveUI.Events.csproj | 1 + src/ReactiveUI.Fody.Tests/FodyWeavers.xsd | 1 + .../ReactiveUI.Testing.csproj | 2 +- .../ApiApprovalTests.ReactiveUI.approved.txt | 178 +-- ...provalTests.ReactiveUI.net461.approved.txt | 269 ++-- ...ests.ReactiveUI.netcoreapp2.0.approved.txt | 269 ++-- ...ests.ReactiveUI.netcoreapp3.0.approved.txt | 837 +++++++++++++ ...alTests.Testing.netcoreapp3.0.approved.txt | 43 + .../Activation/ActivatingViewFetcher.cs | 2 +- .../Activation/ActivatingViewModel.cs | 2 +- src/ReactiveUI.Tests/Platforms/uwp/App.xaml | 7 - .../Platforms/uwp/App.xaml.cs | 41 - .../Legacy/ControlsReactiveCollectionTest.cs | 97 -- .../Legacy/Mocks/LegacyPropertyBindView.cs | 55 - .../Mocks/LegacyPropertyBindViewModel.cs | 87 -- ...ApprovalTests.Winforms.net461.approved.txt | 54 +- ...lTests.Winforms.netcoreapp3.0.approved.txt | 109 ++ .../Platforms/winforms/CommandBindingTests.cs | 4 +- .../Platforms/winforms/Mocks/TestControl.cs | 2 +- .../Platforms/winforms/Mocks/TestForm.cs | 2 +- .../winforms/ReactiveBindingListTests.cs | 221 ---- .../ApiApprovalTests.Wpf.net461.approved.txt | 12 +- ...provalTests.Wpf.netcoreapp3.0.approved.txt | 132 ++ .../Platforms/wpf/Mocks/WpfTestUserControl.cs | 2 +- .../WpfCommandBindingImplementationTests.cs | 2 +- src/ReactiveUI.Tests/ReactiveUI.Tests.csproj | 83 +- .../Utilities/ApiApprovalBase.cs | 2 +- .../Utilities/CountingTestScheduler.cs | 10 +- src/ReactiveUI.Tests/Utilities/TestLogger.cs | 12 +- .../ReactiveNotifyPropertyChangedMixinTest.cs | 561 +++++---- .../ActivationForViewFetcher.cs | 2 +- ...tformRegistrations.cs => Registrations.cs} | 2 +- src/ReactiveUI.Uno/WinRTAppDataDriver.cs | 79 -- .../ActivationForViewFetcher.cs | 40 +- .../CreatesWinformsCommandBinding.cs | 20 +- .../PropertyChangingEventManager.cs | 1 + .../IReactiveDerivedBindingList.cs | 28 - .../ObservableCollectionMixin.cs | 176 --- .../ReactiveBindingList.cs | 131 -- .../ReactiveDerivedBindingList.cs | 94 -- .../ReactiveUI.Winforms.csproj | 16 +- src/ReactiveUI.Winforms/Registrations.cs | 3 + .../WinformsCreatesObservableForProperty.cs | 10 +- .../ActivationForViewFetcher.cs | 32 +- src/ReactiveUI.Wpf/AutoSuspendHelper.cs | 44 +- src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj | 14 +- src/ReactiveUI.Wpf/Registrations.cs | 3 + .../ActivationForViewFetcher.cs | 56 +- src/ReactiveUI.XamForms/RoutedViewHost.cs | 13 +- src/ReactiveUI.sln | 63 +- .../Activation/CanActivateViewFetcher.cs | 4 +- .../Activation/IActivationForViewFetcher.cs | 2 +- src/ReactiveUI/Activation/ViewForMixins.cs | 24 +- .../Bindings/Command/CreatesCommandBinding.cs | 12 +- .../Command/CreatesCommandBindingViaEvent.cs | 16 +- .../Property/IPropertyBinderImplementation.cs | 4 +- .../Property/PropertyBinderImplementation.cs | 20 +- .../Property/PropertyBindingMixins.cs | 8 +- .../EventHandlers/INotifyPropertyChanging.cs | 22 - .../PropertyChangingEventArgs.cs | 30 - .../PropertyChangingEventHandler.cs | 15 - .../CollectionChangingEventManager.cs | 15 - .../PropertyChangingEventManager.cs | 2 + src/ReactiveUI/Expression/Reflection.cs | 18 +- .../{IActivatable.cs => IActivatableView.cs} | 2 +- ...Activation.cs => IActivatableViewModel.cs} | 2 +- src/ReactiveUI/Interfaces/IViewFor.cs | 2 +- .../ReactivePropertyChangingEventArgs.cs | 2 + src/ReactiveUI/Legacy/IMoveInfo.cs | 33 - .../Legacy/INotifyCollectionChanging.cs | 22 - src/ReactiveUI/Legacy/IReactiveCollection.cs | 30 - src/ReactiveUI/Legacy/IReactiveDerivedList.cs | 20 - src/ReactiveUI/Legacy/IReactiveList.cs | 75 -- .../IReactiveNotifyCollectionChanged.cs | 105 -- .../IReactiveNotifyCollectionItemChanged.cs | 37 - .../Legacy/IReadOnlyReactiveCollection.cs | 25 - .../Legacy/IReadOnlyReactiveList.cs | 29 - src/ReactiveUI/Legacy/MoveInfo.cs | 29 - .../Legacy/ObservableCollectionMixin.cs | 230 ---- .../Legacy/ReactiveCollectionMixins.cs | 85 -- .../Legacy/ReactiveDerivedCollection.cs | 872 ------------- ...ReactiveDerivedCollectionFromObservable.cs | 75 -- src/ReactiveUI/Legacy/ReactiveList.cs | 1084 ----------------- .../Mixins/DependencyResolverMixins.cs | 7 +- .../ReactiveNotifyPropertyChangedMixin.cs | 16 +- .../INPCObservableForProperty.cs | 36 +- .../android/AndroidObservableForWidgets.cs | 58 +- .../android/FlexibleCommandBinder.cs | 12 +- .../Platforms/android/ReactiveActivity.cs | 18 +- .../Platforms/android/ReactiveListAdapter.cs | 97 -- .../android/ReactivePreferenceActivity.cs | 18 +- .../apple-common/KVOObservableForProperty.cs | 10 +- .../apple-common/TargetActionCommandBinder.cs | 10 +- .../ComponentModelTypeConverter.cs | 14 +- .../{net461 => net4}/PlatformRegistrations.cs | 0 .../PlatformRegistrations.cs | 0 .../ComponentModelTypeConverter.cs | 86 ++ .../netcoreapp3/PlatformRegistrations.cs | 29 + .../Platforms/uap/ActivationForViewFetcher.cs | 21 +- .../uap/SingleWindowDispatcherScheduler.cs | 13 +- .../uikit-common/CommonReactiveSource.cs | 26 +- .../uikit-common/FlexibleCommandBinder.cs | 20 +- .../ReactiveCollectionViewSource.cs | 3 +- .../ReactiveCollectionViewSourceExtensions.cs | 3 +- .../ReactiveNavigationController.cs | 2 +- .../uikit-common/ReactiveTableViewSource.cs | 3 - .../ReactiveTableViewSourceExtensions.cs | 2 +- .../AutoDataTemplateBindingHook.cs | 2 + .../windows-common/RoutedViewHost.cs | 24 +- .../windows-common/ViewModelViewHost.cs | 10 +- .../ComponentModelTypeConverter.cs | 14 +- src/ReactiveUI/Properties/AssemblyInfo.cs | 1 + .../CombinedReactiveCommand.cs | 3 +- .../ReactiveCommand/ReactiveCommand.cs | 3 +- .../ReactiveCommand/ReactiveCommandBase.cs | 7 +- .../ReactiveCommand/ReactiveCommandMixins.cs | 29 +- src/ReactiveUI/ReactiveUI.csproj | 29 +- src/ReactiveUI/Routing/MessageBus.cs | 22 +- src/ReactiveUI/VariadicTemplates.cs | 24 +- src/ReactiveUI/VariadicTemplates.tt | 4 +- version.json | 4 +- 145 files changed, 2802 insertions(+), 5236 deletions(-) rename src/{ReactiveUI/EventManagers/CollectionChangedEventManager.cs => ReactiveUI.Blazor/PlatformOperations.cs} (50%) create mode 100644 src/ReactiveUI.Blazor/Properties/launchSettings.json create mode 100644 src/ReactiveUI.Blazor/ReactiveComponentBase.cs create mode 100644 src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs create mode 100644 src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj create mode 100644 src/ReactiveUI.Blazor/Registrations.cs rename src/ReactiveUI.Blend/Platforms/{net461 => net4}/ObservableTrigger.cs (100%) create mode 100644 src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.0.approved.txt create mode 100644 src/ReactiveUI.Tests/API/ApiApprovalTests.Testing.netcoreapp3.0.approved.txt delete mode 100644 src/ReactiveUI.Tests/Platforms/uwp/App.xaml delete mode 100644 src/ReactiveUI.Tests/Platforms/uwp/App.xaml.cs delete mode 100644 src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/ControlsReactiveCollectionTest.cs delete mode 100644 src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindView.cs delete mode 100644 src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindViewModel.cs create mode 100644 src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.netcoreapp3.0.approved.txt delete mode 100644 src/ReactiveUI.Tests/Platforms/winforms/ReactiveBindingListTests.cs create mode 100644 src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.netcoreapp3.0.approved.txt rename src/ReactiveUI.Uno/{PlatformRegistrations.cs => Registrations.cs} (96%) delete mode 100644 src/ReactiveUI.Uno/WinRTAppDataDriver.cs delete mode 100644 src/ReactiveUI.Winforms/IReactiveDerivedBindingList.cs delete mode 100644 src/ReactiveUI.Winforms/ObservableCollectionMixin.cs delete mode 100644 src/ReactiveUI.Winforms/ReactiveBindingList.cs delete mode 100644 src/ReactiveUI.Winforms/ReactiveDerivedBindingList.cs delete mode 100644 src/ReactiveUI/EventHandlers/INotifyPropertyChanging.cs delete mode 100644 src/ReactiveUI/EventHandlers/PropertyChangingEventArgs.cs delete mode 100644 src/ReactiveUI/EventHandlers/PropertyChangingEventHandler.cs delete mode 100644 src/ReactiveUI/EventManagers/CollectionChangingEventManager.cs rename src/ReactiveUI/Interfaces/{IActivatable.cs => IActivatableView.cs} (93%) rename src/ReactiveUI/Interfaces/{ISupportsActivation.cs => IActivatableViewModel.cs} (95%) delete mode 100644 src/ReactiveUI/Legacy/IMoveInfo.cs delete mode 100644 src/ReactiveUI/Legacy/INotifyCollectionChanging.cs delete mode 100644 src/ReactiveUI/Legacy/IReactiveCollection.cs delete mode 100644 src/ReactiveUI/Legacy/IReactiveDerivedList.cs delete mode 100644 src/ReactiveUI/Legacy/IReactiveList.cs delete mode 100644 src/ReactiveUI/Legacy/IReactiveNotifyCollectionChanged.cs delete mode 100644 src/ReactiveUI/Legacy/IReactiveNotifyCollectionItemChanged.cs delete mode 100644 src/ReactiveUI/Legacy/IReadOnlyReactiveCollection.cs delete mode 100644 src/ReactiveUI/Legacy/IReadOnlyReactiveList.cs delete mode 100644 src/ReactiveUI/Legacy/MoveInfo.cs delete mode 100644 src/ReactiveUI/Legacy/ObservableCollectionMixin.cs delete mode 100644 src/ReactiveUI/Legacy/ReactiveCollectionMixins.cs delete mode 100644 src/ReactiveUI/Legacy/ReactiveDerivedCollection.cs delete mode 100644 src/ReactiveUI/Legacy/ReactiveDerivedCollectionFromObservable.cs delete mode 100644 src/ReactiveUI/Legacy/ReactiveList.cs delete mode 100644 src/ReactiveUI/Platforms/android/ReactiveListAdapter.cs rename src/ReactiveUI/Platforms/{net461 => net4}/ComponentModelTypeConverter.cs (81%) rename src/ReactiveUI/Platforms/{net461 => net4}/PlatformRegistrations.cs (100%) rename src/ReactiveUI/Platforms/{netcoreapp2.0 => netcoreapp2}/PlatformRegistrations.cs (100%) create mode 100644 src/ReactiveUI/Platforms/netcoreapp3/ComponentModelTypeConverter.cs create mode 100644 src/ReactiveUI/Platforms/netcoreapp3/PlatformRegistrations.cs diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 33045bb74..15bebd94b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -24,8 +24,8 @@ src/ReactiveUI/Platforms/apple-common/* @reactiveui/ios-team @reactiveui/mac- src/ReactiveUI/Platforms/ios/* @reactiveui/ios-team src/ReactiveUI/Platforms/mac/* @reactiveui/mac-team src/ReactiveUI/Platforms/net461/* @reactiveui/wpf-team @reactiveui/winforms-team -src/ReactiveUI/Platforms/netcoreapp2.0/* @reactiveui/dotnetcore-team @reactiveui/webassembly-team -src/ReactiveUI/Platforms/uap/* @reactiveui/uwp-team +src/ReactiveUI/Platforms/netcoreapp/* @reactiveui/dotnetcore-team @reactiveui/webassembly-team +src/ReactiveUI/Platforms/uap10/* @reactiveui/uwp-team src/ReactiveUI/Platforms/tizen/* @reactiveui/tizen-team src/ReactiveUI/Platforms/tvos/* @reactiveui/tvos-team src/ReactiveUI/Platforms/windows-common/* @reactiveui/wpf-team @reactiveui/winforms-team @reactiveui/uwp-team diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 25628b350..25d815ff1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -142,12 +142,12 @@ from the main (upstream) repository: ## Coding ### Developer Environment -- Visual Studio 2017 (with latest patches/updates), with the following workloads/components +- Visual Studio 2019 (with latest patches/updates), with the following workloads/components - Windows Universal Platform Development workload - .NET desktop development workload - Mobile development with .NET workload - .NET Core cross-platform development - - Windows 10 SDK 10.0.16299 (individual component) + - Windows 10 SDK 10.0.17763.0 (individual component) - PowerShell - Android SDK Platform 26 (install through Visual Studio) diff --git a/README.md b/README.md index 702520c0c..c1f1bb091 100644 --- a/README.md +++ b/README.md @@ -407,4 +407,3 @@ This is how we use the donations: [Become a backer](https://opencollective.com/reactiveui#backer) and get your image on our README on Github with a link to your site. - diff --git a/integrationtests/Directory.Build.props b/integrationtests/Directory.Build.props index 771ccf8e1..bdac84f34 100644 --- a/integrationtests/Directory.Build.props +++ b/integrationtests/Directory.Build.props @@ -32,5 +32,5 @@ - + diff --git a/integrationtests/IntegrationTests.Shared.Tests/IntegrationTests.Shared.Tests.csproj b/integrationtests/IntegrationTests.Shared.Tests/IntegrationTests.Shared.Tests.csproj index a8edf01d0..59f93d4fd 100644 --- a/integrationtests/IntegrationTests.Shared.Tests/IntegrationTests.Shared.Tests.csproj +++ b/integrationtests/IntegrationTests.Shared.Tests/IntegrationTests.Shared.Tests.csproj @@ -15,8 +15,8 @@ - - + + @@ -29,7 +29,7 @@ all runtime; build; native; contentfiles; analyzers - + diff --git a/integrationtests/IntegrationTests.Shared/IntegrationTests.Shared.csproj b/integrationtests/IntegrationTests.Shared/IntegrationTests.Shared.csproj index 473445a61..0c5e87dbb 100644 --- a/integrationtests/IntegrationTests.Shared/IntegrationTests.Shared.csproj +++ b/integrationtests/IntegrationTests.Shared/IntegrationTests.Shared.csproj @@ -1,4 +1,5 @@  + netstandard2.0 diff --git a/integrationtests/IntegrationTests.UWP/IntegrationTests.UWP.csproj b/integrationtests/IntegrationTests.UWP/IntegrationTests.UWP.csproj index f03796941..cec7d6077 100644 --- a/integrationtests/IntegrationTests.UWP/IntegrationTests.UWP.csproj +++ b/integrationtests/IntegrationTests.UWP/IntegrationTests.UWP.csproj @@ -11,8 +11,8 @@ IntegrationTests.UWP en-US UAP - 10.0.16299.0 - 10.0.16299.0 + 10.0.17763.0 + 10.0.17763.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} diff --git a/integrationtests/IntegrationTests.WPF/IntegrationTests.WPF.csproj b/integrationtests/IntegrationTests.WPF/IntegrationTests.WPF.csproj index 6704b3901..1eb396b0d 100644 --- a/integrationtests/IntegrationTests.WPF/IntegrationTests.WPF.csproj +++ b/integrationtests/IntegrationTests.WPF/IntegrationTests.WPF.csproj @@ -30,8 +30,8 @@ - + - + \ No newline at end of file diff --git a/integrationtests/IntegrationTests.XamarinForms.UWP/IntegrationTests.XamarinForms.UWP.csproj b/integrationtests/IntegrationTests.XamarinForms.UWP/IntegrationTests.XamarinForms.UWP.csproj index 7a7fad814..3d34c646f 100644 --- a/integrationtests/IntegrationTests.XamarinForms.UWP/IntegrationTests.XamarinForms.UWP.csproj +++ b/integrationtests/IntegrationTests.XamarinForms.UWP/IntegrationTests.XamarinForms.UWP.csproj @@ -11,8 +11,8 @@ IntegrationTests.XamarinForms.UWP en-US UAP - 10.0.16299.0 - 10.0.16299.0 + 10.0.17763.0 + 10.0.17763.0 14 true 512 diff --git a/src/Directory.build.props b/src/Directory.build.props index f74e34561..ae08dd9dd 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -66,7 +66,7 @@ - + diff --git a/src/Directory.build.targets b/src/Directory.build.targets index 3499585b3..a0f128bca 100644 --- a/src/Directory.build.targets +++ b/src/Directory.build.targets @@ -4,7 +4,7 @@ $(AssemblyName) ($(TargetFramework)) - + $(DefineConstants);NETSTANDARD;PORTABLE diff --git a/src/ReactiveUI.AndroidSupport/ReactiveAppCompatActivity.cs b/src/ReactiveUI.AndroidSupport/ReactiveAppCompatActivity.cs index e7f9ac7d1..db915c559 100644 --- a/src/ReactiveUI.AndroidSupport/ReactiveAppCompatActivity.cs +++ b/src/ReactiveUI.AndroidSupport/ReactiveAppCompatActivity.cs @@ -60,7 +60,7 @@ public class ReactiveAppCompatActivity : AppCompatActivity, IReactiveObject, IRe { private readonly Subject _activated = new Subject(); private readonly Subject _deactivated = new Subject(); - private readonly Subject> _activityResult = new Subject>(); + private readonly Subject<(int requestCode, Result result, Intent intent)> _activityResult = new Subject<(int requestCode, Result result, Intent intent)>(); /// /// Initializes a new instance of the class. @@ -124,7 +124,7 @@ public event PropertyChangedEventHandler PropertyChanged /// /// The activity result. /// - public IObservable> ActivityResult => _activityResult.AsObservable(); + public IObservable<(int requestCode, Result result, Intent intent)> ActivityResult => _activityResult.AsObservable(); /// void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) @@ -150,13 +150,13 @@ public IDisposable SuppressChangeNotifications() /// The intent. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Intent intent, int requestCode) + public Task<(Result result, Intent intent)> StartActivityForResultAsync(Intent intent, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.result, x.intent)) .FirstAsync() .ToTask(); @@ -170,13 +170,13 @@ public Task> StartActivityForResultAsync(Intent intent, in /// The type. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Type type, int requestCode) + public Task<(Result result, Intent intent)> StartActivityForResultAsync(Type type, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.result, x.intent)) .FirstAsync() .ToTask(); @@ -202,7 +202,7 @@ protected override void OnResume() protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); - _activityResult.OnNext(Tuple.Create(requestCode, resultCode, data)); + _activityResult.OnNext((requestCode, resultCode, data)); } /// diff --git a/src/ReactiveUI.AndroidSupport/ReactiveFragmentActivity.cs b/src/ReactiveUI.AndroidSupport/ReactiveFragmentActivity.cs index 8e29d1d61..5b1ce6099 100644 --- a/src/ReactiveUI.AndroidSupport/ReactiveFragmentActivity.cs +++ b/src/ReactiveUI.AndroidSupport/ReactiveFragmentActivity.cs @@ -74,7 +74,7 @@ public class ReactiveFragmentActivity : FragmentActivity, IReactiveObject, IReac { private readonly Subject _activated = new Subject(); private readonly Subject _deactivated = new Subject(); - private readonly Subject> _activityResult = new Subject>(); + private readonly Subject<(int requestCode, Result result, Intent intent)> _activityResult = new Subject<(int requestCode, Result result, Intent intent)>(); /// public event PropertyChangingEventHandler PropertyChanging @@ -112,7 +112,7 @@ public event PropertyChangedEventHandler PropertyChanged /// /// Gets the activity result. /// - public IObservable> ActivityResult => _activityResult.AsObservable(); + public IObservable<(int requestCode, Result result, Intent intent)> ActivityResult => _activityResult.AsObservable(); /// void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) @@ -135,13 +135,13 @@ void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) /// The intent. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Intent intent, int requestCode) + public Task<(Result result, Intent intent)> StartActivityForResultAsync(Intent intent, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.result, x.intent)) .FirstAsync() .ToTask(); @@ -155,13 +155,13 @@ public Task> StartActivityForResultAsync(Intent intent, in /// The type. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Type type, int requestCode) + public Task<(Result result, Intent intent)> StartActivityForResultAsync(Type type, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.result, x.intent)) .FirstAsync() .ToTask(); @@ -187,7 +187,7 @@ protected override void OnResume() protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); - _activityResult.OnNext(Tuple.Create(requestCode, resultCode, data)); + _activityResult.OnNext((requestCode, resultCode, data)); } /// diff --git a/src/ReactiveUI.AndroidSupport/ReactiveRecyclerViewViewHolder.cs b/src/ReactiveUI.AndroidSupport/ReactiveRecyclerViewViewHolder.cs index 23fac0013..319602da6 100644 --- a/src/ReactiveUI.AndroidSupport/ReactiveRecyclerViewViewHolder.cs +++ b/src/ReactiveUI.AndroidSupport/ReactiveRecyclerViewViewHolder.cs @@ -104,7 +104,7 @@ public event PropertyChangedEventHandler PropertyChanged /// /// Gets an observable that signals that this ViewHolder has been selected. /// - /// The is the ViewModel of this ViewHolder in the . + /// The is the ViewModel of this ViewHolder in the . /// public IObservable SelectedWithViewModel { get; } @@ -119,7 +119,7 @@ public event PropertyChangedEventHandler PropertyChanged /// /// Gets an observable that signals that this ViewHolder has been long-clicked. /// - /// The is the ViewModel of this ViewHolder in the . + /// The is the ViewModel of this ViewHolder in the . /// public IObservable LongClickedWithViewModel { get; } diff --git a/src/ReactiveUI/EventManagers/CollectionChangedEventManager.cs b/src/ReactiveUI.Blazor/PlatformOperations.cs similarity index 50% rename from src/ReactiveUI/EventManagers/CollectionChangedEventManager.cs rename to src/ReactiveUI.Blazor/PlatformOperations.cs index fbe11a1f8..5895193b4 100644 --- a/src/ReactiveUI/EventManagers/CollectionChangedEventManager.cs +++ b/src/ReactiveUI.Blazor/PlatformOperations.cs @@ -3,13 +3,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -using System.Collections.Specialized; - -namespace ReactiveUI +namespace ReactiveUI.Blazor { -#if !NET_461 - internal class CollectionChangedEventManager : WeakEventManager + /// + /// Returns the current orientation of the device on Windows. + /// + public class PlatformOperations : IPlatformOperations { + /// + public string GetOrientation() + { + return null; + } } -#endif } diff --git a/src/ReactiveUI.Blazor/Properties/launchSettings.json b/src/ReactiveUI.Blazor/Properties/launchSettings.json new file mode 100644 index 000000000..c2b293457 --- /dev/null +++ b/src/ReactiveUI.Blazor/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50286/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "ReactiveUI.Blazor": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:50291/" + } + } +} \ No newline at end of file diff --git a/src/ReactiveUI.Blazor/ReactiveComponentBase.cs b/src/ReactiveUI.Blazor/ReactiveComponentBase.cs new file mode 100644 index 000000000..44fdac13f --- /dev/null +++ b/src/ReactiveUI.Blazor/ReactiveComponentBase.cs @@ -0,0 +1,130 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Reactive; +using System.Reactive.Linq; +using System.Reactive.Subjects; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace ReactiveUI.Blazor +{ + /// + /// A base component for handling property changes and updating the blazer view appropriately. + /// + /// The type of view model. Must support INotifyPropertyChanged. + public class ReactiveComponentBase : ComponentBase, IViewFor, INotifyPropertyChanged, ICanActivate, IDisposable + where T : class, INotifyPropertyChanged + { + private readonly Subject _initSubject = new Subject(); + [SuppressMessage("Design", "CA2213: Dispose object", Justification = "Used for deactivation.")] + private readonly Subject _deactivateSubject = new Subject(); + + private T _viewModel; + + private bool _disposedValue; // To detect redundant calls + + /// + /// Initializes a new instance of the class. + /// + public ReactiveComponentBase() + { + var propertyChangedObservable = this.WhenAnyValue(x => x.ViewModel) + .Select(x => Observable.FromEvent( + eventHandler => + { + void Handler(object sender, PropertyChangedEventArgs e) => eventHandler(Unit.Default); + + return Handler; + }, + eh => x.PropertyChanged += eh, + eh => x.PropertyChanged -= eh)) + .Switch(); + + propertyChangedObservable.Do(_ => StateHasChanged()).Subscribe(); + } + + /// + public event PropertyChangedEventHandler PropertyChanged; + + /// + public T ViewModel + { + get => _viewModel; + set + { + if (EqualityComparer.Default.Equals(_viewModel, value)) + { + return; + } + + _viewModel = value; + OnPropertyChanged(); + } + } + + /// + object IViewFor.ViewModel + { + get => ViewModel; + set => ViewModel = (T)value; + } + + /// + public IObservable Activated => _initSubject.AsObservable(); + + /// + public IObservable Deactivated => _deactivateSubject.AsObservable(); + + /// + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) below. + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected override void OnInit() + { + _initSubject.OnNext(Unit.Default); + base.OnInit(); + } + + /// + /// Invokes the property changed event. + /// + /// The name of the property. + protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + /// + /// Cleans up the managed resources of the object. + /// + /// If it is getting called by the Dispose() method rather than a finalizer. + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + _initSubject?.Dispose(); + + _deactivateSubject.OnNext(Unit.Default); + } + + _disposedValue = true; + } + } + } +} diff --git a/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs b/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs new file mode 100644 index 000000000..367384be6 --- /dev/null +++ b/src/ReactiveUI.Blazor/ReactiveLayoutComponentBase.cs @@ -0,0 +1,124 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reactive; +using System.Reactive.Linq; +using System.Reactive.Subjects; +using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Components.Layouts; + +namespace ReactiveUI.Blazor +{ + /// + /// A base component for handling property changes and updating the blazer view appropriately. + /// + /// The type of view model. Must support INotifyPropertyChanged. + public class ReactiveLayoutComponentBase : LayoutComponentBase, IViewFor, INotifyPropertyChanged, ICanActivate, IDisposable + where T : class, INotifyPropertyChanged + { + private readonly Subject _initSubject = new Subject(); + + private T _viewModel; + + private bool _disposedValue; // To detect redundant calls + + /// + /// Initializes a new instance of the class. + /// + public ReactiveLayoutComponentBase() + { + var propertyChangedObservable = this.WhenAnyValue(x => x.ViewModel) + .Select(x => Observable.FromEvent( + eventHandler => + { + void Handler(object sender, PropertyChangedEventArgs e) => eventHandler(Unit.Default); + + return Handler; + }, + eh => x.PropertyChanged += eh, + eh => x.PropertyChanged -= eh)) + .Switch(); + + propertyChangedObservable.Do(_ => StateHasChanged()).Subscribe(); + } + + /// + public event PropertyChangedEventHandler PropertyChanged; + + /// + public T ViewModel + { + get => _viewModel; + set + { + if (EqualityComparer.Default.Equals(_viewModel, value)) + { + return; + } + + _viewModel = value; + OnPropertyChanged(); + } + } + + /// + object IViewFor.ViewModel + { + get => ViewModel; + set => ViewModel = (T)value; + } + + /// + public IObservable Activated => _initSubject.AsObservable(); + + /// + public IObservable Deactivated => Observable.Empty(); + + /// + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) below. + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + protected override void OnInit() + { + _initSubject.OnNext(Unit.Default); + base.OnInit(); + } + + /// + /// Invokes the property changed event. + /// + /// The name of the property. + protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + /// + /// Cleans up the managed resources of the object. + /// + /// If it is getting called by the Dispose() method rather than a finalizer. + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + _initSubject?.Dispose(); + } + + _disposedValue = true; + } + } + } +} diff --git a/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj b/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj new file mode 100644 index 000000000..bdeec96ab --- /dev/null +++ b/src/ReactiveUI.Blazor/ReactiveUI.Blazor.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/src/ReactiveUI.Blazor/Registrations.cs b/src/ReactiveUI.Blazor/Registrations.cs new file mode 100644 index 000000000..d35862764 --- /dev/null +++ b/src/ReactiveUI.Blazor/Registrations.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Reactive.Concurrency; +using System.Reactive.PlatformServices; +using System.Text; + +namespace ReactiveUI.Blazor +{ + /// + /// Blazor Framework platform registrations. + /// + /// + public class Registrations : IWantsToRegisterStuff + { + /// + public void Register(Action, Type> registerFunction) + { + if (registerFunction is null) + { + throw new ArgumentNullException(nameof(registerFunction)); + } + + registerFunction(() => new PlatformOperations(), typeof(IPlatformOperations)); + +#if NETSTANDARD + if (WasmPlatformEnlightenmentProvider.IsWasm) + { + RxApp.TaskpoolScheduler = WasmScheduler.Default; + RxApp.MainThreadScheduler = WasmScheduler.Default; + } + else +#endif + { + RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; + RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => CurrentThreadScheduler.Instance); + } + } + } +} diff --git a/src/ReactiveUI.Blend/Platforms/net461/ObservableTrigger.cs b/src/ReactiveUI.Blend/Platforms/net4/ObservableTrigger.cs similarity index 100% rename from src/ReactiveUI.Blend/Platforms/net461/ObservableTrigger.cs rename to src/ReactiveUI.Blend/Platforms/net4/ObservableTrigger.cs diff --git a/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj b/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj index 026809555..3bcc18457 100644 --- a/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj +++ b/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/ReactiveUI.Events.WPF/ReactiveUI.Events.WPF.csproj b/src/ReactiveUI.Events.WPF/ReactiveUI.Events.WPF.csproj index 7fa338b6b..84747c5ec 100644 --- a/src/ReactiveUI.Events.WPF/ReactiveUI.Events.WPF.csproj +++ b/src/ReactiveUI.Events.WPF/ReactiveUI.Events.WPF.csproj @@ -1,6 +1,6 @@  - net461 + netcoreapp3.0;net461 ReactiveUI.Events Provides Observable-based events API for WPF UI controls/eventhandlers. The contents of this package is automatically generated, please target pull-requests to the code generator. ReactiveUI.Events.WPF @@ -15,7 +15,25 @@ - + + + + + + + + + + + + + + + + + + + diff --git a/src/ReactiveUI.Events.Winforms/ReactiveUI.Events.Winforms.csproj b/src/ReactiveUI.Events.Winforms/ReactiveUI.Events.Winforms.csproj index 3d174711c..6e2417384 100644 --- a/src/ReactiveUI.Events.Winforms/ReactiveUI.Events.Winforms.csproj +++ b/src/ReactiveUI.Events.Winforms/ReactiveUI.Events.Winforms.csproj @@ -1,12 +1,12 @@  - net461 + netcoreapp3.0;net461 ReactiveUI.Events.Winforms ReactiveUI.Events Provides Observable-based events API for Winforms UI controls/eventhandlers. The contents of this package is automatically generated, please target pull-requests to the code generator. ReactiveUI.Events.Winforms - true true + true $(NoWarn);CS1570;CA1812 @@ -14,9 +14,27 @@ - + - + + + + + + + + + + + + + + + + + + + diff --git a/src/ReactiveUI.Events/ReactiveUI.Events.csproj b/src/ReactiveUI.Events/ReactiveUI.Events.csproj index c54d4f9f2..46ee91edf 100644 --- a/src/ReactiveUI.Events/ReactiveUI.Events.csproj +++ b/src/ReactiveUI.Events/ReactiveUI.Events.csproj @@ -19,6 +19,7 @@ + diff --git a/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd b/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd index f3ac47620..5cedd530b 100644 --- a/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd +++ b/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd @@ -4,6 +4,7 @@ + diff --git a/src/ReactiveUI.Testing/ReactiveUI.Testing.csproj b/src/ReactiveUI.Testing/ReactiveUI.Testing.csproj index 23c603082..88910e9c9 100644 --- a/src/ReactiveUI.Testing/ReactiveUI.Testing.csproj +++ b/src/ReactiveUI.Testing/ReactiveUI.Testing.csproj @@ -1,7 +1,7 @@  netstandard2.0;netcoreapp2.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;MonoAndroid81 - $(TargetFrameworks);net461;uap10.0.16299 + $(TargetFrameworks);net461;uap10.0.16299;netcoreapp3.0 ReactiveUI.Testing ReactiveUI.Testing A library to aid in writing unit tests for ReactiveUI projects diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.approved.txt index d4bb95ab0..108e3719e 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.approved.txt @@ -40,7 +40,7 @@ namespace ReactiveUI public class CanActivateViewFetcher : ReactiveUI.IActivationForViewFetcher { public CanActivateViewFetcher() { } - public System.IObservable GetActivationForView(ReactiveUI.IActivatable view) { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } public int GetAffinityForView(System.Type view) { } } public class static ChangeSetMixin @@ -139,10 +139,10 @@ namespace ReactiveUI public static System.Reflection.MemberInfo GetMemberInfo(this System.Linq.Expressions.Expression expression) { } public static System.Linq.Expressions.Expression GetParent(this System.Linq.Expressions.Expression expression) { } } - public interface IActivatable { } + public interface IActivatableView { } public interface IActivationForViewFetcher { - System.IObservable GetActivationForView(ReactiveUI.IActivatable view); + System.IObservable GetActivationForView(ReactiveUI.IActivatableView view); int GetAffinityForView(System.Type view); } public interface IBindingTypeConverter : Splat.IEnableLogger @@ -186,10 +186,6 @@ namespace ReactiveUI void RegisterScheduler(System.Reactive.Concurrency.IScheduler scheduler, string contract = null); void SendMessage(T message, string contract = null); } - public interface INotifyCollectionChanging - { - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanging; - } public interface INotifyPropertyChanging { public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; @@ -304,7 +300,7 @@ namespace ReactiveUI { ReactiveUI.RoutingState Router { get; } } - public interface ISupportsActivation + public interface IActivatableViewModel { ReactiveUI.ViewModelActivator Activator { get; } } @@ -324,11 +320,11 @@ namespace ReactiveUI System.IObservable ShouldInvalidateState { get; set; } System.IObservable ShouldPersistState { get; set; } } - public interface IViewFor : ReactiveUI.IActivatable + public interface IViewFor : ReactiveUI.IActivatableView { object ViewModel { get; set; } } - public interface IViewFor : ReactiveUI.IActivatable, ReactiveUI.IViewFor + public interface IViewFor : ReactiveUI.IActivatableView, ReactiveUI.IViewFor where T : class { T ViewModel { get; set; } @@ -667,14 +663,14 @@ namespace ReactiveUI } public class static ViewForMixins { - public static void WhenActivated(this ReactiveUI.ISupportsActivation @this, System.Func> block) { } - public static void WhenActivated(this ReactiveUI.ISupportsActivation @this, System.Action> block) { } - public static void WhenActivated(this ReactiveUI.ISupportsActivation @this, System.Action block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable @this, System.Func> block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable @this, System.Func> block, ReactiveUI.IViewFor view) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable @this, System.Action> block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable @this, System.Action> block, ReactiveUI.IViewFor view) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable @this, System.Action block, ReactiveUI.IViewFor view = null) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel @this, System.Func> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel @this, System.Action> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel @this, System.Action block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView @this, System.Func> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView @this, System.Func> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView @this, System.Action> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView @this, System.Action> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView @this, System.Action block, ReactiveUI.IViewFor view = null) { } } public class static ViewLocator { @@ -854,152 +850,6 @@ namespace ReactiveUI where TSender : class { } } } -namespace ReactiveUI.Legacy -{ - public interface IMoveInfo - { - int From { get; } - System.Collections.Generic.IEnumerable MovedItems { get; } - int To { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveCollection : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - void Reset(); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveDerivedList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged, System.IDisposable { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - bool IsEmpty { get; } - void AddRange(System.Collections.Generic.IEnumerable collection); - void InsertRange(int index, System.Collections.Generic.IEnumerable collection); - void RemoveAll(System.Collections.Generic.IEnumerable items); - void RemoveRange(int index, int count); - void Sort(System.Collections.Generic.IComparer comparer = null); - void Sort(System.Comparison comparison); - void Sort(int index, int count, System.Collections.Generic.IComparer comparer); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionChanged - { - System.IObservable BeforeItemsAdded { get; } - System.IObservable> BeforeItemsMoved { get; } - System.IObservable BeforeItemsRemoved { get; } - System.IObservable Changed { get; } - System.IObservable Changing { get; } - System.IObservable CountChanged { get; } - System.IObservable CountChanging { get; } - System.IObservable IsEmptyChanged { get; } - System.IObservable ItemsAdded { get; } - System.IObservable> ItemsMoved { get; } - System.IObservable ItemsRemoved { get; } - System.IObservable ShouldReset { get; } - System.IDisposable SuppressChangeNotifications(); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionItemChanged - { - bool ChangeTrackingEnabled { get; set; } - System.IObservable> ItemChanged { get; } - System.IObservable> ItemChanging { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveCollection : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - bool IsEmpty { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ObservableCollectionMixin - { - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Action onRemoved, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Action onRemoved, System.Func filter = null, System.Func orderer = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Func filter = null, System.Func orderer = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ReactiveCollectionMixins - { - public static ReactiveUI.Legacy.IReactiveDerivedList CreateCollection(this System.IObservable fromObservable, System.Reactive.Concurrency.IScheduler scheduler) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateCollection(this System.IObservable fromObservable, System.Nullable withDelay = null, System.Action onError = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - } - [System.Diagnostics.DebuggerDisplayAttribute("Count = {Count}")] - [System.Diagnostics.DebuggerTypeProxyAttribute(typeof(ReactiveUI.CollectionDebugView<>))] - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class ReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveList, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - public ReactiveList() { } - public ReactiveList(System.Collections.Generic.IEnumerable initialContents) { } - public ReactiveList(System.Collections.Generic.IEnumerable initialContents = null, double resetChangeThreshold = 0.3, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public System.IObservable BeforeItemsAdded { get; } - public System.IObservable> BeforeItemsMoved { get; } - public System.IObservable BeforeItemsRemoved { get; } - public System.IObservable Changed { get; } - public bool ChangeTrackingEnabled { get; set; } - public System.IObservable Changing { get; } - public int Count { get; } - public System.IObservable CountChanged { get; } - public System.IObservable CountChanging { get; } - public bool IsEmpty { get; } - public System.IObservable IsEmptyChanged { get; } - public virtual bool IsReadOnly { get; } - public virtual T this[int index] { get; set; } - public System.IObservable> ItemChanged { get; } - public System.IObservable> ItemChanging { get; } - public System.IObservable ItemsAdded { get; } - public System.IObservable> ItemsMoved { get; } - public System.IObservable ItemsRemoved { get; } - [System.Runtime.Serialization.IgnoreDataMemberAttribute()] - public double ResetChangeThreshold { get; set; } - public System.IObservable ShouldReset { get; } - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanged; - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanging; - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; - public virtual void Add(T item) { } - public virtual void AddRange(System.Collections.Generic.IEnumerable collection) { } - public int BinarySearch(T item) { } - public int BinarySearch(T item, System.Collections.Generic.IComparer comparer) { } - public int BinarySearch(int index, int count, T item, System.Collections.Generic.IComparer comparer) { } - public virtual void Clear() { } - protected void ClearItems() { } - public bool Contains(T item) { } - public void CopyTo(T[] array, int arrayIndex) { } - public System.Collections.Generic.IEnumerator GetEnumerator() { } - public int IndexOf(T item) { } - public virtual void Insert(int index, T item) { } - protected void InsertItem(int index, T item) { } - public virtual void InsertRange(int index, System.Collections.Generic.IEnumerable collection) { } - public virtual void Move(int oldIndex, int newIndex) { } - protected void MoveItem(int oldIndex, int newIndex) { } - protected virtual void RaiseCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) { } - protected virtual void RaiseCollectionChanging(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) { } - public virtual bool Remove(T item) { } - public virtual void RemoveAll(System.Collections.Generic.IEnumerable items) { } - public virtual void RemoveAt(int index) { } - protected void RemoveItem(int index) { } - public virtual void RemoveRange(int index, int count) { } - public virtual void Reset() { } - protected void SetItem(int index, T item) { } - public virtual void Sort(int index, int count, System.Collections.Generic.IComparer comparer) { } - public virtual void Sort(System.Comparison comparison) { } - public virtual void Sort(System.Collections.Generic.IComparer comparer = null) { } - public System.IDisposable SuppressChangeNotifications() { } - } -} namespace System.Reactive.Disposables { public class static DisposableMixins { } diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net461.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net461.approved.txt index b7fe8eae6..949b9dd96 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net461.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net461.approved.txt @@ -1,4 +1,5 @@ [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.AndroidSupport")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Blazor")] [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Tests")] [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Uno")] [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Winforms")] @@ -41,7 +42,7 @@ namespace ReactiveUI public class CanActivateViewFetcher : ReactiveUI.IActivationForViewFetcher { public CanActivateViewFetcher() { } - public System.IObservable GetActivationForView(ReactiveUI.IActivatable view) { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } public int GetAffinityForView(System.Type view) { } } public class static ChangeSetMixin @@ -140,10 +141,14 @@ namespace ReactiveUI public static System.Reflection.MemberInfo GetMemberInfo(this System.Linq.Expressions.Expression expression) { } public static System.Linq.Expressions.Expression GetParent(this System.Linq.Expressions.Expression expression) { } } - public interface IActivatable { } + public interface IActivatableView { } + public interface IActivatableViewModel + { + ReactiveUI.ViewModelActivator Activator { get; } + } public interface IActivationForViewFetcher { - System.IObservable GetActivationForView(ReactiveUI.IActivatable view); + System.IObservable GetActivationForView(ReactiveUI.IActivatableView view); int GetAffinityForView(System.Type view); } public interface IBindingTypeConverter : Splat.IEnableLogger @@ -193,14 +198,6 @@ namespace ReactiveUI public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged) { } public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged, bool suppressWarnings = False) { } } - public interface INotifyCollectionChanging - { - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanging; - } - public interface INotifyPropertyChanging - { - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; - } public interface IObservedChange { System.Linq.Expressions.Expression Expression { get; } @@ -209,11 +206,17 @@ namespace ReactiveUI } public interface IPropertyBinderImplementation : Splat.IEnableLogger { - ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor ; - ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor ; @@ -261,10 +264,10 @@ namespace ReactiveUI System.IObservable> Changing { get; } System.IDisposable SuppressChangeNotifications(); } - public interface IReactiveObject : ReactiveUI.INotifyPropertyChanging, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public interface IReactiveObject : Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { void RaisePropertyChanged(System.ComponentModel.PropertyChangedEventArgs args); - void RaisePropertyChanging(ReactiveUI.PropertyChangingEventArgs args); + void RaisePropertyChanging(System.ComponentModel.PropertyChangingEventArgs args); } public class static IReactiveObjectExtensions { @@ -280,7 +283,7 @@ namespace ReactiveUI string PropertyName { get; } TSender Sender { get; } } - public interface IRoutableViewModel : ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { ReactiveUI.IScreen HostScreen { get; } string UrlPathSegment { get; } @@ -294,17 +297,13 @@ namespace ReactiveUI int GetAffinityForObjects(System.Type fromType, System.Type toType); object PerformSet(object toTarget, object newValue, object[] arguments); } - public interface ISupportsActivation - { - ReactiveUI.ViewModelActivator Activator { get; } - } public interface ISuspensionDriver { System.IObservable InvalidateState(); System.IObservable LoadState(); System.IObservable SaveState(object state); } - public interface ISuspensionHost : ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public interface ISuspensionHost : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { object AppState { get; set; } System.Func CreateNewAppState { get; set; } @@ -314,11 +313,11 @@ namespace ReactiveUI System.IObservable ShouldInvalidateState { get; set; } System.IObservable ShouldPersistState { get; set; } } - public interface IViewFor : ReactiveUI.IActivatable + public interface IViewFor : ReactiveUI.IActivatableView { object ViewModel { get; set; } } - public interface IViewFor : ReactiveUI.IActivatable, ReactiveUI.IViewFor + public interface IViewFor : ReactiveUI.IActivatableView, ReactiveUI.IViewFor where T : class { T ViewModel { get; set; } @@ -425,10 +424,16 @@ namespace ReactiveUI public class PropertyBinderImplementation : ReactiveUI.IPropertyBinderImplementation, Splat.IEnableLogger { public PropertyBinderImplementation() { } - public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } public System.IDisposable BindTo(System.IObservable observedChange, TTarget target, System.Linq.Expressions.Expression> propertyExpression, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) @@ -442,16 +447,28 @@ namespace ReactiveUI } public class static PropertyBindingMixins { - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } public static System.IDisposable BindTo(this System.IObservable @this, TTarget target, System.Linq.Expressions.Expression> property, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) @@ -463,12 +480,6 @@ namespace ReactiveUI where TViewModel : class where TView : class, ReactiveUI.IViewFor { } } - public class PropertyChangingEventArgs : System.EventArgs - { - public PropertyChangingEventArgs(string propertyName) { } - public string PropertyName { get; set; } - } - public delegate void PropertyChangingEventHandler(object sender, ReactiveUI.PropertyChangingEventArgs e); public class static ReactiveCommand { public static ReactiveUI.ReactiveCommand Create(System.Action execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } @@ -499,7 +510,7 @@ namespace ReactiveUI public abstract System.IObservable Execute(TParam parameter = null); protected virtual bool ICommandCanExecute(object parameter) { } protected virtual void ICommandExecute(object parameter) { } - protected void OnCanExecuteChanged() { } + protected void OnCanExecuteChanged(bool newValue) { } public abstract System.IDisposable Subscribe(System.IObserver observer); } public class static ReactiveCommandMixins @@ -529,7 +540,7 @@ namespace ReactiveUI public static System.IObservable> SubscribeToExpressionChain(this TSender source, System.Linq.Expressions.Expression expression, bool beforeChange = False, bool skipInitial = True, bool suppressWarnings = False) { } } [System.Runtime.Serialization.DataContractAttribute()] - public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { public ReactiveObject() { } [System.Runtime.Serialization.IgnoreDataMemberAttribute()] @@ -539,7 +550,7 @@ namespace ReactiveUI [System.Runtime.Serialization.IgnoreDataMemberAttribute()] public System.IObservable ThrownExceptions { get; } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; public bool AreChangeNotificationsEnabled() { } public System.IDisposable DelayChangeNotifications() { } public System.IDisposable SuppressChangeNotifications() { } @@ -549,7 +560,7 @@ namespace ReactiveUI public ReactivePropertyChangedEventArgs(TSender sender, string propertyName) { } public TSender Sender { get; } } - public class ReactivePropertyChangingEventArgs : ReactiveUI.PropertyChangingEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs + public class ReactivePropertyChangingEventArgs : System.ComponentModel.PropertyChangingEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs { public ReactivePropertyChangingEventArgs(TSender sender, string propertyName) { } public TSender Sender { get; } @@ -672,14 +683,14 @@ namespace ReactiveUI } public class static ViewForMixins { - public static void WhenActivated(this ReactiveUI.ISupportsActivation item, System.Func> block) { } - public static void WhenActivated(this ReactiveUI.ISupportsActivation item, System.Action> block) { } - public static void WhenActivated(this ReactiveUI.ISupportsActivation item, System.Action block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Func> block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Func> block, ReactiveUI.IViewFor view) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Action> block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Action> block, ReactiveUI.IViewFor view) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Action block, ReactiveUI.IViewFor view = null) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Func> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action block, ReactiveUI.IViewFor view = null) { } } public class static ViewLocator { @@ -748,17 +759,17 @@ namespace ReactiveUI public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Linq.Expressions.Expression property9, System.Linq.Expressions.Expression property10, System.Linq.Expressions.Expression property11, System.Linq.Expressions.Expression property12, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Func selector) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Func selector) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Func selector) { } @@ -816,153 +827,11 @@ namespace ReactiveUI where TSender : class { } } } -namespace ReactiveUI.Legacy -{ - public interface IMoveInfo - { - int From { get; } - System.Collections.Generic.IEnumerable MovedItems { get; } - int To { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveCollection : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - void Reset(); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveDerivedList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged, System.IDisposable { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - bool IsEmpty { get; } - void AddRange(System.Collections.Generic.IEnumerable collection); - void InsertRange(int index, System.Collections.Generic.IEnumerable collection); - void RemoveAll(System.Collections.Generic.IEnumerable items); - void RemoveRange(int index, int count); - void Sort(System.Collections.Generic.IComparer comparer = null); - void Sort(System.Comparison comparison); - void Sort(int index, int count, System.Collections.Generic.IComparer comparer); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionChanged - { - System.IObservable BeforeItemsAdded { get; } - System.IObservable> BeforeItemsMoved { get; } - System.IObservable BeforeItemsRemoved { get; } - System.IObservable Changed { get; } - System.IObservable Changing { get; } - System.IObservable CountChanged { get; } - System.IObservable CountChanging { get; } - System.IObservable IsEmptyChanged { get; } - System.IObservable ItemsAdded { get; } - System.IObservable> ItemsMoved { get; } - System.IObservable ItemsRemoved { get; } - System.IObservable ShouldReset { get; } - System.IDisposable SuppressChangeNotifications(); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionItemChanged - { - bool ChangeTrackingEnabled { get; set; } - System.IObservable> ItemChanged { get; } - System.IObservable> ItemChanging { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveCollection : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - bool IsEmpty { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ObservableCollectionMixin - { - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Action onRemoved, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Action onRemoved, System.Func filter = null, System.Func orderer = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Func filter = null, System.Func orderer = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ReactiveCollectionMixins - { - public static ReactiveUI.Legacy.IReactiveDerivedList CreateCollection(this System.IObservable fromObservable, System.Reactive.Concurrency.IScheduler scheduler) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateCollection(this System.IObservable fromObservable, System.Nullable withDelay = null, System.Action onError = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - } - [System.Diagnostics.DebuggerDisplayAttribute("Count = {Count}")] - [System.Diagnostics.DebuggerTypeProxyAttribute(typeof(ReactiveUI.Legacy.CollectionDebugView))] - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class ReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveList, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - public ReactiveList() { } - public ReactiveList(System.Collections.Generic.IEnumerable initialContents) { } - public ReactiveList(System.Collections.Generic.IEnumerable initialContents = null, double resetChangeThreshold = 0.3, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public System.IObservable BeforeItemsAdded { get; } - public System.IObservable> BeforeItemsMoved { get; } - public System.IObservable BeforeItemsRemoved { get; } - public bool ChangeTrackingEnabled { get; set; } - public System.IObservable Changed { get; } - public System.IObservable Changing { get; } - public int Count { get; } - public System.IObservable CountChanged { get; } - public System.IObservable CountChanging { get; } - public bool IsEmpty { get; } - public System.IObservable IsEmptyChanged { get; } - public virtual bool IsReadOnly { get; } - public virtual T this[int index] { get; set; } - public System.IObservable> ItemChanged { get; } - public System.IObservable> ItemChanging { get; } - public System.IObservable ItemsAdded { get; } - public System.IObservable> ItemsMoved { get; } - public System.IObservable ItemsRemoved { get; } - [System.Runtime.Serialization.IgnoreDataMemberAttribute()] - public double ResetChangeThreshold { get; set; } - public System.IObservable ShouldReset { get; } - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanged; - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanging; - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; - public virtual void Add(T item) { } - public virtual void AddRange(System.Collections.Generic.IEnumerable collection) { } - public int BinarySearch(T item) { } - public int BinarySearch(T item, System.Collections.Generic.IComparer comparer) { } - public int BinarySearch(int index, int count, T item, System.Collections.Generic.IComparer comparer) { } - public virtual void Clear() { } - protected void ClearItems() { } - public bool Contains(T item) { } - public void CopyTo(T[] array, int arrayIndex) { } - public System.Collections.Generic.IEnumerator GetEnumerator() { } - public int IndexOf(T item) { } - public virtual void Insert(int index, T item) { } - protected void InsertItem(int index, T item) { } - public virtual void InsertRange(int index, System.Collections.Generic.IEnumerable collection) { } - public virtual void Move(int oldIndex, int newIndex) { } - protected void MoveItem(int oldIndex, int newIndex) { } - protected virtual void RaiseCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) { } - protected virtual void RaiseCollectionChanging(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) { } - public virtual bool Remove(T item) { } - public virtual void RemoveAll(System.Collections.Generic.IEnumerable items) { } - public virtual void RemoveAt(int index) { } - protected void RemoveItem(int index) { } - public virtual void RemoveRange(int index, int count) { } - public virtual void Reset() { } - protected void SetItem(int index, T item) { } - public virtual void Sort(int index, int count, System.Collections.Generic.IComparer comparer) { } - public virtual void Sort(System.Comparison comparison) { } - public virtual void Sort(System.Collections.Generic.IComparer comparer = null) { } - public System.IDisposable SuppressChangeNotifications() { } - } -} namespace System.Reactive.Disposables { - public class static DisposableMixins { } + public class static DisposableMixins + { + public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) + where T : System.IDisposable { } + } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp2.0.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp2.0.approved.txt index 89a43aa80..4c9444aef 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp2.0.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp2.0.approved.txt @@ -1,4 +1,5 @@ [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.AndroidSupport")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Blazor")] [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Tests")] [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Uno")] [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Winforms")] @@ -41,7 +42,7 @@ namespace ReactiveUI public class CanActivateViewFetcher : ReactiveUI.IActivationForViewFetcher { public CanActivateViewFetcher() { } - public System.IObservable GetActivationForView(ReactiveUI.IActivatable view) { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } public int GetAffinityForView(System.Type view) { } } public class static ChangeSetMixin @@ -134,10 +135,14 @@ namespace ReactiveUI public static System.Reflection.MemberInfo GetMemberInfo(this System.Linq.Expressions.Expression expression) { } public static System.Linq.Expressions.Expression GetParent(this System.Linq.Expressions.Expression expression) { } } - public interface IActivatable { } + public interface IActivatableView { } + public interface IActivatableViewModel + { + ReactiveUI.ViewModelActivator Activator { get; } + } public interface IActivationForViewFetcher { - System.IObservable GetActivationForView(ReactiveUI.IActivatable view); + System.IObservable GetActivationForView(ReactiveUI.IActivatableView view); int GetAffinityForView(System.Type view); } public interface IBindingTypeConverter : Splat.IEnableLogger @@ -187,14 +192,6 @@ namespace ReactiveUI public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged) { } public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged, bool suppressWarnings = False) { } } - public interface INotifyCollectionChanging - { - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanging; - } - public interface INotifyPropertyChanging - { - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; - } public interface IObservedChange { System.Linq.Expressions.Expression Expression { get; } @@ -203,11 +200,17 @@ namespace ReactiveUI } public interface IPropertyBinderImplementation : Splat.IEnableLogger { - ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor ; - ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor ; @@ -255,10 +258,10 @@ namespace ReactiveUI System.IObservable> Changing { get; } System.IDisposable SuppressChangeNotifications(); } - public interface IReactiveObject : ReactiveUI.INotifyPropertyChanging, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public interface IReactiveObject : Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { void RaisePropertyChanged(System.ComponentModel.PropertyChangedEventArgs args); - void RaisePropertyChanging(ReactiveUI.PropertyChangingEventArgs args); + void RaisePropertyChanging(System.ComponentModel.PropertyChangingEventArgs args); } public class static IReactiveObjectExtensions { @@ -274,7 +277,7 @@ namespace ReactiveUI string PropertyName { get; } TSender Sender { get; } } - public interface IRoutableViewModel : ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { ReactiveUI.IScreen HostScreen { get; } string UrlPathSegment { get; } @@ -288,17 +291,13 @@ namespace ReactiveUI int GetAffinityForObjects(System.Type fromType, System.Type toType); object PerformSet(object toTarget, object newValue, object[] arguments); } - public interface ISupportsActivation - { - ReactiveUI.ViewModelActivator Activator { get; } - } public interface ISuspensionDriver { System.IObservable InvalidateState(); System.IObservable LoadState(); System.IObservable SaveState(object state); } - public interface ISuspensionHost : ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public interface ISuspensionHost : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { object AppState { get; set; } System.Func CreateNewAppState { get; set; } @@ -308,11 +307,11 @@ namespace ReactiveUI System.IObservable ShouldInvalidateState { get; set; } System.IObservable ShouldPersistState { get; set; } } - public interface IViewFor : ReactiveUI.IActivatable + public interface IViewFor : ReactiveUI.IActivatableView { object ViewModel { get; set; } } - public interface IViewFor : ReactiveUI.IActivatable, ReactiveUI.IViewFor + public interface IViewFor : ReactiveUI.IActivatableView, ReactiveUI.IViewFor where T : class { T ViewModel { get; set; } @@ -419,10 +418,16 @@ namespace ReactiveUI public class PropertyBinderImplementation : ReactiveUI.IPropertyBinderImplementation, Splat.IEnableLogger { public PropertyBinderImplementation() { } - public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } public System.IDisposable BindTo(System.IObservable observedChange, TTarget target, System.Linq.Expressions.Expression> propertyExpression, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) @@ -436,16 +441,28 @@ namespace ReactiveUI } public class static PropertyBindingMixins { - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } - public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) where TViewModel : class where TView : class, ReactiveUI.IViewFor { } public static System.IDisposable BindTo(this System.IObservable @this, TTarget target, System.Linq.Expressions.Expression> property, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) @@ -457,12 +474,6 @@ namespace ReactiveUI where TViewModel : class where TView : class, ReactiveUI.IViewFor { } } - public class PropertyChangingEventArgs : System.EventArgs - { - public PropertyChangingEventArgs(string propertyName) { } - public string PropertyName { get; set; } - } - public delegate void PropertyChangingEventHandler(object sender, ReactiveUI.PropertyChangingEventArgs e); public class static ReactiveCommand { public static ReactiveUI.ReactiveCommand Create(System.Action execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } @@ -493,7 +504,7 @@ namespace ReactiveUI public abstract System.IObservable Execute(TParam parameter = null); protected virtual bool ICommandCanExecute(object parameter) { } protected virtual void ICommandExecute(object parameter) { } - protected void OnCanExecuteChanged() { } + protected void OnCanExecuteChanged(bool newValue) { } public abstract System.IDisposable Subscribe(System.IObserver observer); } public class static ReactiveCommandMixins @@ -523,7 +534,7 @@ namespace ReactiveUI public static System.IObservable> SubscribeToExpressionChain(this TSender source, System.Linq.Expressions.Expression expression, bool beforeChange = False, bool skipInitial = True, bool suppressWarnings = False) { } } [System.Runtime.Serialization.DataContractAttribute()] - public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { public ReactiveObject() { } [System.Runtime.Serialization.IgnoreDataMemberAttribute()] @@ -533,7 +544,7 @@ namespace ReactiveUI [System.Runtime.Serialization.IgnoreDataMemberAttribute()] public System.IObservable ThrownExceptions { get; } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; public bool AreChangeNotificationsEnabled() { } public System.IDisposable DelayChangeNotifications() { } public System.IDisposable SuppressChangeNotifications() { } @@ -543,7 +554,7 @@ namespace ReactiveUI public ReactivePropertyChangedEventArgs(TSender sender, string propertyName) { } public TSender Sender { get; } } - public class ReactivePropertyChangingEventArgs : ReactiveUI.PropertyChangingEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs + public class ReactivePropertyChangingEventArgs : System.ComponentModel.PropertyChangingEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs { public ReactivePropertyChangingEventArgs(TSender sender, string propertyName) { } public TSender Sender { get; } @@ -666,14 +677,14 @@ namespace ReactiveUI } public class static ViewForMixins { - public static void WhenActivated(this ReactiveUI.ISupportsActivation item, System.Func> block) { } - public static void WhenActivated(this ReactiveUI.ISupportsActivation item, System.Action> block) { } - public static void WhenActivated(this ReactiveUI.ISupportsActivation item, System.Action block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Func> block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Func> block, ReactiveUI.IViewFor view) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Action> block) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Action> block, ReactiveUI.IViewFor view) { } - public static System.IDisposable WhenActivated(this ReactiveUI.IActivatable item, System.Action block, ReactiveUI.IViewFor view = null) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Func> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action block, ReactiveUI.IViewFor view = null) { } } public class static ViewLocator { @@ -742,17 +753,17 @@ namespace ReactiveUI public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Linq.Expressions.Expression property9, System.Linq.Expressions.Expression property10, System.Linq.Expressions.Expression property11, System.Linq.Expressions.Expression property12, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Func selector) { } - public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Func selector) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Func selector) { } public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Func selector) { } @@ -810,153 +821,11 @@ namespace ReactiveUI where TSender : class { } } } -namespace ReactiveUI.Legacy -{ - public interface IMoveInfo - { - int From { get; } - System.Collections.Generic.IEnumerable MovedItems { get; } - int To { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveCollection : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - void Reset(); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveDerivedList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged, System.IDisposable { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - bool IsEmpty { get; } - void AddRange(System.Collections.Generic.IEnumerable collection); - void InsertRange(int index, System.Collections.Generic.IEnumerable collection); - void RemoveAll(System.Collections.Generic.IEnumerable items); - void RemoveRange(int index, int count); - void Sort(System.Collections.Generic.IComparer comparer = null); - void Sort(System.Comparison comparison); - void Sort(int index, int count, System.Collections.Generic.IComparer comparer); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionChanged - { - System.IObservable BeforeItemsAdded { get; } - System.IObservable> BeforeItemsMoved { get; } - System.IObservable BeforeItemsRemoved { get; } - System.IObservable Changed { get; } - System.IObservable Changing { get; } - System.IObservable CountChanged { get; } - System.IObservable CountChanging { get; } - System.IObservable IsEmptyChanged { get; } - System.IObservable ItemsAdded { get; } - System.IObservable> ItemsMoved { get; } - System.IObservable ItemsRemoved { get; } - System.IObservable ShouldReset { get; } - System.IDisposable SuppressChangeNotifications(); - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionItemChanged - { - bool ChangeTrackingEnabled { get; set; } - System.IObservable> ItemChanged { get; } - System.IObservable> ItemChanging { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveCollection : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - bool IsEmpty { get; } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ObservableCollectionMixin - { - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Action onRemoved, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Action onRemoved, System.Func filter = null, System.Func orderer = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateDerivedCollection(this System.Collections.Generic.IEnumerable @this, System.Func selector, System.Func filter = null, System.Func orderer = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ReactiveCollectionMixins - { - public static ReactiveUI.Legacy.IReactiveDerivedList CreateCollection(this System.IObservable fromObservable, System.Reactive.Concurrency.IScheduler scheduler) { } - public static ReactiveUI.Legacy.IReactiveDerivedList CreateCollection(this System.IObservable fromObservable, System.Nullable withDelay = null, System.Action onError = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } - } - [System.Diagnostics.DebuggerDisplayAttribute("Count = {Count}")] - [System.Diagnostics.DebuggerTypeProxyAttribute(typeof(ReactiveUI.Legacy.CollectionDebugView))] - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class ReactiveList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveList, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged - { - public ReactiveList() { } - public ReactiveList(System.Collections.Generic.IEnumerable initialContents) { } - public ReactiveList(System.Collections.Generic.IEnumerable initialContents = null, double resetChangeThreshold = 0.3, System.Reactive.Concurrency.IScheduler scheduler = null) { } - public System.IObservable BeforeItemsAdded { get; } - public System.IObservable> BeforeItemsMoved { get; } - public System.IObservable BeforeItemsRemoved { get; } - public bool ChangeTrackingEnabled { get; set; } - public System.IObservable Changed { get; } - public System.IObservable Changing { get; } - public int Count { get; } - public System.IObservable CountChanged { get; } - public System.IObservable CountChanging { get; } - public bool IsEmpty { get; } - public System.IObservable IsEmptyChanged { get; } - public virtual bool IsReadOnly { get; } - public virtual T this[int index] { get; set; } - public System.IObservable> ItemChanged { get; } - public System.IObservable> ItemChanging { get; } - public System.IObservable ItemsAdded { get; } - public System.IObservable> ItemsMoved { get; } - public System.IObservable ItemsRemoved { get; } - [System.Runtime.Serialization.IgnoreDataMemberAttribute()] - public double ResetChangeThreshold { get; set; } - public System.IObservable ShouldReset { get; } - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanged; - public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanging; - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; - public virtual void Add(T item) { } - public virtual void AddRange(System.Collections.Generic.IEnumerable collection) { } - public int BinarySearch(T item) { } - public int BinarySearch(T item, System.Collections.Generic.IComparer comparer) { } - public int BinarySearch(int index, int count, T item, System.Collections.Generic.IComparer comparer) { } - public virtual void Clear() { } - protected void ClearItems() { } - public bool Contains(T item) { } - public void CopyTo(T[] array, int arrayIndex) { } - public System.Collections.Generic.IEnumerator GetEnumerator() { } - public int IndexOf(T item) { } - public virtual void Insert(int index, T item) { } - protected void InsertItem(int index, T item) { } - public virtual void InsertRange(int index, System.Collections.Generic.IEnumerable collection) { } - public virtual void Move(int oldIndex, int newIndex) { } - protected void MoveItem(int oldIndex, int newIndex) { } - protected virtual void RaiseCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) { } - protected virtual void RaiseCollectionChanging(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) { } - public virtual bool Remove(T item) { } - public virtual void RemoveAll(System.Collections.Generic.IEnumerable items) { } - public virtual void RemoveAt(int index) { } - protected void RemoveItem(int index) { } - public virtual void RemoveRange(int index, int count) { } - public virtual void Reset() { } - protected void SetItem(int index, T item) { } - public virtual void Sort(int index, int count, System.Collections.Generic.IComparer comparer) { } - public virtual void Sort(System.Comparison comparison) { } - public virtual void Sort(System.Collections.Generic.IComparer comparer = null) { } - public System.IDisposable SuppressChangeNotifications() { } - } -} namespace System.Reactive.Disposables { - public class static DisposableMixins { } + public class static DisposableMixins + { + public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) + where T : System.IDisposable { } + } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.0.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.0.approved.txt new file mode 100644 index 000000000..8c53370a1 --- /dev/null +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.0.approved.txt @@ -0,0 +1,837 @@ +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.AndroidSupport")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Blazor")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Tests")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Uno")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Winforms")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Wpf")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.XamForms")] +[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.0", FrameworkDisplayName="")] +namespace ReactiveUI +{ + public class static AutoPersistHelper + { + public static System.IDisposable ActOnEveryObject(this System.Collections.ObjectModel.ObservableCollection @this, System.Action onAdd, System.Action onRemove) + where TItem : ReactiveUI.IReactiveObject { } + public static System.IDisposable ActOnEveryObject(this System.Collections.ObjectModel.ReadOnlyObservableCollection @this, System.Action onAdd, System.Action onRemove) + where TItem : ReactiveUI.IReactiveObject { } + public static System.IDisposable ActOnEveryObject(this TCollection @this, System.Action onAdd, System.Action onRemove) + where TItem : ReactiveUI.IReactiveObject + where TCollection : System.Collections.Specialized.INotifyCollectionChanged, System.Collections.Generic.IEnumerable { } + public static System.IDisposable ActOnEveryObject(this System.IObservable> @this, System.Action onAdd, System.Action onRemove) + where TItem : ReactiveUI.IReactiveObject { } + public static System.IDisposable AutoPersist(this T @this, System.Func> doPersist, System.Nullable interval = null) + where T : ReactiveUI.IReactiveObject { } + public static System.IDisposable AutoPersist(this T @this, System.Func> doPersist, System.IObservable manualSaveSignal, System.Nullable interval = null) + where T : ReactiveUI.IReactiveObject { } + public static System.IDisposable AutoPersistCollection(this System.Collections.ObjectModel.ObservableCollection @this, System.Func> doPersist, System.Nullable interval = null) + where TItem : ReactiveUI.IReactiveObject { } + public static System.IDisposable AutoPersistCollection(this System.Collections.ObjectModel.ObservableCollection @this, System.Func> doPersist, System.IObservable manualSaveSignal, System.Nullable interval = null) + where TItem : ReactiveUI.IReactiveObject { } + public static System.IDisposable AutoPersistCollection(this System.Collections.ObjectModel.ReadOnlyObservableCollection @this, System.Func> doPersist, System.IObservable manualSaveSignal, System.Nullable interval = null) + where TItem : ReactiveUI.IReactiveObject { } + public static System.IDisposable AutoPersistCollection(this TCollection @this, System.Func> doPersist, System.IObservable manualSaveSignal, System.Nullable interval = null) + where TItem : ReactiveUI.IReactiveObject + where TCollection : System.Collections.Specialized.INotifyCollectionChanged, System.Collections.Generic.IEnumerable { } + } + public enum BindingDirection + { + OneWay = 0, + TwoWay = 1, + AsyncOneWay = 2, + } + public class CanActivateViewFetcher : ReactiveUI.IActivationForViewFetcher + { + public CanActivateViewFetcher() { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } + public int GetAffinityForView(System.Type view) { } + } + public class static ChangeSetMixin + { + public static System.IObservable CountChanged(this System.IObservable changeSet) { } + public static System.IObservable> CountChanged(this System.IObservable> changeSet) { } + public static bool HasCountChanged(this DynamicData.IChangeSet changeSet) { } + } + public class CombinedReactiveCommand : ReactiveUI.ReactiveCommandBase> + { + protected CombinedReactiveCommand(System.Collections.Generic.IEnumerable> childCommands, System.IObservable canExecute, System.Reactive.Concurrency.IScheduler outputScheduler) { } + public override System.IObservable CanExecute { get; } + public override System.IObservable IsExecuting { get; } + public override System.IObservable ThrownExceptions { get; } + protected override void Dispose(bool disposing) { } + public override System.IObservable> Execute(TParam parameter = null) { } + public override System.IDisposable Subscribe(System.IObserver> observer) { } + } + public class static CommandBinder + { + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.IObservable withParameter, string toEvent = null) + where TView : class, ReactiveUI.IViewFor + where TViewModel : class + where TProp : System.Windows.Input.ICommand { } + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, string toEvent = null) + where TView : class, ReactiveUI.IViewFor + where TViewModel : class + where TProp : System.Windows.Input.ICommand { } + public static ReactiveUI.IReactiveBinding BindCommand(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> propertyName, System.Linq.Expressions.Expression> controlName, System.Linq.Expressions.Expression> withParameter, string toEvent = null) + where TView : class, ReactiveUI.IViewFor + where TViewModel : class + where TProp : System.Windows.Input.ICommand { } + } + public class CommandBinderImplementation : Splat.IEnableLogger + { + public CommandBinderImplementation() { } + public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.Func withParameter, string toEvent = null) + where TView : class, ReactiveUI.IViewFor + where TViewModel : class + where TProp : System.Windows.Input.ICommand { } + public ReactiveUI.IReactiveBinding BindCommand(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> controlProperty, System.IObservable withParameter, string toEvent = null) + where TView : class, ReactiveUI.IViewFor + where TViewModel : class + where TProp : System.Windows.Input.ICommand { } + } + public class static ComparerChainingExtensions + { + public static System.Collections.Generic.IComparer ThenBy(this System.Collections.Generic.IComparer parent, System.Func selector) { } + public static System.Collections.Generic.IComparer ThenBy(this System.Collections.Generic.IComparer parent, System.Func selector, System.Collections.Generic.IComparer comparer) { } + public static System.Collections.Generic.IComparer ThenByDescending(this System.Collections.Generic.IComparer parent, System.Func selector) { } + public static System.Collections.Generic.IComparer ThenByDescending(this System.Collections.Generic.IComparer parent, System.Func selector, System.Collections.Generic.IComparer comparer) { } + } + public class ComponentModelTypeConverter : ReactiveUI.IBindingTypeConverter, Splat.IEnableLogger + { + public ComponentModelTypeConverter() { } + public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } + public bool TryConvert(object from, System.Type toType, object conversionHint, out object result) { } + } + public class CreatesCommandBindingViaCommandParameter : ReactiveUI.ICreatesCommandBinding + { + public CreatesCommandBindingViaCommandParameter() { } + public System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter) { } + public System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter, string eventName) { } + public int GetAffinityForObject(System.Type type, bool hasEventTarget) { } + } + public class CreatesCommandBindingViaEvent : ReactiveUI.ICreatesCommandBinding + { + public CreatesCommandBindingViaEvent() { } + public System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter) { } + public System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter, string eventName) { } + public int GetAffinityForObject(System.Type type, bool hasEventTarget) { } + } + public class static DependencyResolverMixins + { + public static void InitializeReactiveUI(this Splat.IMutableDependencyResolver resolver) { } + public static void RegisterViewsForViewModels(this Splat.IMutableDependencyResolver resolver, System.Reflection.Assembly assembly) { } + } + public class DummySuspensionDriver : ReactiveUI.ISuspensionDriver + { + public DummySuspensionDriver() { } + public System.IObservable InvalidateState() { } + public System.IObservable LoadState() { } + public System.IObservable SaveState(object state) { } + } + public class EqualityTypeConverter : ReactiveUI.IBindingTypeConverter, Splat.IEnableLogger + { + public EqualityTypeConverter() { } + public static object DoReferenceCast(object from, System.Type targetType) { } + public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } + public bool TryConvert(object from, System.Type toType, object conversionHint, out object result) { } + } + public class static ExpressionMixins + { + public static object[] GetArgumentsArray(this System.Linq.Expressions.Expression expression) { } + public static System.Collections.Generic.IEnumerable GetExpressionChain(this System.Linq.Expressions.Expression @this) { } + public static System.Reflection.MemberInfo GetMemberInfo(this System.Linq.Expressions.Expression expression) { } + public static System.Linq.Expressions.Expression GetParent(this System.Linq.Expressions.Expression expression) { } + } + public interface IActivatableView { } + public interface IActivatableViewModel + { + ReactiveUI.ViewModelActivator Activator { get; } + } + public interface IActivationForViewFetcher + { + System.IObservable GetActivationForView(ReactiveUI.IActivatableView view); + int GetAffinityForView(System.Type view); + } + public interface IBindingTypeConverter : Splat.IEnableLogger + { + int GetAffinityForObjects(System.Type fromType, System.Type toType); + bool TryConvert(object from, System.Type toType, object conversionHint, out object result); + } + public interface ICanActivate + { + System.IObservable Activated { get; } + System.IObservable Deactivated { get; } + } + public interface IComparerBuilder + { + System.Collections.Generic.IComparer OrderBy(System.Func selector); + System.Collections.Generic.IComparer OrderBy(System.Func selector, System.Collections.Generic.IComparer comparer); + System.Collections.Generic.IComparer OrderByDescending(System.Func selector); + System.Collections.Generic.IComparer OrderByDescending(System.Func selector, System.Collections.Generic.IComparer comparer); + } + public interface ICreatesCommandBinding + { + System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter); + System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter, string eventName); + int GetAffinityForObject(System.Type type, bool hasEventTarget); + } + public interface ICreatesObservableForProperty : Splat.IEnableLogger + { + int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged = False); + System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged = False, bool suppressWarnings = False); + } + public interface IHandleObservableErrors + { + System.IObservable ThrownExceptions { get; } + } + public interface IMessageBus : Splat.IEnableLogger + { + bool IsRegistered(System.Type type, string contract = null); + System.IObservable Listen(string contract = null); + System.IObservable ListenIncludeLatest(string contract = null); + System.IDisposable RegisterMessageSource(System.IObservable source, string contract = null); + void RegisterScheduler(System.Reactive.Concurrency.IScheduler scheduler, string contract = null); + void SendMessage(T message, string contract = null); + } + public class INPCObservableForProperty : ReactiveUI.ICreatesObservableForProperty, Splat.IEnableLogger + { + public INPCObservableForProperty() { } + public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged) { } + public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged, bool suppressWarnings = False) { } + } + public interface IObservedChange + { + System.Linq.Expressions.Expression Expression { get; } + TSender Sender { get; } + TValue Value { get; } + } + public interface IPropertyBinderImplementation : Splat.IEnableLogger + { + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor + ; + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor + ; + System.IDisposable BindTo(System.IObservable observedChange, TTarget target, System.Linq.Expressions.Expression> propertyExpression, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) + where TTarget : class + ; + ReactiveUI.IReactiveBinding OneWayBind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor + ; + ReactiveUI.IReactiveBinding OneWayBind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor + ; + } + public interface IPropertyBindingHook + { + bool ExecuteHook(object source, object target, System.Func[]> getCurrentViewModelProperties, System.Func[]> getCurrentViewProperties, ReactiveUI.BindingDirection direction); + } + public class IROObservableForProperty : ReactiveUI.ICreatesObservableForProperty, Splat.IEnableLogger + { + public IROObservableForProperty() { } + public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged = False) { } + public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged = False, bool suppressWarnings = False) { } + } + public interface IReactiveBinding : System.IDisposable + where out TView : ReactiveUI.IViewFor + where out TViewModel : class + { + System.IObservable Changed { get; } + ReactiveUI.BindingDirection Direction { get; } + TView View { get; } + System.Linq.Expressions.Expression ViewExpression { get; } + TViewModel ViewModel { get; } + System.Linq.Expressions.Expression ViewModelExpression { get; } + } + public interface IReactiveCommand : ReactiveUI.IHandleObservableErrors, System.IDisposable + { + System.IObservable CanExecute { get; } + System.IObservable IsExecuting { get; } + } + public interface IReactiveNotifyPropertyChanged + { + System.IObservable> Changed { get; } + System.IObservable> Changing { get; } + System.IDisposable SuppressChangeNotifications(); + } + public interface IReactiveObject : Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging + { + void RaisePropertyChanged(System.ComponentModel.PropertyChangedEventArgs args); + void RaisePropertyChanging(System.ComponentModel.PropertyChangingEventArgs args); + } + public class static IReactiveObjectExtensions + { + public static TRet RaiseAndSetIfChanged(this TObj reactiveObject, ref TRet backingField, TRet newValue, [System.Runtime.CompilerServices.CallerMemberNameAttribute()] string propertyName = null) + where TObj : ReactiveUI.IReactiveObject { } + public static void RaisePropertyChanged(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberNameAttribute()] string propertyName = null) + where TSender : ReactiveUI.IReactiveObject { } + public static void RaisePropertyChanging(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberNameAttribute()] string propertyName = null) + where TSender : ReactiveUI.IReactiveObject { } + } + public interface IReactivePropertyChangedEventArgs + { + string PropertyName { get; } + TSender Sender { get; } + } + public interface IRoutableViewModel : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging + { + ReactiveUI.IScreen HostScreen { get; } + string UrlPathSegment { get; } + } + public interface IScreen + { + ReactiveUI.RoutingState Router { get; } + } + public interface ISetMethodBindingConverter : Splat.IEnableLogger + { + int GetAffinityForObjects(System.Type fromType, System.Type toType); + object PerformSet(object toTarget, object newValue, object[] arguments); + } + public interface ISuspensionDriver + { + System.IObservable InvalidateState(); + System.IObservable LoadState(); + System.IObservable SaveState(object state); + } + public interface ISuspensionHost : ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging + { + object AppState { get; set; } + System.Func CreateNewAppState { get; set; } + System.IObservable IsLaunchingNew { get; set; } + System.IObservable IsResuming { get; set; } + System.IObservable IsUnpausing { get; set; } + System.IObservable ShouldInvalidateState { get; set; } + System.IObservable ShouldPersistState { get; set; } + } + public interface IViewFor : ReactiveUI.IActivatableView + { + object ViewModel { get; set; } + } + public interface IViewFor : ReactiveUI.IActivatableView, ReactiveUI.IViewFor + where T : class + { + T ViewModel { get; set; } + } + public interface IViewLocator : Splat.IEnableLogger + { + ReactiveUI.IViewFor ResolveView(T viewModel, string contract = null) + where T : class; + } + public sealed class InteractionContext + { + public TInput Input { get; } + public bool IsHandled { get; } + public TOutput GetOutput() { } + public void SetOutput(TOutput output) { } + } + public class Interaction + { + public Interaction(System.Reactive.Concurrency.IScheduler handlerScheduler = null) { } + protected System.Func<, >[] GetHandlers() { } + public virtual System.IObservable Handle(TInput input) { } + public System.IDisposable RegisterHandler(System.Action> handler) { } + public System.IDisposable RegisterHandler(System.Func, System.Threading.Tasks.Task> handler) { } + public System.IDisposable RegisterHandler(System.Func, System.IObservable> handler) { } + } + public class MessageBus : ReactiveUI.IMessageBus, Splat.IEnableLogger + { + public MessageBus() { } + public static ReactiveUI.IMessageBus Current { get; set; } + public bool IsRegistered(System.Type type, string contract = null) { } + public System.IObservable Listen(string contract = null) { } + public System.IObservable ListenIncludeLatest(string contract = null) { } + public System.IDisposable RegisterMessageSource(System.IObservable source, string contract = null) { } + public void RegisterScheduler(System.Reactive.Concurrency.IScheduler scheduler, string contract = null) { } + public void SendMessage(T message, string contract = null) { } + } + public class static OAPHCreationHelperMixin + { + public static ReactiveUI.ObservableAsPropertyHelper ToProperty(this System.IObservable target, TObj source, System.Linq.Expressions.Expression> property, TRet initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) + where TObj : class, ReactiveUI.IReactiveObject { } + public static ReactiveUI.ObservableAsPropertyHelper ToProperty(this System.IObservable target, TObj source, System.Linq.Expressions.Expression> property, out ReactiveUI.ObservableAsPropertyHelper result, TRet initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) + where TObj : class, ReactiveUI.IReactiveObject { } + public static ReactiveUI.ObservableAsPropertyHelper ToProperty(this System.IObservable target, TObj source, string property, TRet initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) + where TObj : class, ReactiveUI.IReactiveObject { } + public static ReactiveUI.ObservableAsPropertyHelper ToProperty(this System.IObservable target, TObj source, string property, out ReactiveUI.ObservableAsPropertyHelper result, TRet initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) + where TObj : class, ReactiveUI.IReactiveObject { } + } + public sealed class ObservableAsPropertyHelper : ReactiveUI.IHandleObservableErrors, Splat.IEnableLogger, System.IDisposable + { + public ObservableAsPropertyHelper(System.IObservable observable, System.Action onChanged, T initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) { } + public ObservableAsPropertyHelper(System.IObservable observable, System.Action onChanged, System.Action onChanging = null, T initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null) { } + public bool IsSubscribed { get; } + public System.IObservable ThrownExceptions { get; } + public T Value { get; } + public static ReactiveUI.ObservableAsPropertyHelper Default(T initialValue = null, System.Reactive.Concurrency.IScheduler scheduler = null) { } + public void Dispose() { } + } + public class static ObservableLoggingMixin + { + public static System.IObservable Log(this System.IObservable @this, TObj klass, string message = null, System.Func stringifier = null) + where TObj : Splat.IEnableLogger { } + public static System.IObservable LoggedCatch(this System.IObservable @this, TObj klass, System.IObservable next = null, string message = null) + where TObj : Splat.IEnableLogger { } + public static System.IObservable LoggedCatch(this System.IObservable @this, TObj klass, System.Func> next, string message = null) + where TObj : Splat.IEnableLogger + where TException : System.Exception { } + } + public class ObservedChange : ReactiveUI.IObservedChange + { + public ObservedChange(TSender sender, System.Linq.Expressions.Expression expression, TValue value = null) { } + public System.Linq.Expressions.Expression Expression { get; } + public TSender Sender { get; } + public TValue Value { get; } + } + public class static ObservedChangedMixin + { + public static string GetPropertyName(this ReactiveUI.IObservedChange item) { } + public static TValue GetValue(this ReactiveUI.IObservedChange item) { } + public static System.IObservable Value(this System.IObservable> item) { } + } + public class static OrderedComparer + { + public static ReactiveUI.IComparerBuilder For(System.Collections.Generic.IEnumerable enumerable) { } + public static ReactiveUI.IComparerBuilder For() { } + } + public class static OrderedComparer + { + public static System.Collections.Generic.IComparer OrderBy(System.Func selector) { } + public static System.Collections.Generic.IComparer OrderBy(System.Func selector, System.Collections.Generic.IComparer comparer) { } + public static System.Collections.Generic.IComparer OrderByDescending(System.Func selector) { } + public static System.Collections.Generic.IComparer OrderByDescending(System.Func selector, System.Collections.Generic.IComparer comparer) { } + } + public class POCOObservableForProperty : ReactiveUI.ICreatesObservableForProperty, Splat.IEnableLogger + { + public POCOObservableForProperty() { } + public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged = False) { } + public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged = False, bool suppressWarnings = False) { } + } + public class PlatformRegistrations + { + public PlatformRegistrations() { } + public void Register(System.Action, System.Type> registerFunction) { } + } + public class PropertyBinderImplementation : ReactiveUI.IPropertyBinderImplementation, Splat.IEnableLogger + { + public PropertyBinderImplementation() { } + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public ReactiveUI.IReactiveBinding> Bind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + public System.IDisposable BindTo(System.IObservable observedChange, TTarget target, System.Linq.Expressions.Expression> propertyExpression, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) + where TTarget : class { } + public ReactiveUI.IReactiveBinding OneWayBind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + public ReactiveUI.IReactiveBinding OneWayBind(TViewModel viewModel, TView view, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + } + public class static PropertyBindingMixins + { + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null, ReactiveUI.IBindingTypeConverter viewToVMConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func vmToViewConverter, System.Func viewToVmConverter) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + [return: System.Runtime.CompilerServices.TupleElementNamesAttribute(new string[] { + "view", + "isViewModel"})] + public static ReactiveUI.IReactiveBinding> Bind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.IObservable signalViewUpdate, System.Func vmToViewConverter, System.Func viewToVmConverter) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + public static System.IDisposable BindTo(this System.IObservable @this, TTarget target, System.Linq.Expressions.Expression> property, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) + where TTarget : class { } + public static ReactiveUI.IReactiveBinding OneWayBind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, object conversionHint = null, ReactiveUI.IBindingTypeConverter vmToViewConverterOverride = null) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + public static ReactiveUI.IReactiveBinding OneWayBind(this TView view, TViewModel viewModel, System.Linq.Expressions.Expression> vmProperty, System.Linq.Expressions.Expression> viewProperty, System.Func selector) + where TViewModel : class + where TView : class, ReactiveUI.IViewFor { } + } + public class static ReactiveCommand + { + public static ReactiveUI.ReactiveCommand Create(System.Action execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand Create(System.Func execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand Create(System.Action execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand Create(System.Func execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.CombinedReactiveCommand CreateCombined(System.Collections.Generic.IEnumerable> childCommands, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromObservable(System.Func> execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromObservable(System.Func> execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func> execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func> execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func> execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func> execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + public static ReactiveUI.ReactiveCommand CreateFromTask(System.Func execute, System.IObservable canExecute = null, System.Reactive.Concurrency.IScheduler outputScheduler = null) { } + } + public abstract class ReactiveCommandBase : ReactiveUI.IHandleObservableErrors, ReactiveUI.IReactiveCommand, System.IDisposable, System.IObservable, System.Windows.Input.ICommand + { + protected ReactiveCommandBase() { } + public abstract System.IObservable CanExecute { get; } + public abstract System.IObservable IsExecuting { get; } + public abstract System.IObservable ThrownExceptions { get; } + public event System.EventHandler System.Windows.Input.ICommand.CanExecuteChanged; + public void Dispose() { } + protected abstract void Dispose(bool disposing); + public abstract System.IObservable Execute(TParam parameter = null); + protected virtual bool ICommandCanExecute(object parameter) { } + protected virtual void ICommandExecute(object parameter) { } + protected void OnCanExecuteChanged(bool newValue) { } + public abstract System.IDisposable Subscribe(System.IObserver observer); + } + public class static ReactiveCommandMixins + { + public static System.IDisposable InvokeCommand(this System.IObservable item, System.Windows.Input.ICommand command) { } + public static System.IDisposable InvokeCommand(this System.IObservable item, ReactiveUI.ReactiveCommandBase command) { } + public static System.IDisposable InvokeCommand(this System.IObservable item, TTarget target, System.Linq.Expressions.Expression> commandProperty) + where TTarget : class { } + public static System.IDisposable InvokeCommand(this System.IObservable item, TTarget target, System.Linq.Expressions.Expression>> commandProperty) + where TTarget : class { } + } + public class ReactiveCommand : ReactiveUI.ReactiveCommandBase + { + protected ReactiveCommand(System.Func> execute, System.IObservable canExecute, System.Reactive.Concurrency.IScheduler outputScheduler) { } + public override System.IObservable CanExecute { get; } + public override System.IObservable IsExecuting { get; } + public override System.IObservable ThrownExceptions { get; } + protected override void Dispose(bool disposing) { } + public override System.IObservable Execute(TParam parameter = null) { } + public override System.IDisposable Subscribe(System.IObserver observer) { } + } + public class static ReactiveNotifyPropertyChangedMixin + { + public static System.IObservable> ObservableForProperty(this TSender item, System.Linq.Expressions.Expression> property, bool beforeChange = False, bool skipInitial = True) { } + public static System.IObservable ObservableForProperty(this TSender item, System.Linq.Expressions.Expression> property, System.Func selector, bool beforeChange = False) + where TSender : class { } + public static System.IObservable> SubscribeToExpressionChain(this TSender source, System.Linq.Expressions.Expression expression, bool beforeChange = False, bool skipInitial = True, bool suppressWarnings = False) { } + } + [System.Runtime.Serialization.DataContractAttribute()] + public class ReactiveObject : ReactiveUI.IHandleObservableErrors, ReactiveUI.IReactiveNotifyPropertyChanged, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging + { + public ReactiveObject() { } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.IObservable> Changed { get; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.IObservable> Changing { get; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.IObservable ThrownExceptions { get; } + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; + public bool AreChangeNotificationsEnabled() { } + public System.IDisposable DelayChangeNotifications() { } + public System.IDisposable SuppressChangeNotifications() { } + } + public class ReactivePropertyChangedEventArgs : System.ComponentModel.PropertyChangedEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs + { + public ReactivePropertyChangedEventArgs(TSender sender, string propertyName) { } + public TSender Sender { get; } + } + public class ReactivePropertyChangingEventArgs : System.ComponentModel.PropertyChangingEventArgs, ReactiveUI.IReactivePropertyChangedEventArgs + { + public ReactivePropertyChangingEventArgs(TSender sender, string propertyName) { } + public TSender Sender { get; } + } + public class static Reflection + { + public static string ExpressionToPropertyNames(System.Linq.Expressions.Expression expression) { } + public static System.Type GetEventArgsTypeForEvent(System.Type type, string eventName) { } + public static System.Func GetValueFetcherForProperty(System.Reflection.MemberInfo member) { } + public static System.Func GetValueFetcherOrThrow(System.Reflection.MemberInfo member) { } + public static System.Action GetValueSetterForProperty(System.Reflection.MemberInfo member) { } + public static System.Action GetValueSetterOrThrow(System.Reflection.MemberInfo member) { } + public static bool IsStatic(this System.Reflection.PropertyInfo item) { } + public static System.Type ReallyFindType(string type, bool throwOnFailure) { } + public static System.Linq.Expressions.Expression Rewrite(System.Linq.Expressions.Expression expression) { } + public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object targetObject, params string[] methodsToCheck) { } + public static bool TryGetAllValuesForPropertyChain(out ReactiveUI.IObservedChange<, >[] changeValues, object current, System.Collections.Generic.IEnumerable expressionChain) { } + public static bool TryGetValueForPropertyChain(out TValue changeValue, object current, System.Collections.Generic.IEnumerable expressionChain) { } + public static bool TrySetValueToPropertyChain(object target, System.Collections.Generic.IEnumerable expressionChain, TValue value, bool shouldThrow = True) { } + } + public class Registrations + { + public Registrations() { } + public void Register(System.Action, System.Type> registerFunction) { } + } + public class static RoutableViewModelMixin + { + public static System.IDisposable WhenNavigatedTo(this ReactiveUI.IRoutableViewModel item, System.Func onNavigatedTo) { } + public static System.IObservable WhenNavigatedToObservable(this ReactiveUI.IRoutableViewModel item) { } + public static System.IObservable WhenNavigatingFromObservable(this ReactiveUI.IRoutableViewModel item) { } + } + [System.Runtime.Serialization.DataContractAttribute()] + public class RoutingState : ReactiveUI.ReactiveObject + { + public RoutingState() { } + public RoutingState(System.Reactive.Concurrency.IScheduler scheduler) { } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.IObservable CurrentViewModel { get; set; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public ReactiveUI.ReactiveCommand Navigate { get; set; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public ReactiveUI.ReactiveCommand NavigateAndReset { get; set; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public ReactiveUI.ReactiveCommand NavigateBack { get; set; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.IObservable> NavigationChanged { get; set; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.Collections.ObjectModel.ObservableCollection NavigationStack { get; } + [System.Runtime.Serialization.IgnoreDataMemberAttribute()] + public System.Reactive.Concurrency.IScheduler Scheduler { get; set; } + } + public class static RoutingStateMixins + { + public static T FindViewModelInStack(this ReactiveUI.RoutingState item) + where T : ReactiveUI.IRoutableViewModel { } + public static ReactiveUI.IRoutableViewModel GetCurrentViewModel(this ReactiveUI.RoutingState item) { } + } + public class static RxApp + { + public const int BigCacheLimit = 256; + public const int SmallCacheLimit = 64; + public static System.IObserver DefaultExceptionHandler { get; set; } + public static System.Reactive.Concurrency.IScheduler MainThreadScheduler { get; set; } + public static bool SupportsRangeNotifications { get; set; } + public static bool SuppressViewCommandBindingMessage { get; set; } + public static ReactiveUI.ISuspensionHost SuspensionHost { get; set; } + public static System.Reactive.Concurrency.IScheduler TaskpoolScheduler { get; set; } + } + public class ScheduledSubject : System.IDisposable, System.IObservable, System.IObserver, System.Reactive.Subjects.ISubject, System.Reactive.Subjects.ISubject + { + public ScheduledSubject(System.Reactive.Concurrency.IScheduler scheduler, System.IObserver defaultObserver = null, System.Reactive.Subjects.ISubject defaultSubject = null) { } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + public void OnCompleted() { } + public void OnError(System.Exception error) { } + public void OnNext(T value) { } + public System.IDisposable Subscribe(System.IObserver observer) { } + } + [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.All)] + public class SingleInstanceViewAttribute : System.Attribute + { + public SingleInstanceViewAttribute() { } + } + public class StringConverter : ReactiveUI.IBindingTypeConverter, Splat.IEnableLogger + { + public StringConverter() { } + public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } + public bool TryConvert(object from, System.Type toType, object conversionHint, out object result) { } + } + public class static SuspensionHostExtensions + { + public static T GetAppState(this ReactiveUI.ISuspensionHost item) { } + public static System.IObservable ObserveAppState(this ReactiveUI.ISuspensionHost item) + where T : class { } + public static System.IDisposable SetupDefaultSuspendResume(this ReactiveUI.ISuspensionHost item, ReactiveUI.ISuspensionDriver driver = null) { } + } + public class UnhandledErrorException : System.Exception + { + public UnhandledErrorException() { } + public UnhandledErrorException(string message) { } + public UnhandledErrorException(string message, System.Exception innerException) { } + protected UnhandledErrorException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + } + public class UnhandledInteractionException : System.Exception + { + public UnhandledInteractionException(ReactiveUI.Interaction interaction, TInput input) { } + public UnhandledInteractionException() { } + public UnhandledInteractionException(string message) { } + public UnhandledInteractionException(string message, System.Exception innerException) { } + protected UnhandledInteractionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public TInput Input { get; } + public ReactiveUI.Interaction Interaction { get; } + public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + } + [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.All)] + public class ViewContractAttribute : System.Attribute + { + public ViewContractAttribute(string contract) { } + public string Contract { get; } + } + public class static ViewForMixins + { + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Func> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action> block) { } + public static void WhenActivated(this ReactiveUI.IActivatableViewModel item, System.Action block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Func> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action> block, ReactiveUI.IViewFor view) { } + public static System.IDisposable WhenActivated(this ReactiveUI.IActivatableView item, System.Action block, ReactiveUI.IViewFor view = null) { } + } + public class static ViewLocator + { + public static ReactiveUI.IViewLocator Current { get; } + } + public class ViewLocatorNotFoundException : System.Exception + { + public ViewLocatorNotFoundException() { } + public ViewLocatorNotFoundException(string message) { } + public ViewLocatorNotFoundException(string message, System.Exception innerException) { } + protected ViewLocatorNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + } + public sealed class ViewModelActivator : System.IDisposable + { + public ViewModelActivator() { } + public System.IObservable Activated { get; } + public System.IObservable Deactivated { get; } + public System.IDisposable Activate() { } + public void Deactivate(bool ignoreRefCount = False) { } + public void Dispose() { } + } + public class WaitForDispatcherScheduler : System.Reactive.Concurrency.IScheduler + { + public WaitForDispatcherScheduler(System.Func schedulerFactory) { } + public System.DateTimeOffset Now { get; } + public System.IDisposable Schedule(TState state, System.Func action) { } + public System.IDisposable Schedule(TState state, System.TimeSpan dueTime, System.Func action) { } + public System.IDisposable Schedule(TState state, System.DateTimeOffset dueTime, System.Func action) { } + } + public class WeakEventManager + where TEventSource : class + where TEventHandler : class + { + protected WeakEventManager() { } + public static void AddHandler(TEventSource source, TEventHandler handler) { } + public static void DeliverEvent(TEventSource sender, TEventArgs args) { } + public static void RemoveHandler(TEventSource source, TEventHandler handler) { } + protected virtual void StartListening(object source) { } + protected virtual void StopListening(object source) { } + } + public class static WhenAnyMixin + { + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Func, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Func, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Linq.Expressions.Expression> property10, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Linq.Expressions.Expression> property10, System.Linq.Expressions.Expression> property11, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAny(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Linq.Expressions.Expression> property10, System.Linq.Expressions.Expression> property11, System.Linq.Expressions.Expression> property12, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Func, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Func, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Linq.Expressions.Expression property9, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Linq.Expressions.Expression property9, System.Linq.Expressions.Expression property10, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Linq.Expressions.Expression property9, System.Linq.Expressions.Expression property10, System.Linq.Expressions.Expression property11, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyDynamic(this TSender This, System.Linq.Expressions.Expression property1, System.Linq.Expressions.Expression property2, System.Linq.Expressions.Expression property3, System.Linq.Expressions.Expression property4, System.Linq.Expressions.Expression property5, System.Linq.Expressions.Expression property6, System.Linq.Expressions.Expression property7, System.Linq.Expressions.Expression property8, System.Linq.Expressions.Expression property9, System.Linq.Expressions.Expression property10, System.Linq.Expressions.Expression property11, System.Linq.Expressions.Expression property12, System.Func, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, ReactiveUI.IObservedChange, TRet> selector) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Func selector) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Func selector) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Func selector) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Func selector) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Func selector) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Func selector) { } + public static System.IObservable> WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Func selector) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Func selector) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Func selector) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Linq.Expressions.Expression> property10, System.Func selector) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Linq.Expressions.Expression> property10, System.Linq.Expressions.Expression> property11, System.Func selector) { } + public static System.IObservable WhenAnyValue(this TSender This, System.Linq.Expressions.Expression> property1, System.Linq.Expressions.Expression> property2, System.Linq.Expressions.Expression> property3, System.Linq.Expressions.Expression> property4, System.Linq.Expressions.Expression> property5, System.Linq.Expressions.Expression> property6, System.Linq.Expressions.Expression> property7, System.Linq.Expressions.Expression> property8, System.Linq.Expressions.Expression> property9, System.Linq.Expressions.Expression> property10, System.Linq.Expressions.Expression> property11, System.Linq.Expressions.Expression> property12, System.Func selector) { } + } + public class static WhenAnyObservableMixin + { + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Linq.Expressions.Expression>> obs10) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Linq.Expressions.Expression>> obs10, System.Linq.Expressions.Expression>> obs11) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Linq.Expressions.Expression>> obs10, System.Linq.Expressions.Expression>> obs11, System.Linq.Expressions.Expression>> obs12) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Linq.Expressions.Expression>> obs10, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Linq.Expressions.Expression>> obs10, System.Linq.Expressions.Expression>> obs11, System.Func selector) + where TSender : class { } + public static System.IObservable WhenAnyObservable(this TSender This, System.Linq.Expressions.Expression>> obs1, System.Linq.Expressions.Expression>> obs2, System.Linq.Expressions.Expression>> obs3, System.Linq.Expressions.Expression>> obs4, System.Linq.Expressions.Expression>> obs5, System.Linq.Expressions.Expression>> obs6, System.Linq.Expressions.Expression>> obs7, System.Linq.Expressions.Expression>> obs8, System.Linq.Expressions.Expression>> obs9, System.Linq.Expressions.Expression>> obs10, System.Linq.Expressions.Expression>> obs11, System.Linq.Expressions.Expression>> obs12, System.Func selector) + where TSender : class { } + } +} +namespace System.Reactive.Disposables +{ + public class static DisposableMixins + { + public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) + where T : System.IDisposable { } + } +} \ No newline at end of file diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.Testing.netcoreapp3.0.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.Testing.netcoreapp3.0.approved.txt new file mode 100644 index 000000000..14a6605b2 --- /dev/null +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.Testing.netcoreapp3.0.approved.txt @@ -0,0 +1,43 @@ +[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.0", FrameworkDisplayName="")] +namespace ReactiveUI.Testing +{ + public interface IBuilder { } + public class static IBuilderExtensions + { + public static TBuilder With(this TBuilder builder, ref TField field, TField value) + where TBuilder : ReactiveUI.Testing.IBuilder { } + public static TBuilder With(this TBuilder builder, ref System.Collections.Generic.List field, System.Collections.Generic.IEnumerable values) + where TBuilder : ReactiveUI.Testing.IBuilder { } + public static TBuilder With(this TBuilder builder, ref System.Collections.Generic.List field, TField value) + where TBuilder : ReactiveUI.Testing.IBuilder { } + public static TBuilder With(this TBuilder builder, ref System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.KeyValuePair keyValuePair) + where TBuilder : ReactiveUI.Testing.IBuilder { } + public static TBuilder With(this TBuilder builder, ref System.Collections.Generic.Dictionary dictionary, TKey key, TField value) + where TBuilder : ReactiveUI.Testing.IBuilder { } + public static TBuilder With(this TBuilder builder, ref System.Collections.Generic.Dictionary dictionary, System.Collections.Generic.IDictionary keyValuePair) { } + } + public class static MessageBusExtensions + { + public static TRet With(this ReactiveUI.IMessageBus messageBus, System.Func block) { } + public static void With(this ReactiveUI.IMessageBus messageBus, System.Action block) { } + public static System.IDisposable WithMessageBus(this ReactiveUI.IMessageBus messageBus) { } + } + public class static SchedulerExtensions + { + public static void AdvanceByMs(this Microsoft.Reactive.Testing.TestScheduler sched, double milliseconds) { } + public static void AdvanceToMs(this Microsoft.Reactive.Testing.TestScheduler sched, double milliseconds) { } + public static long FromTimeSpan(this Microsoft.Reactive.Testing.TestScheduler sched, System.TimeSpan span) { } + public static Microsoft.Reactive.Testing.Recorded> OnCompletedAt(this Microsoft.Reactive.Testing.TestScheduler sched, double milliseconds) { } + public static Microsoft.Reactive.Testing.Recorded> OnErrorAt(this Microsoft.Reactive.Testing.TestScheduler sched, double milliseconds, System.Exception ex) { } + public static Microsoft.Reactive.Testing.Recorded> OnNextAt(this Microsoft.Reactive.Testing.TestScheduler sched, double milliseconds, T value) { } + public static TRet With(this T sched, System.Func block) + where T : System.Reactive.Concurrency.IScheduler { } + public static void With(this T sched, System.Action block) + where T : System.Reactive.Concurrency.IScheduler { } + public static System.Threading.Tasks.Task WithAsync(this T sched, System.Func> block) + where T : System.Reactive.Concurrency.IScheduler { } + public static System.Threading.Tasks.Task WithAsync(this T sched, System.Func block) + where T : System.Reactive.Concurrency.IScheduler { } + public static System.IDisposable WithScheduler(System.Reactive.Concurrency.IScheduler sched) { } + } +} \ No newline at end of file diff --git a/src/ReactiveUI.Tests/Activation/ActivatingViewFetcher.cs b/src/ReactiveUI.Tests/Activation/ActivatingViewFetcher.cs index 0c52c0dad..316abeb5b 100644 --- a/src/ReactiveUI.Tests/Activation/ActivatingViewFetcher.cs +++ b/src/ReactiveUI.Tests/Activation/ActivatingViewFetcher.cs @@ -16,7 +16,7 @@ public int GetAffinityForView(Type view) return view == typeof(ActivatingView) ? 100 : 0; } - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { var av = view as ActivatingView; return av.Loaded.Select(_ => true).Merge(av.Unloaded.Select(_ => false)); diff --git a/src/ReactiveUI.Tests/Activation/ActivatingViewModel.cs b/src/ReactiveUI.Tests/Activation/ActivatingViewModel.cs index 24b20cc6a..ac3a15047 100644 --- a/src/ReactiveUI.Tests/Activation/ActivatingViewModel.cs +++ b/src/ReactiveUI.Tests/Activation/ActivatingViewModel.cs @@ -7,7 +7,7 @@ namespace ReactiveUI.Tests { - public class ActivatingViewModel : ReactiveObject, ISupportsActivation + public class ActivatingViewModel : ReactiveObject, IActivatableViewModel { public ActivatingViewModel() { diff --git a/src/ReactiveUI.Tests/Platforms/uwp/App.xaml b/src/ReactiveUI.Tests/Platforms/uwp/App.xaml deleted file mode 100644 index e5112eac6..000000000 --- a/src/ReactiveUI.Tests/Platforms/uwp/App.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/src/ReactiveUI.Tests/Platforms/uwp/App.xaml.cs b/src/ReactiveUI.Tests/Platforms/uwp/App.xaml.cs deleted file mode 100644 index 4fc0d335a..000000000 --- a/src/ReactiveUI.Tests/Platforms/uwp/App.xaml.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -using Xunit.Runners.UI; - -namespace ReactiveUI.Tests.Uwp -{ - /// - /// Interaction logic for App.xaml. - /// - public partial class App - { - protected override void OnInitializeRunner() - { - AddTestAssembly(GetType().GetTypeInfo().Assembly); - InitializeRunner(); - } - - partial void InitializeRunner(); - } -} diff --git a/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/ControlsReactiveCollectionTest.cs b/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/ControlsReactiveCollectionTest.cs deleted file mode 100644 index f439d8b17..000000000 --- a/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/ControlsReactiveCollectionTest.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Xunit; - -#if NETFX_CORE -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Markup; -#else -using FactAttribute = Xunit.WpfFactAttribute; -#endif - -namespace ReactiveUI.Tests.Xaml -{ - public class ControlsReactiveCollectionTest - { - [Fact] - public void DataboundReactiveListDoesNotThrowForAddRange() - { - var vm = new LegacyPropertyBindViewModel(); - var view = new LegacyPropertyBindView - { - ViewModel = vm - }; - var fixture = new PropertyBinderImplementation(); - fixture.OneWayBind(vm, view, m => m.SomeCollectionOfStrings, v => v.FakeItemsControl.ItemsSource); - - // eliminate the ResetChangeThreshold from the equation - vm.SomeCollectionOfStrings.ResetChangeThreshold = int.MinValue; - - // Within the reset threshold - vm.SomeCollectionOfStrings.AddRange(Create(5)); - vm.SomeCollectionOfStrings.AddRange(Create(20)); - - IEnumerable Create(int numElements) => Enumerable.Range(1, numElements).Select(i => $"item_{i}"); - } - - [Fact] - public void DataboundReactiveListDoesNotThrowForInsertRange() - { - var vm = new LegacyPropertyBindViewModel(); - var view = new LegacyPropertyBindView - { - ViewModel = vm - }; - var fixture = new PropertyBinderImplementation(); - fixture.OneWayBind(vm, view, m => m.SomeCollectionOfStrings, v => v.FakeItemsControl.ItemsSource); - vm.SomeCollectionOfStrings.ResetChangeThreshold = int.MinValue; - - foreach (var item in Create(5)) - { - vm.SomeCollectionOfStrings.Add(item); - } - - // within reset threshold - vm.SomeCollectionOfStrings.InsertRange(2, Create(5)); - - // outside reset threshold - vm.SomeCollectionOfStrings.InsertRange(2, Create(20)); - - IEnumerable Create(int numElements) => Enumerable.Range(1, numElements).Select(i => $"item_{i}"); - } - - [Fact] - public void DataboundReactiveListDoesNotThrowForRemoveRange() - { - var vm = new LegacyPropertyBindViewModel(); - var view = new LegacyPropertyBindView - { - ViewModel = vm - }; - var fixture = new PropertyBinderImplementation(); - fixture.OneWayBind(vm, view, m => m.SomeCollectionOfStrings, v => v.FakeItemsControl.ItemsSource); - vm.SomeCollectionOfStrings.ResetChangeThreshold = int.MinValue; - - foreach (var item in Enumerable.Range(1, 40).Select(i => $"item_{i}")) - { - vm.SomeCollectionOfStrings.Add(item); - } - - // within reset threshold - vm.SomeCollectionOfStrings.RemoveRange(2, 5); - - // outside reset threshold - vm.SomeCollectionOfStrings.RemoveRange(2, 20); - } - } -} diff --git a/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindView.cs b/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindView.cs deleted file mode 100644 index dc0b196d8..000000000 --- a/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindView.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -#if NETFX_CORE -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -#else -using System.Windows.Controls; -#endif - -namespace ReactiveUI.Tests.Xaml -{ - public class LegacyPropertyBindView : Control, IViewFor - { - public static readonly DependencyProperty ViewModelProperty = - DependencyProperty.Register("ViewModel", typeof(LegacyPropertyBindViewModel), typeof(LegacyPropertyBindView), new PropertyMetadata(null)); - - public LegacyPropertyBindView() - { - SomeTextBox = new TextBox(); - Property2 = new TextBox(); - FakeControl = new PropertyBindFakeControl(); - FakeItemsControl = new ListBox(); - } - - public TextBox SomeTextBox { get; set; } - - public TextBox Property2 { get; set; } - - public PropertyBindFakeControl FakeControl { get; set; } - - public ListBox FakeItemsControl { get; set; } - - public LegacyPropertyBindViewModel ViewModel - { - get => (LegacyPropertyBindViewModel)GetValue(ViewModelProperty); - set => SetValue(ViewModelProperty, value); - } - - object IViewFor.ViewModel - { - get => ViewModel; - set => ViewModel = (LegacyPropertyBindViewModel)value; - } - } -} diff --git a/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindViewModel.cs b/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindViewModel.cs deleted file mode 100644 index 5d8bafc03..000000000 --- a/src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindViewModel.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ReactiveUI.Legacy; - -#pragma warning disable CS0618 // Item has been marked as Obsolete - -namespace ReactiveUI.Tests.Xaml -{ - public class LegacyPropertyBindViewModel : ReactiveObject - { - private decimal _JustADecimal; - - private double _JustADouble; - - private int _JustAInt32; - - private PropertyBindModel _Model; - - private double? _NullableDouble; - - private string _Property1; - - private int _Property2; - - public LegacyPropertyBindViewModel(PropertyBindModel model = null) - { - Model = model ?? new PropertyBindModel - { - AThing = 42, - AnotherThing = "Baz" - }; - SomeCollectionOfStrings = new ReactiveList(new[] { "Foo", "Bar" }); - } - - public decimal JustADecimal - { - get => _JustADecimal; - set => this.RaiseAndSetIfChanged(ref _JustADecimal, value); - } - - public double JustADouble - { - get => _JustADouble; - set => this.RaiseAndSetIfChanged(ref _JustADouble, value); - } - - public int JustAInt32 - { - get => _JustAInt32; - set => this.RaiseAndSetIfChanged(ref _JustAInt32, value); - } - - public PropertyBindModel Model - { - get => _Model; - set => this.RaiseAndSetIfChanged(ref _Model, value); - } - - public double? NullableDouble - { - get => _NullableDouble; - set => this.RaiseAndSetIfChanged(ref _NullableDouble, value); - } - - public string Property1 - { - get => _Property1; - set => this.RaiseAndSetIfChanged(ref _Property1, value); - } - - public int Property2 - { - get => _Property2; - set => this.RaiseAndSetIfChanged(ref _Property2, value); - } - - public ReactiveList SomeCollectionOfStrings { get; } - } -} diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.net461.approved.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.net461.approved.txt index bb01b4e58..49cbb1af7 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.net461.approved.txt +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.net461.approved.txt @@ -4,7 +4,7 @@ namespace ReactiveUI.Winforms public class ActivationForViewFetcher : ReactiveUI.IActivationForViewFetcher, Splat.IEnableLogger { public ActivationForViewFetcher() { } - public System.IObservable GetActivationForView(ReactiveUI.IActivatable view) { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } public int GetAffinityForView(System.Type view) { } } public class ContentControlBindingHook : ReactiveUI.IPropertyBindingHook @@ -30,7 +30,7 @@ namespace ReactiveUI.Winforms public PlatformOperations() { } public string GetOrientation() { } } - public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatable, ReactiveUI.IViewFor, ReactiveUI.IViewFor + public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { public ReactiveUserControl() { } @@ -47,7 +47,7 @@ namespace ReactiveUI.Winforms public void Register(System.Action, System.Type> registerFunction) { } } [System.ComponentModel.DefaultPropertyAttribute("ViewModel")] - public class RoutedControlHost : System.Windows.Forms.UserControl, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public class RoutedControlHost : System.Windows.Forms.UserControl, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { public RoutedControlHost() { } [System.ComponentModel.CategoryAttribute("ReactiveUI")] @@ -61,7 +61,7 @@ namespace ReactiveUI.Winforms [System.ComponentModel.BrowsableAttribute(false)] public ReactiveUI.IViewLocator ViewLocator { get; set; } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; protected override void Dispose(bool disposing) { } } public class TableContentSetMethodBindingConverter : ReactiveUI.ISetMethodBindingConverter, Splat.IEnableLogger @@ -71,7 +71,7 @@ namespace ReactiveUI.Winforms public object PerformSet(object toTarget, object newValue, object[] arguments) { } } [System.ComponentModel.DefaultPropertyAttribute("ViewModel")] - public class ViewModelControlHost : System.Windows.Forms.UserControl, ReactiveUI.IActivatable, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.IViewFor, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged + public class ViewModelControlHost : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IReactiveObject, ReactiveUI.IViewFor, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging { public ViewModelControlHost() { } [System.ComponentModel.BindableAttribute(true)] @@ -97,7 +97,7 @@ namespace ReactiveUI.Winforms [System.ComponentModel.DescriptionAttribute("The viewmodel to host.")] public object ViewModel { get; set; } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - public event ReactiveUI.PropertyChangingEventHandler PropertyChanging; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; protected override void Dispose(bool disposing) { } } public class WinformsCreatesObservableForProperty : ReactiveUI.ICreatesObservableForProperty, Splat.IEnableLogger @@ -106,46 +106,4 @@ namespace ReactiveUI.Winforms public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged = False) { } public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged = False, bool suppressWarnings = False) { } } -} -namespace ReactiveUI.Winforms.Legacy -{ - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveDerivedBindingList : ReactiveUI.INotifyCollectionChanging, ReactiveUI.INotifyPropertyChanging, ReactiveUI.IReactiveObject, ReactiveUI.Legacy.IReactiveCollection, ReactiveUI.Legacy.IReactiveDerivedList, ReactiveUI.Legacy.IReactiveNotifyCollectionChanged, ReactiveUI.Legacy.IReactiveNotifyCollectionItemChanged, ReactiveUI.Legacy.IReadOnlyReactiveCollection, ReactiveUI.Legacy.IReadOnlyReactiveList, Splat.IEnableLogger, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.IBindingList, System.ComponentModel.INotifyPropertyChanged, System.IDisposable { } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class static ObservableCollectionMixin - { - public static ReactiveUI.Winforms.Legacy.IReactiveDerivedBindingList CreateDerivedBindingList(this System.Collections.Generic.IEnumerable collection, System.Func selector, System.Action removed, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null) { } - public static ReactiveUI.Winforms.Legacy.IReactiveDerivedBindingList CreateDerivedBindingList(this System.Collections.Generic.IEnumerable collection, System.Func selector, System.Func filter = null, System.Func orderer = null, System.IObservable signalReset = null) { } - public static ReactiveUI.Winforms.Legacy.IReactiveDerivedBindingList CreateDerivedBindingList(this System.Collections.Generic.IEnumerable collection, System.Func selector, System.Action removed, System.Func filter = null, System.Func orderer = null) { } - public static ReactiveUI.Winforms.Legacy.IReactiveDerivedBindingList CreateDerivedBindingList(this System.Collections.Generic.IEnumerable collection, System.Func selector, System.Func filter = null, System.Func orderer = null) { } - } - [System.ObsoleteAttribute("ReactiveList is no longer supported. We suggest replacing it with DynamicData htt" + - "ps://github.com/rolandpheasant/dynamicdata")] - public class ReactiveBindingList : ReactiveUI.Legacy.ReactiveList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ComponentModel.IBindingList, System.ComponentModel.ICancelAddNew, System.ComponentModel.IRaiseItemChangedEvents - { - public ReactiveBindingList() { } - public ReactiveBindingList(System.Collections.Generic.IEnumerable items) { } - public bool AllowEdit { get; } - public bool AllowNew { get; } - public bool AllowRemove { get; } - public bool IsSorted { get; } - public bool RaisesItemChangedEvents { get; } - public System.ComponentModel.ListSortDirection SortDirection { get; } - public System.ComponentModel.PropertyDescriptor SortProperty { get; } - public bool SupportsChangeNotification { get; } - public bool SupportsSearching { get; } - public bool SupportsSorting { get; } - public event System.ComponentModel.ListChangedEventHandler ListChanged; - public void AddIndex(System.ComponentModel.PropertyDescriptor property) { } - public object AddNew() { } - public void ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) { } - public void CancelNew(int itemIndex) { } - public void EndNew(int itemIndex) { } - public int Find(System.ComponentModel.PropertyDescriptor property, object key) { } - protected override void RaiseCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { } - public void RemoveIndex(System.ComponentModel.PropertyDescriptor property) { } - public void RemoveSort() { } - } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.netcoreapp3.0.approved.txt b/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.netcoreapp3.0.approved.txt new file mode 100644 index 000000000..8a9c6ef14 --- /dev/null +++ b/src/ReactiveUI.Tests/Platforms/winforms/API/ApiApprovalTests.Winforms.netcoreapp3.0.approved.txt @@ -0,0 +1,109 @@ +[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.0", FrameworkDisplayName="")] +namespace ReactiveUI.Winforms +{ + public class ActivationForViewFetcher : ReactiveUI.IActivationForViewFetcher, Splat.IEnableLogger + { + public ActivationForViewFetcher() { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } + public int GetAffinityForView(System.Type view) { } + } + public class ContentControlBindingHook : ReactiveUI.IPropertyBindingHook + { + public ContentControlBindingHook() { } + public bool ExecuteHook(object source, object target, System.Func[]> getCurrentViewModelProperties, System.Func[]> getCurrentViewProperties, ReactiveUI.BindingDirection direction) { } + } + public class CreatesWinformsCommandBinding : ReactiveUI.ICreatesCommandBinding + { + public CreatesWinformsCommandBinding() { } + public System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter) { } + public System.IDisposable BindCommandToObject(System.Windows.Input.ICommand command, object target, System.IObservable commandParameter, string eventName) { } + public int GetAffinityForObject(System.Type type, bool hasEventTarget) { } + } + public class PanelSetMethodBindingConverter : ReactiveUI.ISetMethodBindingConverter, Splat.IEnableLogger + { + public PanelSetMethodBindingConverter() { } + public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } + public object PerformSet(object toTarget, object newValue, object[] arguments) { } + } + public class PlatformOperations + { + public PlatformOperations() { } + public string GetOrientation() { } + } + public class ReactiveUserControl : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor + where TViewModel : class + { + public ReactiveUserControl() { } + [System.ComponentModel.BindableAttribute(true)] + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DescriptionAttribute("The ViewModel.")] + [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public TViewModel ViewModel { get; set; } + protected override void Dispose(bool disposing) { } + } + public class Registrations + { + public Registrations() { } + public void Register(System.Action, System.Type> registerFunction) { } + } + [System.ComponentModel.DefaultPropertyAttribute("ViewModel")] + public class RoutedControlHost : System.Windows.Forms.UserControl, ReactiveUI.IReactiveObject, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging + { + public RoutedControlHost() { } + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DescriptionAttribute("The default control when no viewmodel is specified")] + public System.Windows.Forms.Control DefaultContent { get; set; } + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DescriptionAttribute("The router.")] + public ReactiveUI.RoutingState Router { get; set; } + [System.ComponentModel.BrowsableAttribute(false)] + public System.IObservable ViewContractObservable { get; set; } + [System.ComponentModel.BrowsableAttribute(false)] + public ReactiveUI.IViewLocator ViewLocator { get; set; } + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; + protected override void Dispose(bool disposing) { } + } + public class TableContentSetMethodBindingConverter : ReactiveUI.ISetMethodBindingConverter, Splat.IEnableLogger + { + public TableContentSetMethodBindingConverter() { } + public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } + public object PerformSet(object toTarget, object newValue, object[] arguments) { } + } + [System.ComponentModel.DefaultPropertyAttribute("ViewModel")] + public class ViewModelControlHost : System.Windows.Forms.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IReactiveObject, ReactiveUI.IViewFor, Splat.IEnableLogger, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging + { + public ViewModelControlHost() { } + [System.ComponentModel.BindableAttribute(true)] + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DefaultValueAttribute(true)] + [System.ComponentModel.DescriptionAttribute("Cache Views")] + public bool CacheViews { get; set; } + [System.ComponentModel.BindableAttribute(true)] + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DescriptionAttribute("The Current View")] + public object Content { get; set; } + public System.Windows.Forms.Control CurrentView { get; } + public static bool DefaultCacheViewsEnabled { get; set; } + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DescriptionAttribute("The default control when no viewmodel is specified")] + public System.Windows.Forms.Control DefaultContent { get; set; } + [System.ComponentModel.BrowsableAttribute(false)] + public System.IObservable ViewContractObservable { get; set; } + [System.ComponentModel.BrowsableAttribute(false)] + public ReactiveUI.IViewLocator ViewLocator { get; set; } + [System.ComponentModel.BindableAttribute(true)] + [System.ComponentModel.CategoryAttribute("ReactiveUI")] + [System.ComponentModel.DescriptionAttribute("The viewmodel to host.")] + public object ViewModel { get; set; } + public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; + public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging; + protected override void Dispose(bool disposing) { } + } + public class WinformsCreatesObservableForProperty : ReactiveUI.ICreatesObservableForProperty, Splat.IEnableLogger + { + public WinformsCreatesObservableForProperty() { } + public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged = False) { } + public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged = False, bool suppressWarnings = False) { } + } +} \ No newline at end of file diff --git a/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingTests.cs b/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingTests.cs index dafeff797..f7b011dea 100755 --- a/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingTests.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/CommandBindingTests.cs @@ -100,7 +100,7 @@ public void CommandBinderAffectsEnabledState() canExecute.OnNext(true); var cmd = ReactiveCommand.Create(() => { }, canExecute); - var input = new Button { }; + var input = new Button(); using (fixture.BindCommandToObject(cmd, input, Observable.Return((object)5))) { @@ -120,7 +120,7 @@ public void CommandBinderAffectsEnabledStateForComponents() canExecute.OnNext(true); var cmd = ReactiveCommand.Create(() => { }, canExecute); - var input = new ToolStripButton { }; // ToolStripButton is a Component, not a Control + var input = new ToolStripButton(); // ToolStripButton is a Component, not a Control using (fixture.BindCommandToObject(cmd, input, Observable.Return((object)5))) { diff --git a/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestControl.cs b/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestControl.cs index 4e71ff241..139420028 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestControl.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestControl.cs @@ -7,7 +7,7 @@ namespace ReactiveUI.Tests.Winforms { - public class TestControl : Control, IActivatable + public class TestControl : Control, IActivatableView { } } \ No newline at end of file diff --git a/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestForm.cs b/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestForm.cs index ff4165544..7219618e0 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestForm.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestForm.cs @@ -7,7 +7,7 @@ namespace ReactiveUI.Tests.Winforms { - public class TestForm : Form, IActivatable + public class TestForm : Form, IActivatableView { } } diff --git a/src/ReactiveUI.Tests/Platforms/winforms/ReactiveBindingListTests.cs b/src/ReactiveUI.Tests/Platforms/winforms/ReactiveBindingListTests.cs deleted file mode 100644 index 7a5953c7f..000000000 --- a/src/ReactiveUI.Tests/Platforms/winforms/ReactiveBindingListTests.cs +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using ReactiveUI.Legacy; -using ReactiveUI.Winforms.Legacy; -using Xunit; - -#pragma warning disable CS0618 // Item has been marked as Obsolete - -namespace ReactiveUI.Tests.Winforms.Legacy -{ - public class ReactiveBindingListTests - { - [Fact] - public void RaisesListChangedEventOnAdd() - { - var target = new ReactiveBindingList(); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.Add("item"); - - Assert.Equal(1, capturedEvents.Count); - Assert.True(capturedEvents[0].ListChangedType == ListChangedType.ItemAdded); - Assert.True(capturedEvents[0].NewIndex == 0); - } - - [Fact] - public void RaisesListChangedEventOnRemove() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.Remove("item2"); - - Assert.Equal(1, capturedEvents.Count); - Assert.True(capturedEvents[0].ListChangedType == ListChangedType.ItemDeleted); - Assert.Equal(1, capturedEvents[0].NewIndex); - Assert.Equal(-1, capturedEvents[0].OldIndex); - } - - [Fact] - public void RaisesListChangedEventOnChange() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target[0] = "changed item1"; - - Assert.Equal(1, capturedEvents.Count); - Assert.True(capturedEvents[0].ListChangedType == ListChangedType.ItemChanged); - Assert.Equal(0, capturedEvents[0].NewIndex); - Assert.Equal(-1, capturedEvents[0].OldIndex); - } - - [Fact] - public void RaisesListChangedEventOnMove() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.Move(0, 1); - - Assert.Equal(1, capturedEvents.Count); - - Assert.True(capturedEvents[0].ListChangedType == ListChangedType.ItemMoved); - Assert.Equal(1, capturedEvents[0].NewIndex); - Assert.Equal(0, capturedEvents[0].OldIndex); - } - - [Fact] - public void RaisesListChangedEventOnReset() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.Reset(); - Assert.Equal(1, capturedEvents.Count); - - Assert.True(capturedEvents[0].ListChangedType == ListChangedType.Reset); - Assert.Equal(-1, capturedEvents[0].NewIndex); - Assert.Equal(-1, capturedEvents[0].OldIndex); - } - - [Fact] - public void RaisesMultipleEventsListChangedEventOnRemoveRange() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2", "item3" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.RemoveRange(1, 2); - Assert.Equal(2, capturedEvents.Count); - - Assert.True(capturedEvents.All(x => x.ListChangedType == ListChangedType.ItemDeleted)); - Assert.Equal(1, capturedEvents[0].NewIndex); - Assert.Equal(-1, capturedEvents[0].OldIndex); - - Assert.Equal(2, capturedEvents[1].NewIndex); - Assert.Equal(-1, capturedEvents[1].OldIndex); - } - - [Fact] - public void RaisesMultipleEventsListChangedEventOnAddRange() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2", "item3" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.AddRange(new[] { "item4", "item5", "item6" }); - Assert.Equal(3, capturedEvents.Count); - - Assert.True(capturedEvents.All(x => x.ListChangedType == ListChangedType.ItemAdded)); - Assert.Equal(3, capturedEvents[0].NewIndex); - Assert.Equal(-1, capturedEvents[0].OldIndex); - - Assert.Equal(4, capturedEvents[1].NewIndex); - Assert.Equal(-1, capturedEvents[1].OldIndex); - - Assert.Equal(5, capturedEvents[2].NewIndex); - Assert.Equal(-1, capturedEvents[2].OldIndex); - } - - [Fact] - public void RaisesMultipleEventsListChangedEventOnInsertRange() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2", "item3" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.InsertRange(1, new[] { "item4", "item5", "item6" }); - Assert.Equal(3, capturedEvents.Count); - - Assert.True(capturedEvents.All(x => x.ListChangedType == ListChangedType.ItemAdded)); - Assert.Equal(1, capturedEvents[0].NewIndex); - Assert.Equal(-1, capturedEvents[0].OldIndex); - - Assert.Equal(2, capturedEvents[1].NewIndex); - Assert.Equal(-1, capturedEvents[1].OldIndex); - - Assert.Equal(3, capturedEvents[2].NewIndex); - Assert.Equal(-1, capturedEvents[2].OldIndex); - } - - [Fact] - public void RaisesResetEventWhileItemsAddedOnSuppressChanges() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2", "item3" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - using (target.SuppressChangeNotifications()) - { - target.InsertRange(1, new[] { "item4", "item5", "item6" }); - } - - Assert.Equal(1, capturedEvents.Count); - Assert.Equal(ListChangedType.Reset, capturedEvents[0].ListChangedType); - } - - [Fact] - public void RaisesResetEventWhenAboveTreshold() - { - var target = new ReactiveBindingList(new string[] { "item1", "item2", "item3" }); - var capturedEvents = new List(); - target.ListChanged += (o, e) => { capturedEvents.Add(e); }; - - target.ResetChangeThreshold = 0; - target.InsertRange(1, Enumerable.Repeat("added1", 35)); - - Assert.Equal(1, capturedEvents.Count); - Assert.Equal(ListChangedType.Reset, capturedEvents[0].ListChangedType); - } - - [Fact] - public void DerivedCollectionsShouldRaiseListChangedEvents() - { - var input = new[] { "Foo", "Bar", "Baz", "Bamf" }; - var fixture = new ReactiveBindingList( - input.Select(x => new TestFixture { IsOnlyOneWord = x })); - - IBindingList output = fixture.CreateDerivedBindingList(new Func(x => x.IsOnlyOneWord)); - var capturedEvents = new List(); - output.ListChanged += (o, e) => capturedEvents.Add(e); - - input.AssertAreEqual((IEnumerable)output); - - fixture.Add(new TestFixture { IsOnlyOneWord = "Hello" }); - Assert.Equal(capturedEvents.Last().ListChangedType, ListChangedType.ItemAdded); - Assert.Equal(5, output.Count); - Assert.Equal("Hello", output[4]); - - fixture.RemoveAt(4); - Assert.Equal(capturedEvents.Last().ListChangedType, ListChangedType.ItemDeleted); - Assert.Equal(4, output.Count); - - // replacing results in - // 1 itemdeleted - // 2 itemadded - fixture[1] = new TestFixture { IsOnlyOneWord = "Goodbye" }; - Assert.Equal(4, output.Count); - Assert.Equal("Goodbye", output[1]); - Assert.Equal(capturedEvents[capturedEvents.Count - 2].ListChangedType, ListChangedType.ItemDeleted); - Assert.Equal(capturedEvents[capturedEvents.Count - 1].ListChangedType, ListChangedType.ItemAdded); - - fixture.Clear(); - Assert.Equal(0, output.Count); - Assert.Equal(capturedEvents.Last().ListChangedType, ListChangedType.Reset); - } - } -} diff --git a/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.net461.approved.txt b/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.net461.approved.txt index a2b9191ed..bda7ababc 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.net461.approved.txt +++ b/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.net461.approved.txt @@ -6,7 +6,7 @@ namespace ReactiveUI public class ActivationForViewFetcher : ReactiveUI.IActivationForViewFetcher { public ActivationForViewFetcher() { } - public System.IObservable GetActivationForView(ReactiveUI.IActivatable view) { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } public int GetAffinityForView(System.Type view) { } } public class AutoDataTemplateBindingHook : ReactiveUI.IPropertyBindingHook @@ -44,7 +44,7 @@ namespace ReactiveUI public PlatformOperations() { } public string GetOrientation() { } } - public abstract class ReactivePage : System.Windows.Controls.Page, ReactiveUI.IActivatable, ReactiveUI.IViewFor, ReactiveUI.IViewFor + public abstract class ReactivePage : System.Windows.Controls.Page, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { public static readonly System.Windows.DependencyProperty ViewModelProperty; @@ -52,7 +52,7 @@ namespace ReactiveUI public TViewModel BindingRoot { get; } public TViewModel ViewModel { get; set; } } - public abstract class ReactiveUserControl : System.Windows.Controls.UserControl, ReactiveUI.IActivatable, ReactiveUI.IViewFor, ReactiveUI.IViewFor + public abstract class ReactiveUserControl : System.Windows.Controls.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { public static readonly System.Windows.DependencyProperty ViewModelProperty; @@ -60,7 +60,7 @@ namespace ReactiveUI public TViewModel BindingRoot { get; } public TViewModel ViewModel { get; set; } } - public abstract class ReactiveWindow : System.Windows.Window, ReactiveUI.IActivatable, ReactiveUI.IViewFor, ReactiveUI.IViewFor + public abstract class ReactiveWindow : System.Windows.Window, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor where TViewModel : class { public static readonly System.Windows.DependencyProperty ViewModelProperty; @@ -68,7 +68,7 @@ namespace ReactiveUI public TViewModel BindingRoot { get; } public TViewModel ViewModel { get; set; } } - public class RoutedViewHost : ReactiveUI.TransitioningContentControl, ReactiveUI.IActivatable, Splat.IEnableLogger + public class RoutedViewHost : ReactiveUI.TransitioningContentControl, ReactiveUI.IActivatableView, Splat.IEnableLogger { public static readonly System.Windows.DependencyProperty DefaultContentProperty; public static readonly System.Windows.DependencyProperty RouterProperty; @@ -107,7 +107,7 @@ namespace ReactiveUI SlideLeft = 2, } } - public class ViewModelViewHost : ReactiveUI.TransitioningContentControl, ReactiveUI.IActivatable, ReactiveUI.IViewFor, Splat.IEnableLogger, System.IDisposable + public class ViewModelViewHost : ReactiveUI.TransitioningContentControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, Splat.IEnableLogger, System.IDisposable { public static readonly System.Windows.DependencyProperty DefaultContentProperty; public static readonly System.Windows.DependencyProperty ViewContractObservableProperty; diff --git a/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.netcoreapp3.0.approved.txt b/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.netcoreapp3.0.approved.txt new file mode 100644 index 000000000..6d23c2f09 --- /dev/null +++ b/src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.netcoreapp3.0.approved.txt @@ -0,0 +1,132 @@ +[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.0", FrameworkDisplayName="")] +[assembly: System.Windows.Markup.XmlnsDefinitionAttribute("http://reactiveui.net", "ReactiveUI")] +[assembly: System.Windows.ThemeInfoAttribute(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] +namespace ReactiveUI +{ + public class ActivationForViewFetcher : ReactiveUI.IActivationForViewFetcher + { + public ActivationForViewFetcher() { } + public System.IObservable GetActivationForView(ReactiveUI.IActivatableView view) { } + public int GetAffinityForView(System.Type view) { } + } + public class AutoDataTemplateBindingHook : ReactiveUI.IPropertyBindingHook + { + public AutoDataTemplateBindingHook() { } + public static System.Lazy DefaultItemTemplate { get; } + public bool ExecuteHook(object source, object target, System.Func[]> getCurrentViewModelProperties, System.Func[]> getCurrentViewProperties, ReactiveUI.BindingDirection direction) { } + } + public class AutoSuspendHelper : Splat.IEnableLogger + { + public AutoSuspendHelper(System.Windows.Application app) { } + public System.TimeSpan IdleTimeout { get; set; } + } + [System.FlagsAttribute()] + public enum BooleanToVisibilityHint + { + None = 0, + Inverse = 2, + UseHidden = 4, + } + public class BooleanToVisibilityTypeConverter : ReactiveUI.IBindingTypeConverter, Splat.IEnableLogger + { + public BooleanToVisibilityTypeConverter() { } + public int GetAffinityForObjects(System.Type fromType, System.Type toType) { } + public bool TryConvert(object from, System.Type toType, object conversionHint, out object result) { } + } + public class DependencyObjectObservableForProperty : ReactiveUI.ICreatesObservableForProperty, Splat.IEnableLogger + { + public DependencyObjectObservableForProperty() { } + public int GetAffinityForObject(System.Type type, string propertyName, bool beforeChanged = False) { } + public System.IObservable> GetNotificationForProperty(object sender, System.Linq.Expressions.Expression expression, string propertyName, bool beforeChanged = False, bool suppressWarnings = False) { } + } + public class PlatformOperations + { + public PlatformOperations() { } + public string GetOrientation() { } + } + public abstract class ReactivePage : System.Windows.Controls.Page, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor + where TViewModel : class + { + public static readonly System.Windows.DependencyProperty ViewModelProperty; + protected ReactivePage() { } + public TViewModel BindingRoot { get; } + public TViewModel ViewModel { get; set; } + } + public abstract class ReactiveUserControl : System.Windows.Controls.UserControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor + where TViewModel : class + { + public static readonly System.Windows.DependencyProperty ViewModelProperty; + protected ReactiveUserControl() { } + public TViewModel BindingRoot { get; } + public TViewModel ViewModel { get; set; } + } + public abstract class ReactiveWindow : System.Windows.Window, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, ReactiveUI.IViewFor + where TViewModel : class + { + public static readonly System.Windows.DependencyProperty ViewModelProperty; + protected ReactiveWindow() { } + public TViewModel BindingRoot { get; } + public TViewModel ViewModel { get; set; } + } + public class RoutedViewHost : ReactiveUI.TransitioningContentControl, ReactiveUI.IActivatableView, Splat.IEnableLogger + { + public static readonly System.Windows.DependencyProperty DefaultContentProperty; + public static readonly System.Windows.DependencyProperty RouterProperty; + public static readonly System.Windows.DependencyProperty ViewContractObservableProperty; + public RoutedViewHost() { } + public object DefaultContent { get; set; } + public ReactiveUI.RoutingState Router { get; set; } + public System.IObservable ViewContractObservable { get; set; } + public ReactiveUI.IViewLocator ViewLocator { get; set; } + } + [System.Windows.TemplatePartAttribute(Name="PART_Container", Type=typeof(System.Windows.FrameworkElement))] + [System.Windows.TemplatePartAttribute(Name="PART_CurrentContentPresentationSite", Type=typeof(System.Windows.Controls.ContentPresenter))] + [System.Windows.TemplatePartAttribute(Name="PART_PreviousContentPresentationSite", Type=typeof(System.Windows.Controls.ContentPresenter))] + [System.Windows.TemplateVisualStateAttribute(GroupName="PresentationStates", Name="Normal")] + public class TransitioningContentControl : System.Windows.Controls.ContentControl + { + public static readonly System.Windows.DependencyProperty TransitionPartProperty; + public static readonly System.Windows.DependencyProperty TransitionProperty; + public TransitioningContentControl() { } + public ReactiveUI.TransitioningContentControl.TransitionType Transition { get; set; } + public ReactiveUI.TransitioningContentControl.TransitionPartType TransitionPart { get; set; } + public event System.Windows.RoutedEventHandler TransitionCompleted; + public event System.Windows.RoutedEventHandler TransitionStarted; + public override void OnApplyTemplate() { } + protected override void OnContentChanged(object oldContent, object newContent) { } + public enum TransitionPartType + { + Out = 0, + In = 1, + OutIn = 2, + } + public enum TransitionType + { + Fade = 0, + FadeDown = 1, + SlideLeft = 2, + } + } + public class ViewModelViewHost : ReactiveUI.TransitioningContentControl, ReactiveUI.IActivatableView, ReactiveUI.IViewFor, Splat.IEnableLogger, System.IDisposable + { + public static readonly System.Windows.DependencyProperty DefaultContentProperty; + public static readonly System.Windows.DependencyProperty ViewContractObservableProperty; + public static readonly System.Windows.DependencyProperty ViewModelProperty; + public ViewModelViewHost() { } + public object DefaultContent { get; set; } + public string ViewContract { get; set; } + public System.IObservable ViewContractObservable { get; set; } + public ReactiveUI.IViewLocator ViewLocator { get; set; } + public object ViewModel { get; set; } + public void Dispose() { } + protected virtual void Dispose(bool isDisposing) { } + } +} +namespace ReactiveUI.Wpf +{ + public class Registrations + { + public Registrations() { } + public void Register(System.Action, System.Type> registerFunction) { } + } +} \ No newline at end of file diff --git a/src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfTestUserControl.cs b/src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfTestUserControl.cs index c111f6f34..32b55205f 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfTestUserControl.cs +++ b/src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfTestUserControl.cs @@ -13,7 +13,7 @@ namespace ReactiveUI.Tests.Wpf { - public class WpfTestUserControl : UserControl, IActivatable + public class WpfTestUserControl : UserControl, IActivatableView { } } diff --git a/src/ReactiveUI.Tests/Platforms/wpf/WpfCommandBindingImplementationTests.cs b/src/ReactiveUI.Tests/Platforms/wpf/WpfCommandBindingImplementationTests.cs index 24b90cf8a..2ce82e591 100644 --- a/src/ReactiveUI.Tests/Platforms/wpf/WpfCommandBindingImplementationTests.cs +++ b/src/ReactiveUI.Tests/Platforms/wpf/WpfCommandBindingImplementationTests.cs @@ -49,7 +49,7 @@ public void BindCommandShouldNotWarnWhenBindingToFieldDeclaredInXaml() var vm = new CommandBindingViewModel(); var view = new FakeXamlCommandBindingView { ViewModel = vm }; - testLogger.Messages.ShouldNotContain(t => t.Item1.Contains(nameof(POCOObservableForProperty)) && t.Item1.Contains(view.NameOfButtonDeclaredInXaml) && t.Item3 == LogLevel.Warn); + testLogger.Messages.ShouldNotContain(t => t.message.Contains(nameof(POCOObservableForProperty)) && t.message.Contains(view.NameOfButtonDeclaredInXaml) && t.logLevel == LogLevel.Warn); } } } diff --git a/src/ReactiveUI.Tests/ReactiveUI.Tests.csproj b/src/ReactiveUI.Tests/ReactiveUI.Tests.csproj index f4895c2d2..3336f6b4d 100644 --- a/src/ReactiveUI.Tests/ReactiveUI.Tests.csproj +++ b/src/ReactiveUI.Tests/ReactiveUI.Tests.csproj @@ -2,16 +2,12 @@ netcoreapp2.0 - $(TargetFrameworks);net461 + $(TargetFrameworks);net461;netcoreapp3.0 latest - - ReactiveUI.Tests_TemporaryKey.pfx - - - + @@ -24,40 +20,49 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + true + true + + + + + + + + + + + + + + + - - - + + + - - - - + + + + + + + - - - + + + + + + + + + + + + diff --git a/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs b/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs index 34ff7703e..9c1241c53 100644 --- a/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs +++ b/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs @@ -43,7 +43,7 @@ protected static void CheckApproval(Assembly assembly, [CallerMemberName]string approvedPublicApi = File.ReadAllText(approvedFileName); } - var receivedPublicApi = Filter(ApiGenerator.GeneratePublicApi(assembly)); + var receivedPublicApi = Filter(ApiGenerator.GeneratePublicApi(assembly, whitelistedNamespacePrefixes: new[] { "ReactiveUI", "System.Reactive" })); if (!string.Equals(receivedPublicApi, approvedPublicApi, StringComparison.InvariantCulture)) { diff --git a/src/ReactiveUI.Tests/Utilities/CountingTestScheduler.cs b/src/ReactiveUI.Tests/Utilities/CountingTestScheduler.cs index 4f359991d..446ef5a45 100644 --- a/src/ReactiveUI.Tests/Utilities/CountingTestScheduler.cs +++ b/src/ReactiveUI.Tests/Utilities/CountingTestScheduler.cs @@ -17,30 +17,30 @@ public class CountingTestScheduler : IScheduler public CountingTestScheduler(IScheduler innerScheduler) { InnerScheduler = innerScheduler; - ScheduledItems = new List>(); + ScheduledItems = new List<(Action action, TimeSpan? dueTime)>(); } public IScheduler InnerScheduler { get; } - public List> ScheduledItems { get; } + public List<(Action action, TimeSpan? dueTime)> ScheduledItems { get; } public DateTimeOffset Now => InnerScheduler.Now; public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func action) { - ScheduledItems.Add(new Tuple(() => action(this, state), null)); + ScheduledItems.Add((() => action(this, state), null)); return InnerScheduler.Schedule(state, dueTime, action); } public IDisposable Schedule(TState state, TimeSpan dueTime, Func action) { - ScheduledItems.Add(new Tuple(() => action(this, state), dueTime)); + ScheduledItems.Add((() => action(this, state), dueTime)); return InnerScheduler.Schedule(state, dueTime, action); } public IDisposable Schedule(TState state, Func action) { - ScheduledItems.Add(new Tuple(() => action(this, state), null)); + ScheduledItems.Add((() => action(this, state), null)); return InnerScheduler.Schedule(state, action); } } diff --git a/src/ReactiveUI.Tests/Utilities/TestLogger.cs b/src/ReactiveUI.Tests/Utilities/TestLogger.cs index 303c6fbe9..9f39a7366 100644 --- a/src/ReactiveUI.Tests/Utilities/TestLogger.cs +++ b/src/ReactiveUI.Tests/Utilities/TestLogger.cs @@ -17,32 +17,32 @@ public class TestLogger : ILogger { public TestLogger() { - Messages = new List>(); + Messages = new List<(string message, Type type, LogLevel logLevel)>(); Level = LogLevel.Debug; } - public List> Messages { get; } + public List<(string message, Type type, LogLevel logLevel)> Messages { get; } public LogLevel Level { get; set; } public void Write(Exception exception, string message, Type type, LogLevel logLevel) { - Messages.Add(Tuple.Create(message, typeof(TestLogger), logLevel)); + Messages.Add((message, typeof(TestLogger), logLevel)); } public void Write(string message, LogLevel logLevel) { - Messages.Add(Tuple.Create(message, typeof(TestLogger), logLevel)); + Messages.Add((message, typeof(TestLogger), logLevel)); } public void Write(Exception exception, string message, LogLevel logLevel) { - Messages.Add(Tuple.Create(message, typeof(TestLogger), logLevel)); + Messages.Add((message, typeof(TestLogger), logLevel)); } public void Write([Localizable(false)] string message, [Localizable(false)] Type type, LogLevel logLevel) { - Messages.Add(Tuple.Create(message, type, logLevel)); + Messages.Add((message, type, logLevel)); } } } diff --git a/src/ReactiveUI.Tests/WhenAny/ReactiveNotifyPropertyChangedMixinTest.cs b/src/ReactiveUI.Tests/WhenAny/ReactiveNotifyPropertyChangedMixinTest.cs index 2da2874b6..0ecda0d91 100644 --- a/src/ReactiveUI.Tests/WhenAny/ReactiveNotifyPropertyChangedMixinTest.cs +++ b/src/ReactiveUI.Tests/WhenAny/ReactiveNotifyPropertyChangedMixinTest.cs @@ -11,9 +11,11 @@ using System.Reactive.Concurrency; using System.Reactive.Linq; using System.Threading; + +using DynamicData; + using Microsoft.Reactive.Testing; -using ReactiveUI.Legacy; using ReactiveUI.Testing; using Xunit; @@ -99,320 +101,339 @@ public void MultiPropertyExpressionsShouldBeProperlyResolved() [Fact] public void OFPChangingTheHostPropertyShouldFireAChildChangeNotificationOnlyIfThePreviousChildIsDifferent() { - new TestScheduler().With( - sched => - { - var fixture = new HostTestFixture - { - Child = new TestFixture() - }; - var changes = fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.Child.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.Child.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.Child = new TestFixture - { - IsOnlyOneWord = "Bar" - }; - sched.Start(); - Assert.Equal(2, changes.Count); - }); + new TestScheduler().With(sched => + { + var fixture = new HostTestFixture + { + Child = new TestFixture() + }; + fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.Child.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.Child.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.Child = new TestFixture + { + IsOnlyOneWord = "Bar" + }; + sched.Start(); + Assert.Equal(2, changes.Count); + }); } [Fact] public void OFPNamedPropertyTest() { - new TestScheduler().With( - sched => - { - var fixture = new TestFixture(); - var changes = fixture.ObservableForProperty(x => x.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(3, changes.Count); - - fixture.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(3, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Baz" }); - }); + new TestScheduler().With(sched => + { + var fixture = new TestFixture(); + fixture.ObservableForProperty(x => x.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(3, changes.Count); + + fixture.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(3, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Baz" }); + }); } [Fact] public void OFPNamedPropertyTestBeforeChange() { - new TestScheduler().With( - sched => - { - var fixture = new TestFixture - { - IsOnlyOneWord = "Pre" - }; - var changes = fixture.ObservableForProperty(x => x.IsOnlyOneWord, beforeChange: true).CreateCollection(scheduler: ImmediateScheduler.Instance); - - sched.Start(); - Assert.Equal(0, changes.Count); - - fixture.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Pre", "Foo" }); - }); + new TestScheduler().With(sched => + { + var fixture = new TestFixture + { + IsOnlyOneWord = "Pre" + }; + fixture.ObservableForProperty(x => x.IsOnlyOneWord, beforeChange: true) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + sched.Start(); + Assert.Equal(0, changes.Count); + + fixture.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Pre", "Foo" }); + }); } [Fact] public void OFPNamedPropertyTestNoSkipInitial() { - new TestScheduler().With( - sched => - { - var fixture = new TestFixture - { - IsOnlyOneWord = "Pre" - }; - var changes = fixture.ObservableForProperty(x => x.IsOnlyOneWord, skipInitial: false).CreateCollection(scheduler: ImmediateScheduler.Instance); - - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(2, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Pre", "Foo" }); - }); + new TestScheduler().With(sched => + { + var fixture = new TestFixture + { + IsOnlyOneWord = "Pre" + }; + fixture.ObservableForProperty(x => x.IsOnlyOneWord, skipInitial: false) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(2, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Pre", "Foo" }); + }); } [Fact] public void OFPNamedPropertyTestRepeats() { - new TestScheduler().With( - sched => - { - var fixture = new TestFixture(); - var changes = fixture.ObservableForProperty(x => x.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(3, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Foo" }); - }); + new TestScheduler().With(sched => + { + var fixture = new TestFixture(); + fixture.ObservableForProperty(x => x.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(3, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Foo" }); + }); } [Fact] public void OFPReplacingTheHostShouldResubscribeTheObservable() { - new TestScheduler().With( - sched => - { - var fixture = new HostTestFixture - { - Child = new TestFixture() - }; - var changes = fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.Child.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.Child.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - // Tricky! This is a change too, because from the perspective - // of the binding, we've went from "Bar" to null - fixture.Child = new TestFixture(); - sched.Start(); - Assert.Equal(3, changes.Count); - - // Here we've set the value but it shouldn't change - fixture.Child.IsOnlyOneWord = null; - sched.Start(); - Assert.Equal(3, changes.Count); - - fixture.Child.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(4, changes.Count); - - fixture.Child.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(4, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "Child.IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", null, "Baz" }); - }); + new TestScheduler().With(sched => + { + var fixture = new HostTestFixture + { + Child = new TestFixture() + }; + fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.Child.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.Child.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + // Tricky! This is a change too, because from the perspective + // of the binding, we've went from "Bar" to null + fixture.Child = new TestFixture(); + sched.Start(); + Assert.Equal(3, changes.Count); + + // Here we've set the value but it shouldn't change + fixture.Child.IsOnlyOneWord = null; + sched.Start(); + Assert.Equal(3, changes.Count); + + fixture.Child.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(4, changes.Count); + + fixture.Child.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(4, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "Child.IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", null, "Baz" }); + }); } [Fact] public void OFPReplacingTheHostWithNullThenSettingItBackShouldResubscribeTheObservable() { - new TestScheduler().With( - sched => - { - var fixture = new HostTestFixture - { - Child = new TestFixture() - }; - var changes = fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.Child.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.Child.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - // Oops, now the child is Null, we may now blow up - fixture.Child = null; - sched.Start(); - Assert.Equal(2, changes.Count); - - // Tricky! This is a change too, because from the perspective - // of the binding, we've went from "Bar" to null - fixture.Child = new TestFixture(); - sched.Start(); - Assert.Equal(3, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "Child.IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", null }); - }); + new TestScheduler().With(sched => + { + var fixture = new HostTestFixture + { + Child = new TestFixture() + }; + fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.Child.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.Child.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + // Oops, now the child is Null, we may now blow up + fixture.Child = null; + sched.Start(); + Assert.Equal(2, changes.Count); + + // Tricky! This is a change too, because from the perspective + // of the binding, we've went from "Bar" to null + fixture.Child = new TestFixture(); + sched.Start(); + Assert.Equal(3, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "Child.IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", null }); + }); } [Fact] public void OFPShouldWorkWithINPCObjectsToo() { - new TestScheduler().With( - sched => - { - var fixture = new NonReactiveINPCObject - { - InpcProperty = null - }; - - var changes = fixture.ObservableForProperty(x => x.InpcProperty.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.InpcProperty = new TestFixture(); - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.InpcProperty.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.InpcProperty.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(3, changes.Count); - }); + new TestScheduler().With(sched => + { + var fixture = new NonReactiveINPCObject + { + InpcProperty = null + }; + fixture.ObservableForProperty(x => x.InpcProperty.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.InpcProperty = new TestFixture(); + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.InpcProperty.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.InpcProperty.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(3, changes.Count); + }); } [Fact] public void OFPSimpleChildPropertyTest() { - new TestScheduler().With( - sched => - { - var fixture = new HostTestFixture - { - Child = new TestFixture() - }; - var changes = fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.Child.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.Child.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.Child.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(3, changes.Count); - - fixture.Child.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(3, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "Child.IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Baz" }); - }); + new TestScheduler().With(sched => + { + var fixture = new HostTestFixture + { + Child = new TestFixture() + }; + fixture.ObservableForProperty(x => x.Child.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.Child.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.Child.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.Child.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(3, changes.Count); + + fixture.Child.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(3, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "Child.IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Baz" }); + }); } [Fact] public void OFPSimplePropertyTest() { - new TestScheduler().With( - sched => - { - var fixture = new TestFixture(); - var changes = fixture.ObservableForProperty(x => x.IsOnlyOneWord).CreateCollection(scheduler: ImmediateScheduler.Instance); - - fixture.IsOnlyOneWord = "Foo"; - sched.Start(); - Assert.Equal(1, changes.Count); - - fixture.IsOnlyOneWord = "Bar"; - sched.Start(); - Assert.Equal(2, changes.Count); - - fixture.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(3, changes.Count); - - fixture.IsOnlyOneWord = "Baz"; - sched.Start(); - Assert.Equal(3, changes.Count); - - Assert.True(changes.All(x => x.Sender == fixture)); - Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); - changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Baz" }); - }); + new TestScheduler().With(sched => + { + var fixture = new TestFixture(); + fixture.ObservableForProperty(x => x.IsOnlyOneWord) + .ToObservableChangeSet(ImmediateScheduler.Instance) + .Bind(out var changes) + .Subscribe(); + + fixture.IsOnlyOneWord = "Foo"; + sched.Start(); + Assert.Equal(1, changes.Count); + + fixture.IsOnlyOneWord = "Bar"; + sched.Start(); + Assert.Equal(2, changes.Count); + + fixture.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(3, changes.Count); + + fixture.IsOnlyOneWord = "Baz"; + sched.Start(); + Assert.Equal(3, changes.Count); + + Assert.True(changes.All(x => x.Sender == fixture)); + Assert.True(changes.All(x => x.GetPropertyName() == "IsOnlyOneWord")); + changes.Select(x => x.Value).AssertAreEqual(new[] { "Foo", "Bar", "Baz" }); + }); } [Fact] diff --git a/src/ReactiveUI.Uno/ActivationForViewFetcher.cs b/src/ReactiveUI.Uno/ActivationForViewFetcher.cs index 506f2d12d..ae9b8c48b 100644 --- a/src/ReactiveUI.Uno/ActivationForViewFetcher.cs +++ b/src/ReactiveUI.Uno/ActivationForViewFetcher.cs @@ -28,7 +28,7 @@ public int GetAffinityForView(Type view) } /// - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { var fe = view as FrameworkElement; diff --git a/src/ReactiveUI.Uno/PlatformRegistrations.cs b/src/ReactiveUI.Uno/Registrations.cs similarity index 96% rename from src/ReactiveUI.Uno/PlatformRegistrations.cs rename to src/ReactiveUI.Uno/Registrations.cs index 3ce709dcc..2d9afe3b3 100644 --- a/src/ReactiveUI.Uno/PlatformRegistrations.cs +++ b/src/ReactiveUI.Uno/Registrations.cs @@ -13,7 +13,7 @@ namespace ReactiveUI.Uno /// UWP platform registrations. /// /// - public class PlatformRegistrations : IWantsToRegisterStuff + public class Registrations : IWantsToRegisterStuff { /// public void Register(Action, Type> registerFunction) diff --git a/src/ReactiveUI.Uno/WinRTAppDataDriver.cs b/src/ReactiveUI.Uno/WinRTAppDataDriver.cs deleted file mode 100644 index 124096c02..000000000 --- a/src/ReactiveUI.Uno/WinRTAppDataDriver.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reactive; -using System.Reactive.Concurrency; -using System.Reactive.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Serialization; -using Windows.Storage; -using UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding; - -namespace ReactiveUI.Uno -{ - /// - /// Loads and saves state to persistent storage. - /// - public class WinRTAppDataDriver : ISuspensionDriver - { - /// - public IObservable LoadState() - { - return Observable.FromAsync(() => ApplicationData.Current.RoamingFolder.GetFileAsync("appData.xmlish").AsTask()) - .SelectMany(x => FileIO.ReadTextAsync(x, UnicodeEncoding.Utf8).AsTask()) - .SelectMany(x => - { - var line = x.IndexOf("\n", StringComparison.InvariantCulture); - var typeName = x.Substring(0, line - 1); // -1 for CR - var serializer = new DataContractSerializer(Type.GetType(typeName)); - - // NB: WinRT is terrible - var obj = serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(x.Substring(line + 1)))); - return Observable.Return(obj); - }); - } - - /// - public IObservable SaveState(object state) - { - if (state == null) - { - throw new ArgumentNullException(nameof(state)); - } - - try - { - var ms = new MemoryStream(); - var writer = new StreamWriter(ms, Encoding.UTF8); - var serializer = new DataContractSerializer(state.GetType()); - writer.WriteLine(state.GetType().AssemblyQualifiedName); - writer.Flush(); - - serializer.WriteObject(ms, state); - - return Observable.FromAsync(() => ApplicationData.Current.RoamingFolder.CreateFileAsync("appData.xmlish", CreationCollisionOption.ReplaceExisting).AsTask()) - .SelectMany(x => Observable.FromAsync(() => FileIO.WriteBytesAsync(x, ms.ToArray()).AsTask())); - } - catch (Exception ex) - { - return Observable.Throw(ex); - } - } - - /// - public IObservable InvalidateState() - { - return Observable.FromAsync(() => ApplicationData.Current.RoamingFolder.GetFileAsync("appData.xmlish").AsTask()) - .SelectMany(x => Observable.FromAsync(() => x.DeleteAsync().AsTask())); - } - } -} diff --git a/src/ReactiveUI.Winforms/ActivationForViewFetcher.cs b/src/ReactiveUI.Winforms/ActivationForViewFetcher.cs index 68163e8c5..97f6acd4f 100644 --- a/src/ReactiveUI.Winforms/ActivationForViewFetcher.cs +++ b/src/ReactiveUI.Winforms/ActivationForViewFetcher.cs @@ -29,7 +29,7 @@ public int GetAffinityForView(Type view) } /// - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { // Startup: Control.HandleCreated > Control.BindingContextChanged > Form.Load > Control.VisibleChanged > Form.Activated > Form.Shown // Shutdown: Form.Closing > Form.FormClosing > Form.Closed > Form.FormClosed > Form.Deactivate @@ -41,16 +41,46 @@ public IObservable GetActivationForView(IActivatable view) return Observable.Empty; } - var handleDestroyed = Observable.FromEventPattern(control, "HandleDestroyed").Select(_ => false); - var handleCreated = Observable.FromEventPattern(control, "HandleCreated").Select(_ => true); - var visibleChanged = Observable.FromEventPattern(control, "VisibleChanged").Select(_ => control.Visible); + var handleDestroyed = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(false); + return Handler; + }, + h => control.HandleDestroyed += h, + h => control.HandleDestroyed -= h); + + var handleCreated = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(true); + return Handler; + }, + h => control.HandleCreated += h, + h => control.HandleCreated -= h); + + var visibleChanged = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(control.Visible); + return Handler; + }, + h => control.VisibleChanged += h, + h => control.VisibleChanged -= h); var controlActivation = Observable.Merge(handleDestroyed, handleCreated, visibleChanged) .DistinctUntilChanged(); if (view is Form form) { - var formClosed = Observable.FromEventPattern(form, "FormClosed").Select(_ => false); + var formClosed = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, FormClosedEventArgs e) => eventHandler(control.Visible); + return Handler; + }, + h => form.FormClosed += h, + h => form.FormClosed -= h); controlActivation = controlActivation.Merge(formClosed) .DistinctUntilChanged(); } diff --git a/src/ReactiveUI.Winforms/CreatesWinformsCommandBinding.cs b/src/ReactiveUI.Winforms/CreatesWinformsCommandBinding.cs index 92f5b05d7..47b579961 100644 --- a/src/ReactiveUI.Winforms/CreatesWinformsCommandBinding.cs +++ b/src/ReactiveUI.Winforms/CreatesWinformsCommandBinding.cs @@ -23,10 +23,10 @@ namespace ReactiveUI.Winforms public class CreatesWinformsCommandBinding : ICreatesCommandBinding { // NB: These are in priority order - private static readonly List> defaultEventsToBind = new List> + private static readonly List<(string name, Type type)> defaultEventsToBind = new List<(string name, Type type)> { - Tuple.Create("Click", typeof(EventArgs)), - Tuple.Create("MouseUp", typeof(System.Windows.Forms.MouseEventArgs)), + ("Click", typeof(EventArgs)), + ("MouseUp", typeof(System.Windows.Forms.MouseEventArgs)), }; /// @@ -46,7 +46,7 @@ public int GetAffinityForObject(Type type, bool hasEventTarget) return defaultEventsToBind.Any(x => { - var ei = type.GetEvent(x.Item1, BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance); + var ei = type.GetEvent(x.name, BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance); return ei != null; }) ? 4 : 0; } @@ -63,7 +63,7 @@ public IDisposable BindCommandToObject(ICommand command, object target, IObserva var type = target.GetType(); var eventInfo = defaultEventsToBind - .Select(x => new { EventInfo = type.GetEvent(x.Item1, bf), Args = x.Item2 }) + .Select(x => new { EventInfo = type.GetEvent(x.name, bf), Args = x.type }) .FirstOrDefault(x => x.EventInfo != null); if (eventInfo == null) @@ -119,8 +119,14 @@ public IDisposable BindCommandToObject(ICommand command, object targ object latestParam = null; ret.Add(commandParameter.Subscribe(x => latestParam = x)); - ret.Add(Observable.FromEventPattern(x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x) - .Select(_ => command.CanExecute(latestParam)) + ret.Add(Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(command.CanExecute(latestParam)); + return Handler; + }, + x => command.CanExecuteChanged += x, + x => command.CanExecuteChanged -= x) .StartWith(command.CanExecute(latestParam)) .Subscribe(x => { diff --git a/src/ReactiveUI.Winforms/EventShims/PropertyChangingEventManager.cs b/src/ReactiveUI.Winforms/EventShims/PropertyChangingEventManager.cs index 8b98dcaa7..1af85004b 100644 --- a/src/ReactiveUI.Winforms/EventShims/PropertyChangingEventManager.cs +++ b/src/ReactiveUI.Winforms/EventShims/PropertyChangingEventManager.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; diff --git a/src/ReactiveUI.Winforms/IReactiveDerivedBindingList.cs b/src/ReactiveUI.Winforms/IReactiveDerivedBindingList.cs deleted file mode 100644 index fb0105255..000000000 --- a/src/ReactiveUI.Winforms/IReactiveDerivedBindingList.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ReactiveUI.Legacy; - -namespace ReactiveUI.Winforms.Legacy -{ - /// - /// IReactiveDerivedList represents a bindinglist whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection is updated. - /// - /// The type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - [SuppressMessage("Design", "CA1010: IList inheritors should inherit the generic form", Justification = "Legacy code.")] - public interface IReactiveDerivedBindingList : IReactiveDerivedList, IBindingList - { - } -} diff --git a/src/ReactiveUI.Winforms/ObservableCollectionMixin.cs b/src/ReactiveUI.Winforms/ObservableCollectionMixin.cs deleted file mode 100644 index eedaff209..000000000 --- a/src/ReactiveUI.Winforms/ObservableCollectionMixin.cs +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.Linq; -using System.Reactive; -using System.Reactive.Linq; - -namespace ReactiveUI.Winforms.Legacy -{ - /// - /// A set of extension methods associated with the IReactiveDerivedBindingList{TNew}. - /// - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public static class ObservableCollectionMixin - { - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Note that even though this method attaches itself to any - /// IEnumerable, it will only detect changes from objects implementing - /// INotifyCollectionChanged (like ReactiveList). If your source - /// collection doesn't implement this, signalReset is the way to signal - /// the derived collection to reorder/refilter itself. - /// - /// The type. - /// The new type. - /// The signal type. - /// The collection we are creating a derived list from. - /// A Select function that will be run on each - /// item. - /// An action that is called on each item when - /// it is removed. - /// A filter to determine whether to exclude items - /// in the derived collection. - /// A comparator method to determine the ordering of - /// the resulting collection. - /// When this Observable is signalled, - /// the derived collection will be manually - /// reordered/refiltered. - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - public static IReactiveDerivedBindingList CreateDerivedBindingList( - this IEnumerable collection, - Func selector, - Action removed, - Func filter = null, - Func orderer = null, - IObservable signalReset = null) - { - Contract.Requires(selector != null); - - IObservable reset = null; - - if (signalReset != null) - { - reset = signalReset.Select(_ => Unit.Default); - } - - return new ReactiveDerivedBindingList(collection, selector, filter, orderer, removed, reset); - } - - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Note that even though this method attaches itself to any - /// IEnumerable, it will only detect changes from objects implementing - /// INotifyCollectionChanged (like ReactiveList). If your source - /// collection doesn't implement this, signalReset is the way to signal - /// the derived collection to reorder/refilter itself. - /// - /// The type. - /// The new type. - /// The signal type. - /// The collection we are creating a derived list from. - /// A Select function that will be run on each - /// item. - /// A filter to determine whether to exclude items - /// in the derived collection. - /// A comparator method to determine the ordering of - /// the resulting collection. - /// When this Observable is signalled, - /// the derived collection will be manually - /// reordered/refiltered. - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - public static IReactiveDerivedBindingList CreateDerivedBindingList( - this IEnumerable collection, - Func selector, - Func filter = null, - Func orderer = null, - IObservable signalReset = null) - { - return collection.CreateDerivedBindingList(selector, null, filter, orderer, signalReset); - } - - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Be aware that this overload will result in a collection that *only* - /// updates if the source implements INotifyCollectionChanged. If your - /// list changes but isn't a ReactiveList/ObservableCollection, - /// you probably want to use the other overload. - /// - /// The type. - /// The new type. - /// The collection we are creating a derived list from. - /// A Select function that will be run on each - /// item. - /// An action that is called on each item when - /// it is removed. - /// A filter to determine whether to exclude items - /// in the derived collection. - /// A comparator method to determine the ordering of - /// the resulting collection. - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - public static IReactiveDerivedBindingList CreateDerivedBindingList( - this IEnumerable collection, - Func selector, - Action removed, - Func filter = null, - Func orderer = null) - { - return collection.CreateDerivedBindingList(selector, removed, filter, orderer, (IObservable)null); - } - - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Be aware that this overload will result in a collection that *only* - /// updates if the source implements INotifyCollectionChanged. If your - /// list changes but isn't a ReactiveList/ObservableCollection, - /// you probably want to use the other overload. - /// - /// The type. - /// The new type. - /// The collection we are creating a derived list from. - /// A Select function that will be run on each - /// item. - /// A filter to determine whether to exclude items - /// in the derived collection. - /// A comparator method to determine the ordering of - /// the resulting collection. - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - public static IReactiveDerivedBindingList CreateDerivedBindingList( - this IEnumerable collection, - Func selector, - Func filter = null, - Func orderer = null) - { - return collection.CreateDerivedBindingList(selector, null, filter, orderer, (IObservable)null); - } - } -} diff --git a/src/ReactiveUI.Winforms/ReactiveBindingList.cs b/src/ReactiveUI.Winforms/ReactiveBindingList.cs deleted file mode 100644 index ce97f9d7c..000000000 --- a/src/ReactiveUI.Winforms/ReactiveBindingList.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using ReactiveUI.Legacy; - -namespace ReactiveUI.Winforms.Legacy -{ - /// - /// A version of the ReactiveList that works with the Winforms IBindingList. - /// - /// The type of item in the list. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public class ReactiveBindingList : ReactiveList, IBindingList, ICancelAddNew, IRaiseItemChangedEvents - { - /// - /// Initializes a new instance of the class. - /// - public ReactiveBindingList() - : this(null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The items. - public ReactiveBindingList(IEnumerable items) - : base(items) - { - } - - /// - public event ListChangedEventHandler ListChanged; - - /// - public bool RaisesItemChangedEvents => ChangeTrackingEnabled; - - /// - public bool AllowNew => true; - - /// - public bool AllowEdit => true; - - /// - public bool AllowRemove => true; - - /// - public bool SupportsChangeNotification => true; - - /// - public bool SupportsSearching => false; - - /// - public bool SupportsSorting => false; - - /// - public bool IsSorted => false; - - /// - public PropertyDescriptor SortProperty => null; - - /// - public ListSortDirection SortDirection => ListSortDirection.Ascending; - - /// - public void CancelNew(int itemIndex) - { - // throw new NotImplementedException(); - } - - /// - public void EndNew(int itemIndex) - { - // throw new NotImplementedException(); - } - - /// - public object AddNew() - { - return Activator.CreateInstance(); - } - - /// - public void AddIndex(PropertyDescriptor property) - { - throw new NotSupportedException(); - } - - /// - public void ApplySort(PropertyDescriptor property, ListSortDirection direction) - { - throw new NotSupportedException(); - } - - /// - public int Find(PropertyDescriptor property, object key) - { - throw new NotSupportedException(); - } - - /// - public void RemoveIndex(PropertyDescriptor property) - { - throw new NotSupportedException(); - } - - /// - public void RemoveSort() - { - throw new NotSupportedException(); - } - - /// - protected override void RaiseCollectionChanged(NotifyCollectionChangedEventArgs e) - { - base.RaiseCollectionChanged(e); - if (ListChanged != null) - { - e.AsListChangedEventArgs().ForEach(x => ListChanged(this, x)); - } - } - } -} diff --git a/src/ReactiveUI.Winforms/ReactiveDerivedBindingList.cs b/src/ReactiveUI.Winforms/ReactiveDerivedBindingList.cs deleted file mode 100644 index 2fc3b3f64..000000000 --- a/src/ReactiveUI.Winforms/ReactiveDerivedBindingList.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.ComponentModel; -using System.Diagnostics.Contracts; -using System.Reactive; -using System.Reactive.Concurrency; -using System.Reactive.Linq; - -using ReactiveUI.Legacy; - -namespace ReactiveUI.Winforms.Legacy -{ - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - internal class ReactiveDerivedBindingList : ReactiveDerivedCollection, IReactiveDerivedBindingList - { - private const string ReadonlyExceptionMessage = "Derived collections cannot be modified."; - - public ReactiveDerivedBindingList( - IEnumerable source, - Func selector, - Func filter, - Func orderer, - Action removed, - IObservable signalReset) - : base(source, selector, filter, orderer, removed, signalReset, Scheduler.Immediate) - { - } - - public event ListChangedEventHandler ListChanged; - - public bool AllowNew => false; - - public bool AllowEdit => false; - - public bool AllowRemove => false; - - public bool SupportsChangeNotification => true; - - public bool SupportsSearching => false; - - public bool SupportsSorting => false; - - public bool IsSorted => false; - - public PropertyDescriptor SortProperty => null; - - public ListSortDirection SortDirection => ListSortDirection.Ascending; - - public object AddNew() - { - throw new NotSupportedException(ReadonlyExceptionMessage); - } - - public void AddIndex(PropertyDescriptor property) - { - throw new NotSupportedException(); - } - - public void ApplySort(PropertyDescriptor property, ListSortDirection direction) - { - throw new NotSupportedException(); - } - - public int Find(PropertyDescriptor property, object key) - { - throw new NotSupportedException(); - } - - public void RemoveIndex(PropertyDescriptor property) - { - throw new NotSupportedException(); - } - - public void RemoveSort() - { - throw new NotSupportedException(); - } - - protected override void RaiseCollectionChanged(NotifyCollectionChangedEventArgs e) - { - base.RaiseCollectionChanged(e); - if (ListChanged != null) - { - e.AsListChangedEventArgs().ForEach(x => ListChanged(this, x)); - } - } - } -} diff --git a/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj b/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj index 87e15cf98..a779c52a5 100644 --- a/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj +++ b/src/ReactiveUI.Winforms/ReactiveUI.Winforms.csproj @@ -1,7 +1,7 @@  - net461 + netcoreapp3.0;net461 ReactiveUI.Winforms ReactiveUI.Winforms Windows Forms specific extensions to ReactiveUI @@ -15,7 +15,19 @@ - + + + + + + + + + + + + + diff --git a/src/ReactiveUI.Winforms/Registrations.cs b/src/ReactiveUI.Winforms/Registrations.cs index 384dc1525..b2ebfdf52 100644 --- a/src/ReactiveUI.Winforms/Registrations.cs +++ b/src/ReactiveUI.Winforms/Registrations.cs @@ -6,6 +6,8 @@ using System; using System.Reactive.Concurrency; using System.Windows.Forms; + +using ReactiveUI; using Splat; namespace ReactiveUI.Winforms @@ -31,6 +33,7 @@ public void Register(Action, Type> registerFunction) registerFunction(() => new ActivationForViewFetcher(), typeof(IActivationForViewFetcher)); registerFunction(() => new PanelSetMethodBindingConverter(), typeof(ISetMethodBindingConverter)); registerFunction(() => new TableContentSetMethodBindingConverter(), typeof(ISetMethodBindingConverter)); + registerFunction(() => new ComponentModelTypeConverter(), typeof(IBindingTypeConverter)); if (!ModeDetector.InUnitTestRunner()) { diff --git a/src/ReactiveUI.Winforms/WinformsCreatesObservableForProperty.cs b/src/ReactiveUI.Winforms/WinformsCreatesObservableForProperty.cs index 8eb208f42..8950a436c 100644 --- a/src/ReactiveUI.Winforms/WinformsCreatesObservableForProperty.cs +++ b/src/ReactiveUI.Winforms/WinformsCreatesObservableForProperty.cs @@ -22,11 +22,11 @@ namespace ReactiveUI.Winforms /// public class WinformsCreatesObservableForProperty : ICreatesObservableForProperty { - private static readonly MemoizingMRUCache, EventInfo> eventInfoCache = new MemoizingMRUCache, EventInfo>( + private static readonly MemoizingMRUCache<(Type type, string name), EventInfo> eventInfoCache = new MemoizingMRUCache<(Type type, string name), EventInfo>( (pair, _) => { - return pair.Item1.GetEvents(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public) - .FirstOrDefault(x => x.Name == pair.Item2 + "Changed"); + return pair.type.GetEvents(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public) + .FirstOrDefault(x => x.Name == pair.name + "Changed"); }, RxApp.SmallCacheLimit); /// @@ -38,7 +38,7 @@ public int GetAffinityForObject(Type type, string propertyName, bool beforeChang return 0; } - var ei = eventInfoCache.Get(Tuple.Create(type, propertyName)); + var ei = eventInfoCache.Get((type, propertyName)); return beforeChanged == false && ei != null ? 8 : 0; } @@ -50,7 +50,7 @@ public IObservable> GetNotificationForProperty(o throw new ArgumentNullException(nameof(sender)); } - var ei = eventInfoCache.Get(Tuple.Create(sender.GetType(), propertyName)); + var ei = eventInfoCache.Get((sender.GetType(), propertyName)); return Observable.Create>(subj => { diff --git a/src/ReactiveUI.Wpf/ActivationForViewFetcher.cs b/src/ReactiveUI.Wpf/ActivationForViewFetcher.cs index f7d309586..ddd9c048f 100644 --- a/src/ReactiveUI.Wpf/ActivationForViewFetcher.cs +++ b/src/ReactiveUI.Wpf/ActivationForViewFetcher.cs @@ -25,7 +25,7 @@ public int GetAffinityForView(Type view) } /// - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { var fe = view as FrameworkElement; @@ -34,20 +34,32 @@ public IObservable GetActivationForView(IActivatable view) return Observable.Empty; } - var viewLoaded = Observable.FromEventPattern( + var viewLoaded = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, RoutedEventArgs e) => eventHandler(true); + return Handler; + }, x => fe.Loaded += x, - x => fe.Loaded -= x) - .Select(_ => true); + x => fe.Loaded -= x); - var hitTestVisible = Observable.FromEventPattern( + var hitTestVisible = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, DependencyPropertyChangedEventArgs e) => eventHandler((bool)e.NewValue); + return Handler; + }, x => fe.IsHitTestVisibleChanged += x, - x => fe.IsHitTestVisibleChanged -= x) - .Select(x => (bool)x.EventArgs.NewValue); + x => fe.IsHitTestVisibleChanged -= x); - var viewUnloaded = Observable.FromEventPattern( + var viewUnloaded = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, RoutedEventArgs e) => eventHandler(false); + return Handler; + }, x => fe.Unloaded += x, - x => fe.Unloaded -= x) - .Select(_ => false); + x => fe.Unloaded -= x); return viewLoaded .Merge(viewUnloaded) diff --git a/src/ReactiveUI.Wpf/AutoSuspendHelper.cs b/src/ReactiveUI.Wpf/AutoSuspendHelper.cs index 094bb4e7c..86ed1a6ed 100644 --- a/src/ReactiveUI.Wpf/AutoSuspendHelper.cs +++ b/src/ReactiveUI.Wpf/AutoSuspendHelper.cs @@ -34,27 +34,49 @@ public AutoSuspendHelper(Application app) IdleTimeout = TimeSpan.FromSeconds(15.0); RxApp.SuspensionHost.IsLaunchingNew = - Observable.FromEventPattern( - x => app.Startup += x, x => app.Startup -= x) - .Select(_ => Unit.Default); + Observable.FromEvent( + eventHandler => + { + void Handler(object sender, StartupEventArgs e) => eventHandler(Unit.Default); + return Handler; + }, + x => app.Startup += x, + x => app.Startup -= x); RxApp.SuspensionHost.IsUnpausing = - Observable.FromEventPattern( - x => app.Activated += x, x => app.Activated -= x) - .Select(_ => Unit.Default); + Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(Unit.Default); + return Handler; + }, + x => app.Activated += x, + x => app.Activated -= x); RxApp.SuspensionHost.IsResuming = Observable.Never; // NB: No way to tell OS that we need time to suspend, we have to // do it in-process - var deactivated = Observable.FromEventPattern( - x => app.Deactivated += x, x => app.Deactivated -= x); + var deactivated = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(Unit.Default); + return Handler; + }, + x => app.Deactivated += x, + x => app.Deactivated -= x); - var exit = Observable.FromEventPattern( - x => app.Exit += x, x => app.Exit -= x); + var exit = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, ExitEventArgs e) => eventHandler(Disposable.Empty); + return Handler; + }, + x => app.Exit += x, + x => app.Exit -= x); RxApp.SuspensionHost.ShouldPersistState = Observable.Merge( - exit.Select(_ => Disposable.Empty), + exit, deactivated .SelectMany(_ => Observable.Timer(IdleTimeout, RxApp.TaskpoolScheduler)) .TakeUntil(RxApp.SuspensionHost.IsUnpausing) diff --git a/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj b/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj index 60052fcc4..e8e2eebce 100644 --- a/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj +++ b/src/ReactiveUI.Wpf/ReactiveUI.Wpf.csproj @@ -1,6 +1,6 @@  - net461 + netcoreapp3.0;net461 WPF specific extensions to ReactiveUI ReactiveUI.WPF true @@ -13,6 +13,18 @@ + + + + + + + + + + + + diff --git a/src/ReactiveUI.Wpf/Registrations.cs b/src/ReactiveUI.Wpf/Registrations.cs index 3e9690c4b..013ca47f7 100644 --- a/src/ReactiveUI.Wpf/Registrations.cs +++ b/src/ReactiveUI.Wpf/Registrations.cs @@ -6,6 +6,8 @@ using System; using System.Reactive.Concurrency; +using ReactiveUI; + namespace ReactiveUI.Wpf { /// @@ -27,6 +29,7 @@ public void Register(Action, Type> registerFunction) registerFunction(() => new DependencyObjectObservableForProperty(), typeof(ICreatesObservableForProperty)); registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter)); registerFunction(() => new AutoDataTemplateBindingHook(), typeof(IPropertyBindingHook)); + registerFunction(() => new ComponentModelTypeConverter(), typeof(IBindingTypeConverter)); RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; diff --git a/src/ReactiveUI.XamForms/ActivationForViewFetcher.cs b/src/ReactiveUI.XamForms/ActivationForViewFetcher.cs index 9270811a9..06bb38be2 100644 --- a/src/ReactiveUI.XamForms/ActivationForViewFetcher.cs +++ b/src/ReactiveUI.XamForms/ActivationForViewFetcher.cs @@ -28,7 +28,7 @@ public int GetAffinityForView(Type view) } /// - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { var activation = GetActivationFor(view as ICanActivate) ?? @@ -59,9 +59,25 @@ private static IObservable GetActivationFor(Page page) return null; } - return Observable.Merge( - Observable.FromEventPattern(x => page.Appearing += x, x => page.Appearing -= x).Select(_ => true), - Observable.FromEventPattern(x => page.Disappearing += x, x => page.Disappearing -= x).Select(_ => false)); + var appearing = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(true); + return Handler; + }, + x => page.Appearing += x, + x => page.Appearing -= x); + + var disappearing = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(false); + return Handler; + }, + x => page.Disappearing += x, + x => page.Disappearing -= x); + + return Observable.Merge(appearing, disappearing); } private static IObservable GetActivationFor(View view) @@ -71,11 +87,17 @@ private static IObservable GetActivationFor(View view) return null; } - var propertyChanged = Observable.FromEventPattern( + var propertyChanged = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, PropertyChangedEventArgs e) => eventHandler(e.PropertyName); + return Handler; + }, x => view.PropertyChanged += x, x => view.PropertyChanged -= x); + return propertyChanged - .Where(x => x.EventArgs.PropertyName == "IsVisible") + .Where(x => x == "IsVisible") .Select(_ => view.IsVisible) .StartWith(view.IsVisible); } @@ -87,9 +109,25 @@ private static IObservable GetActivationFor(Cell cell) return null; } - return Observable.Merge( - Observable.FromEventPattern(x => cell.Appearing += x, x => cell.Appearing -= x).Select(_ => true), - Observable.FromEventPattern(x => cell.Disappearing += x, x => cell.Disappearing -= x).Select(_ => false)); + var appearing = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(true); + return Handler; + }, + x => cell.Appearing += x, + x => cell.Appearing -= x); + + var disappearing = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(false); + return Handler; + }, + x => cell.Disappearing += x, + x => cell.Disappearing -= x); + + return Observable.Merge(appearing, disappearing); } } } diff --git a/src/ReactiveUI.XamForms/RoutedViewHost.cs b/src/ReactiveUI.XamForms/RoutedViewHost.cs index a562a53c6..b824a7391 100644 --- a/src/ReactiveUI.XamForms/RoutedViewHost.cs +++ b/src/ReactiveUI.XamForms/RoutedViewHost.cs @@ -19,8 +19,8 @@ namespace ReactiveUI.XamForms /// This is a that serves as a router. /// /// - /// - public class RoutedViewHost : NavigationPage, IActivatable + /// + public class RoutedViewHost : NavigationPage, IActivatableView { /// /// The router bindable property. @@ -121,7 +121,14 @@ public RoutedViewHost() }) .Subscribe()); - var poppingEvent = Observable.FromEventPattern(x => Popped += x, x => Popped -= x); + var poppingEvent = Observable.FromEvent, Unit>( + eventHandler => + { + void Handler(object sender, NavigationEventArgs e) => eventHandler(Unit.Default); + return Handler; + }, + x => Popped += x, + x => Popped -= x); // NB: Catch when the user hit back as opposed to the application // requesting Back via NavigateBack diff --git a/src/ReactiveUI.sln b/src/ReactiveUI.sln index 9fcb73110..f925b2c2a 100644 --- a/src/ReactiveUI.sln +++ b/src/ReactiveUI.sln @@ -41,7 +41,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Splat.Tests", "R EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Testing.Tests", "ReactiveUI.Testing.Tests\ReactiveUI.Testing.Tests.csproj", "{CD8B19A9-316E-4FBC-8F0C-87ADC6AAD684}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactiveUI.Uno", "ReactiveUI.Uno\ReactiveUI.Uno.csproj", "{36FC3269-B7D0-4D79-A54A-B26B6190E8A2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Uno", "ReactiveUI.Uno\ReactiveUI.Uno.csproj", "{36FC3269-B7D0-4D79-A54A-B26B6190E8A2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Blazor", "ReactiveUI.Blazor\ReactiveUI.Blazor.csproj", "{0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -875,6 +877,65 @@ Global {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|x64.Build.0 = Release|Any CPU {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|x86.ActiveCfg = Release|Any CPU {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|x86.Build.0 = Release|Any CPU +<<<<<<< HEAD + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|Mixed Platforms.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|Mixed Platforms.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|ARM.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|iPhone.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|Mixed Platforms.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|Mixed Platforms.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|x64.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|x64.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|x86.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.AppStore|x86.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|ARM.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|ARM.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|iPhone.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|x64.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Debug|x86.Build.0 = Debug|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|Any CPU.Build.0 = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|ARM.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|ARM.Build.0 = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|iPhone.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|iPhone.Build.0 = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|x64.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|x64.Build.0 = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|x86.ActiveCfg = Release|Any CPU + {0C7EDFF0-80BE-4FFC-A1B9-0C48043B71F3}.Release|x86.Build.0 = Release|Any CPU +======= +>>>>>>> master EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ReactiveUI/Activation/CanActivateViewFetcher.cs b/src/ReactiveUI/Activation/CanActivateViewFetcher.cs index 637c95e6c..963a8afaa 100644 --- a/src/ReactiveUI/Activation/CanActivateViewFetcher.cs +++ b/src/ReactiveUI/Activation/CanActivateViewFetcher.cs @@ -22,7 +22,7 @@ public class CanActivateViewFetcher : IActivationForViewFetcher /// /// The source type to check. /// - /// A positive integer if is supported, + /// A positive integer if is supported, /// zero otherwise. /// public int GetAffinityForView(Type view) => typeof(ICanActivate).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ? @@ -33,7 +33,7 @@ public int GetAffinityForView(Type view) => typeof(ICanActivate).GetTypeInfo().I /// /// The view to observe. /// An observable tracking whether the view is active. - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { var canActivate = view as ICanActivate; diff --git a/src/ReactiveUI/Activation/IActivationForViewFetcher.cs b/src/ReactiveUI/Activation/IActivationForViewFetcher.cs index e4f403a06..fff95fa39 100644 --- a/src/ReactiveUI/Activation/IActivationForViewFetcher.cs +++ b/src/ReactiveUI/Activation/IActivationForViewFetcher.cs @@ -32,6 +32,6 @@ public interface IActivationForViewFetcher /// /// The view to get the activation observable for. /// A Observable which will returns if Activation was successful. - IObservable GetActivationForView(IActivatable view); + IObservable GetActivationForView(IActivatableView view); } } diff --git a/src/ReactiveUI/Activation/ViewForMixins.cs b/src/ReactiveUI/Activation/ViewForMixins.cs index aae9e19d2..88a0fe7ed 100644 --- a/src/ReactiveUI/Activation/ViewForMixins.cs +++ b/src/ReactiveUI/Activation/ViewForMixins.cs @@ -44,7 +44,7 @@ static ViewForMixins() /// View is activated. It returns a list of Disposables that will be /// cleaned up when the View is deactivated. /// - public static void WhenActivated(this ISupportsActivation item, Func> block) + public static void WhenActivated(this IActivatableViewModel item, Func> block) { if (item == null) { @@ -65,7 +65,7 @@ public static void WhenActivated(this ISupportsActivation item, Func - public static void WhenActivated(this ISupportsActivation item, Action> block) + public static void WhenActivated(this IActivatableViewModel item, Action> block) { if (item == null) { @@ -90,7 +90,7 @@ public static void WhenActivated(this ISupportsActivation item, Action - public static void WhenActivated(this ISupportsActivation item, Action block) + public static void WhenActivated(this IActivatableViewModel item, Action block) { if (item == null) { @@ -116,7 +116,7 @@ public static void WhenActivated(this ISupportsActivation item, Action /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatable item, Func> block) + public static IDisposable WhenActivated(this IActivatableView item, Func> block) { if (item == null) { @@ -137,12 +137,12 @@ public static IDisposable WhenActivated(this IActivatable item, Func /// - /// The IActivatable will ordinarily also host the View + /// The IActivatableView will ordinarily also host the View /// Model, but in the event it is not, a class implementing /// can be supplied here. /// /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatable item, Func> block, IViewFor view) + public static IDisposable WhenActivated(this IActivatableView item, Func> block, IViewFor view) { if (item == null) { @@ -180,7 +180,7 @@ public static IDisposable WhenActivated(this IActivatable item, Func /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatable item, Action> block) + public static IDisposable WhenActivated(this IActivatableView item, Action> block) { return item.WhenActivated(block, null); } @@ -197,12 +197,12 @@ public static IDisposable WhenActivated(this IActivatable item, Action /// - /// The IActivatable will ordinarily also host the View + /// The IActivatableView will ordinarily also host the View /// Model, but in the event it is not, a class implementing /// can be supplied here. /// /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatable item, Action> block, IViewFor view) + public static IDisposable WhenActivated(this IActivatableView item, Action> block, IViewFor view) { return item.WhenActivated( () => @@ -224,12 +224,12 @@ public static IDisposable WhenActivated(this IActivatable item, Action /// - /// The IActivatable will ordinarily also host the View + /// The IActivatableView will ordinarily also host the View /// Model, but in the event it is not, a class implementing /// can be supplied here. /// /// A Disposable that deactivates this registration. - public static IDisposable WhenActivated(this IActivatable item, Action block, IViewFor view = null) + public static IDisposable WhenActivated(this IActivatableView item, Action block, IViewFor view = null) { return item.WhenActivated( () => @@ -269,7 +269,7 @@ private static IDisposable HandleViewModelActivation(IViewFor view, IObservable< if (activated) { viewVmDisposable.Disposable = view.WhenAnyValue(x => x.ViewModel) - .Select(x => x as ISupportsActivation) + .Select(x => x as IActivatableViewModel) .Subscribe(x => { // NB: We need to make sure to respect ordering so that the cleanup diff --git a/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs b/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs index 9cef6d9b3..a28ef6798 100644 --- a/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs +++ b/src/ReactiveUI/Bindings/Command/CreatesCommandBinding.cs @@ -21,11 +21,11 @@ internal class CreatesCommandBinding (t, _) => { return Locator.Current.GetServices() - .Aggregate(Tuple.Create(0, (ICreatesCommandBinding)null), (acc, x) => + .Aggregate((score: 0, binding: (ICreatesCommandBinding)null), (acc, x) => { int score = x.GetAffinityForObject(t, false); - return (score > acc.Item1) ? Tuple.Create(score, x) : acc; - }).Item2; + return (score > acc.score) ? (score, x) : acc; + }).binding; }, RxApp.SmallCacheLimit); private static readonly MemoizingMRUCache bindCommandEventCache = @@ -33,11 +33,11 @@ internal class CreatesCommandBinding (t, _) => { return Locator.Current.GetServices() - .Aggregate(Tuple.Create(0, (ICreatesCommandBinding)null), (acc, x) => + .Aggregate((score: 0, binding: (ICreatesCommandBinding)null), (acc, x) => { int score = x.GetAffinityForObject(t, true); - return (score > acc.Item1) ? Tuple.Create(score, x) : acc; - }).Item2; + return (score > acc.score) ? (score, x) : acc; + }).binding; }, RxApp.SmallCacheLimit); public static IDisposable BindCommandToObject(ICommand command, object target, IObservable commandParameter) diff --git a/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs b/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs index 09a3cd706..1a2d5eb75 100644 --- a/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs +++ b/src/ReactiveUI/Bindings/Command/CreatesCommandBindingViaEvent.cs @@ -22,14 +22,14 @@ namespace ReactiveUI public class CreatesCommandBindingViaEvent : ICreatesCommandBinding { // NB: These are in priority order - private static readonly List> defaultEventsToBind = new List> + private static readonly List<(string name, Type type)> defaultEventsToBind = new List<(string name, Type type)> { - Tuple.Create("Click", typeof(EventArgs)), - Tuple.Create("TouchUpInside", typeof(EventArgs)), - Tuple.Create("MouseUp", typeof(EventArgs)), + ("Click", typeof(EventArgs)), + ("TouchUpInside", typeof(EventArgs)), + ("MouseUp", typeof(EventArgs)), #if NETFX_CORE - Tuple.Create("PointerReleased", typeof(PointerRoutedEventArgs)), - Tuple.Create("Tapped", typeof(TappedRoutedEventArgs)), + ("PointerReleased", typeof(PointerRoutedEventArgs)), + ("Tapped", typeof(TappedRoutedEventArgs)), #endif }; @@ -43,7 +43,7 @@ public int GetAffinityForObject(Type type, bool hasEventTarget) return defaultEventsToBind.Any(x => { - var ei = type.GetRuntimeEvent(x.Item1); + var ei = type.GetRuntimeEvent(x.name); return ei != null; }) ? 3 : 0; } @@ -58,7 +58,7 @@ public IDisposable BindCommandToObject(ICommand command, object target, IObserva var type = target.GetType(); var eventInfo = defaultEventsToBind - .Select(x => new { EventInfo = type.GetRuntimeEvent(x.Item1), Args = x.Item2 }) + .Select(x => new { EventInfo = type.GetRuntimeEvent(x.name), Args = x.type }) .FirstOrDefault(x => x.EventInfo != null); if (eventInfo == null) diff --git a/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs index 365c93527..235954b0d 100644 --- a/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/IPropertyBinderImplementation.cs @@ -64,7 +64,7 @@ public interface IPropertyBinderImplementation : IEnableLogger /// An instance of that, when disposed, /// disconnects the binding. /// - IReactiveBinding> Bind( + IReactiveBinding Bind( TViewModel viewModel, TView view, Expression> vmProperty, @@ -121,7 +121,7 @@ IReactiveBinding> Bind that, when disposed, /// disconnects the binding. /// - IReactiveBinding> Bind( + IReactiveBinding Bind( TViewModel viewModel, TView view, Expression> vmProperty, diff --git a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs index 6d1f6e5b1..67099bfcf 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBinderImplementation.cs @@ -28,7 +28,7 @@ public class PropertyBinderImplementation : IPropertyBinderImplementation { var score = x.GetAffinityForObjects(types.fromType, types.toType); return score > acc.currentAffinity && score > 0 ? (score, x) : acc; - }).Item2; + }).currentBinding; }, RxApp.SmallCacheLimit); private static readonly MemoizingMRUCache<(Type fromType, Type toType), ISetMethodBindingConverter> _setMethodCache = new MemoizingMRUCache<(Type fromType, Type toType), ISetMethodBindingConverter>( @@ -39,7 +39,7 @@ public class PropertyBinderImplementation : IPropertyBinderImplementation { var score = x.GetAffinityForObjects(type.fromType, type.toType); return score > acc.currentAffinity && score > 0 ? (score, x) : acc; - }).Item2; + }).currentBinding; }, RxApp.SmallCacheLimit); private delegate bool OutFunc(T1 t1, out T2 t2); @@ -97,7 +97,7 @@ public class PropertyBinderImplementation : IPropertyBinderImplementation /// An instance of that, when disposed, /// disconnects the binding. /// - public IReactiveBinding> Bind( + public IReactiveBinding Bind( TViewModel viewModel, TView view, Expression> vmProperty, @@ -177,7 +177,7 @@ bool ViewToVmFunc(TVProp vValue, out TVMProp vmValue) /// An instance of that, when disposed, /// disconnects the binding. /// - public IReactiveBinding> Bind( + public IReactiveBinding Bind( TViewModel viewModel, TView view, Expression> vmProperty, @@ -562,7 +562,7 @@ private bool EvalBindingHooks(TViewModel viewModel, TView vie return shouldBind; } - private IReactiveBinding> BindImpl( + private IReactiveBinding BindImpl( TViewModel viewModel, TView view, Expression> vmProperty, @@ -628,17 +628,17 @@ private IReactiveBinding> BindImpl> changes = changeWithValues.Where(tuple => tuple != null).Publish().RefCount(); + IObservable<(object view, bool isViewModel)> changes = changeWithValues.Where(value => value != null).Select(value => (value.Item1, value.Item2)).Publish().RefCount(); IDisposable disposable = changes.Subscribe(isVmWithLatestValue => { - if (isVmWithLatestValue.Item2) + if (isVmWithLatestValue.isViewModel) { - Reflection.TrySetValueToPropertyChain(view, viewExpression.GetExpressionChain(), isVmWithLatestValue.Item1, false); + Reflection.TrySetValueToPropertyChain(view, viewExpression.GetExpressionChain(), isVmWithLatestValue.view, false); } else { - Reflection.TrySetValueToPropertyChain(view.ViewModel, vmExpression.GetExpressionChain(), isVmWithLatestValue.Item1, false); + Reflection.TrySetValueToPropertyChain(view.ViewModel, vmExpression.GetExpressionChain(), isVmWithLatestValue.view, false); } }); @@ -646,7 +646,7 @@ private IReactiveBinding> BindImpl>( + return new ReactiveBinding( view, viewModel, viewExpression, diff --git a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs index 23002a117..5a7585c01 100644 --- a/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs +++ b/src/ReactiveUI/Bindings/Property/PropertyBindingMixins.cs @@ -57,7 +57,7 @@ static PropertyBindingMixins() /// An instance of that, when disposed, /// disconnects the binding. /// - public static IReactiveBinding> Bind( + public static IReactiveBinding Bind( this TView view, TViewModel viewModel, Expression> vmProperty, @@ -124,7 +124,7 @@ public static IReactiveBinding> Bind that, when disposed, /// disconnects the binding. /// - public static IReactiveBinding> Bind( + public static IReactiveBinding Bind( this TView view, TViewModel viewModel, Expression> vmProperty, @@ -168,7 +168,7 @@ public static IReactiveBinding> Bind that, when disposed, /// disconnects the binding. /// - public static IReactiveBinding> Bind( + public static IReactiveBinding Bind( this TView view, TViewModel viewModel, Expression> vmProperty, @@ -218,7 +218,7 @@ public static IReactiveBinding> Bind that, when disposed, /// disconnects the binding. /// - public static IReactiveBinding> Bind( + public static IReactiveBinding Bind( this TView view, TViewModel viewModel, Expression> vmProperty, diff --git a/src/ReactiveUI/EventHandlers/INotifyPropertyChanging.cs b/src/ReactiveUI/EventHandlers/INotifyPropertyChanging.cs deleted file mode 100644 index 6288cc4e5..000000000 --- a/src/ReactiveUI/EventHandlers/INotifyPropertyChanging.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Specialized; - -namespace ReactiveUI -{ - /// - /// Classes which implement this interface will notify - /// external users when a property is changing. - /// - public interface INotifyPropertyChanging - { - /// - /// An event that is triggered before a property's value is going to change. - /// - event PropertyChangingEventHandler PropertyChanging; - } -} \ No newline at end of file diff --git a/src/ReactiveUI/EventHandlers/PropertyChangingEventArgs.cs b/src/ReactiveUI/EventHandlers/PropertyChangingEventArgs.cs deleted file mode 100644 index c8cba0aa9..000000000 --- a/src/ReactiveUI/EventHandlers/PropertyChangingEventArgs.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Specialized; - -namespace ReactiveUI -{ - /// - /// The arguments for the PropertyChanging event. - /// - public class PropertyChangingEventArgs : EventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The name of the property that is changing. - public PropertyChangingEventArgs(string propertyName) - { - PropertyName = propertyName; - } - - /// - /// Gets or sets the name of the property that is changing. - /// - public string PropertyName { get; protected set; } - } -} diff --git a/src/ReactiveUI/EventHandlers/PropertyChangingEventHandler.cs b/src/ReactiveUI/EventHandlers/PropertyChangingEventHandler.cs deleted file mode 100644 index c953522c7..000000000 --- a/src/ReactiveUI/EventHandlers/PropertyChangingEventHandler.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -namespace ReactiveUI -{ - /// - /// Event handler for the property changing events. - /// This will be called before a property value has changed. - /// - /// The sender of the event. - /// Details about the changing property. - public delegate void PropertyChangingEventHandler(object sender, PropertyChangingEventArgs e); -} diff --git a/src/ReactiveUI/EventManagers/CollectionChangingEventManager.cs b/src/ReactiveUI/EventManagers/CollectionChangingEventManager.cs deleted file mode 100644 index 81ca3f951..000000000 --- a/src/ReactiveUI/EventManagers/CollectionChangingEventManager.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System.Collections.Specialized; - -namespace ReactiveUI -{ -#if !NET_461 - internal class CollectionChangingEventManager : WeakEventManager - { - } -#endif -} diff --git a/src/ReactiveUI/EventManagers/PropertyChangingEventManager.cs b/src/ReactiveUI/EventManagers/PropertyChangingEventManager.cs index db437492b..a64573fc4 100644 --- a/src/ReactiveUI/EventManagers/PropertyChangingEventManager.cs +++ b/src/ReactiveUI/EventManagers/PropertyChangingEventManager.cs @@ -3,6 +3,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. +using System.ComponentModel; + namespace ReactiveUI { #if !NET_461 diff --git a/src/ReactiveUI/Expression/Reflection.cs b/src/ReactiveUI/Expression/Reflection.cs index e0528c6cb..efe428e14 100644 --- a/src/ReactiveUI/Expression/Reflection.cs +++ b/src/ReactiveUI/Expression/Reflection.cs @@ -144,6 +144,11 @@ public static Func GetValueFetcherForProperty(MemberIn /// A Func that takes in the object/indexes and returns the value. public static Func GetValueFetcherOrThrow(MemberInfo member) { + if (member is null) + { + throw new ArgumentNullException(nameof(member)); + } + var ret = GetValueFetcherForProperty(member); if (ret == null) @@ -191,6 +196,11 @@ public static Action GetValueSetterForProperty(MemberI /// A Func that takes in the object/indexes and sets the value. public static Action GetValueSetterOrThrow(MemberInfo member) { + if (member is null) + { + throw new ArgumentNullException(nameof(member)); + } + var ret = GetValueSetterForProperty(member); if (ret == null) @@ -382,13 +392,13 @@ public static void ThrowIfMethodsNotOverloaded(string callingTypeName, object ta .Select(x => { IEnumerable methods = targetObject.GetType().GetTypeInfo().DeclaredMethods; - return Tuple.Create(x, methods.FirstOrDefault(y => y.Name == x)); + return (methodName: x, methodImplementation: methods.FirstOrDefault(y => y.Name == x)); }) - .FirstOrDefault(x => x.Item2 == null); + .FirstOrDefault(x => x.methodImplementation == null); - if (missingMethod != null) + if (missingMethod.methodImplementation == default) { - throw new Exception($"Your class must implement {missingMethod.Item1} and call {callingTypeName}.{missingMethod.Item1}"); + throw new Exception($"Your class must implement {missingMethod.methodName} and call {callingTypeName}.{missingMethod.methodName}"); } } diff --git a/src/ReactiveUI/Interfaces/IActivatable.cs b/src/ReactiveUI/Interfaces/IActivatableView.cs similarity index 93% rename from src/ReactiveUI/Interfaces/IActivatable.cs rename to src/ReactiveUI/Interfaces/IActivatableView.cs index b2f817498..d956c1e4c 100644 --- a/src/ReactiveUI/Interfaces/IActivatable.cs +++ b/src/ReactiveUI/Interfaces/IActivatableView.cs @@ -11,7 +11,7 @@ namespace ReactiveUI /// Use this Interface when you want to mark a control as recieving View /// Activation when it doesn't have a backing ViewModel. /// - public interface IActivatable + public interface IActivatableView { } } diff --git a/src/ReactiveUI/Interfaces/ISupportsActivation.cs b/src/ReactiveUI/Interfaces/IActivatableViewModel.cs similarity index 95% rename from src/ReactiveUI/Interfaces/ISupportsActivation.cs rename to src/ReactiveUI/Interfaces/IActivatableViewModel.cs index 3b9796f16..c6cbd9255 100644 --- a/src/ReactiveUI/Interfaces/ISupportsActivation.cs +++ b/src/ReactiveUI/Interfaces/IActivatableViewModel.cs @@ -12,7 +12,7 @@ namespace ReactiveUI /// the View is activated. See the documentation for ViewModelActivator to /// read more about Activation. /// - public interface ISupportsActivation + public interface IActivatableViewModel { /// /// Gets the Activator which will be used by the View when Activation/Deactivation occurs. diff --git a/src/ReactiveUI/Interfaces/IViewFor.cs b/src/ReactiveUI/Interfaces/IViewFor.cs index 13b2ce566..d8874d1cc 100644 --- a/src/ReactiveUI/Interfaces/IViewFor.cs +++ b/src/ReactiveUI/Interfaces/IViewFor.cs @@ -9,7 +9,7 @@ namespace ReactiveUI /// This base class is mostly used by the Framework. Implement /// instead. /// - public interface IViewFor : IActivatable + public interface IViewFor : IActivatableView { /// /// Gets or sets the View Model associated with the View. diff --git a/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs b/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs index 47ae8c994..95d5b4f7a 100644 --- a/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs +++ b/src/ReactiveUI/Interfaces/ReactivePropertyChangingEventArgs.cs @@ -3,6 +3,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. +using System.ComponentModel; + namespace ReactiveUI { /// diff --git a/src/ReactiveUI/Legacy/IMoveInfo.cs b/src/ReactiveUI/Legacy/IMoveInfo.cs deleted file mode 100644 index 0d7e45cfc..000000000 --- a/src/ReactiveUI/Legacy/IMoveInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System.Collections.Generic; - -#pragma warning disable CA1716 // don't use reserve word -- disabled for legacy. - -namespace ReactiveUI.Legacy -{ - /// - /// Information when a item has been moved inside a collection. - /// - /// The item type inside the collection. - public interface IMoveInfo - { - /// - /// Gets a enumerable of the moved items. - /// - IEnumerable MovedItems { get; } - - /// - /// Gets the old index where the item has moved from. - /// - int From { get; } - - /// - /// Gets the new index where the item has moved to. - /// - int To { get; } - } -} diff --git a/src/ReactiveUI/Legacy/INotifyCollectionChanging.cs b/src/ReactiveUI/Legacy/INotifyCollectionChanging.cs deleted file mode 100644 index b42eadd47..000000000 --- a/src/ReactiveUI/Legacy/INotifyCollectionChanging.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Specialized; - -namespace ReactiveUI -{ - /// - /// Notifies when a collection is changing. - /// - public interface INotifyCollectionChanging - { - /// - /// An event for when a collection is changing. Used for getting values - /// before the change. - /// - event NotifyCollectionChangedEventHandler CollectionChanging; - } -} \ No newline at end of file diff --git a/src/ReactiveUI/Legacy/IReactiveCollection.cs b/src/ReactiveUI/Legacy/IReactiveCollection.cs deleted file mode 100644 index b153aef4f..000000000 --- a/src/ReactiveUI/Legacy/IReactiveCollection.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; - -namespace ReactiveUI.Legacy -{ - /// - /// IReactiveCollection of T represents a collection that can notify when its - /// contents are changed (either items are added/removed, or the object - /// itself changes). - /// - /// It is important to implement the Changing/Changed from - /// IReactiveNotifyPropertyChanged semantically as "Fire when *anything* in - /// the collection or any of its items have changed, in any way". - /// - /// The collection type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveCollection : IReactiveNotifyCollectionChanged, IReactiveNotifyCollectionItemChanged, IEnumerable, INotifyCollectionChanged, INotifyCollectionChanging, IReactiveObject - { - /// - /// Resets the collection and retriggers all the observables with fresh changes. - /// - void Reset(); - } -} diff --git a/src/ReactiveUI/Legacy/IReactiveDerivedList.cs b/src/ReactiveUI/Legacy/IReactiveDerivedList.cs deleted file mode 100644 index bd911affe..000000000 --- a/src/ReactiveUI/Legacy/IReactiveDerivedList.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; - -namespace ReactiveUI.Legacy -{ - /// - /// IReactiveDerivedList represents a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection is updated. - /// - /// The list type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveDerivedList : IReadOnlyReactiveList, IDisposable - { - } -} diff --git a/src/ReactiveUI/Legacy/IReactiveList.cs b/src/ReactiveUI/Legacy/IReactiveList.cs deleted file mode 100644 index a0c01f1e9..000000000 --- a/src/ReactiveUI/Legacy/IReactiveList.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; - -namespace ReactiveUI.Legacy -{ - /// - /// IReactiveList of T represents a list that can notify when its - /// contents are changed (either items are added/removed, or the object - /// itself changes). - /// - /// It is important to implement the Changing/Changed from - /// IReactiveNotifyPropertyChanged semantically as "Fire when *anything* in - /// the collection or any of its items have changed, in any way". - /// - /// The list type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveList : IReactiveCollection, IList - { - /// - /// Gets a value indicating whether the collection is empty. - /// - bool IsEmpty { get; } - - /// - /// Adds a range of elements to the collection. - /// - /// A collection of values to add. - void AddRange(IEnumerable collection); - - /// - /// Inserts a range of elements to the collection at the specified index. - /// - /// The index to start adding the items to. - /// A collection of values to add. - void InsertRange(int index, IEnumerable collection); - - /// - /// Remove all the items contained within the specified collection. - /// - /// The items to remove. - void RemoveAll(IEnumerable items); - - /// - /// Removes items contained at the starting index going to count. - /// - /// The index to start removing items from. - /// The number of items to remove. - void RemoveRange(int index, int count); - - /// - /// Sort the container using the specified comparer. - /// - /// The comparer to use to sort the list. If none is specified the default comparer will be used. - void Sort(IComparer comparer = null); - - /// - /// Sort the container using the specified comparison method. - /// - /// The comparison type to use to sort the list. - void Sort(Comparison comparison); - - /// - /// Sort the items based at the specified index for the number of items specified by the count. - /// - /// The index to start sorting at. - /// The count to sort. - /// The comparer to use to sort the list. - void Sort(int index, int count, IComparer comparer); - } -} diff --git a/src/ReactiveUI/Legacy/IReactiveNotifyCollectionChanged.cs b/src/ReactiveUI/Legacy/IReactiveNotifyCollectionChanged.cs deleted file mode 100644 index 8516b0529..000000000 --- a/src/ReactiveUI/Legacy/IReactiveNotifyCollectionChanged.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Specialized; -using System.Reactive; - -#pragma warning disable SA1600 // Elements should be documented -- not used for legacy - -namespace ReactiveUI.Legacy -{ - /// - /// IReactiveNotifyCollectionChanged of T provides notifications when the contents - /// of collection are changed (items are added/removed/moved). - /// - /// The list type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionChanged - { - /// - /// Gets an observable that signals when items are added to the collection, once per item added. - /// Functions that add multiple items such AddRange should fire this - /// multiple times. The object provided is the item that was added. - /// - IObservable ItemsAdded { get; } - - /// - /// Gets an observable that signals before an item is going to be added to the collection. - /// - IObservable BeforeItemsAdded { get; } - - /// - /// Gets an observable that signals once an item has been removed from a collection, providing the - /// item that was removed. - /// - IObservable ItemsRemoved { get; } - - /// - /// Gets an observable that signals before an item will be removed from a collection, providing - /// the item that will be removed. - /// - IObservable BeforeItemsRemoved { get; } - - /// - /// Gets an observable that signals before an items moves from one position in the collection to - /// another, providing the item(s) to be moved as well as source and destination - /// indices. - /// - IObservable> BeforeItemsMoved { get; } - - /// - /// Gets an observable that signals once one or more items moves from one position in the collection to - /// another, providing the item(s) that was moved as well as source and destination - /// indices. - /// - IObservable> ItemsMoved { get; } - - /// - /// Gets an observable that signals when the collection is changing. - /// This Observable is equivalent to the NotifyCollectionChanged event, - /// but fires before the collection is changed. - /// - IObservable Changing { get; } - - /// - /// Gets an observable that signals when the collection has changed. - /// This Observable is equivalent to the NotifyCollectionChanged event, - /// and fires after the collection is changed. - /// - IObservable Changed { get; } - - /// - /// Gets an observable that signals when the collection count changes, regardless of reason. - /// - IObservable CountChanging { get; } - - /// - /// Gets an observable that signals when the collection count changes, regardless of reason. - /// - IObservable CountChanged { get; } - - /// - /// Gets an observable that signals when the collection has become empty or not. - /// - IObservable IsEmptyChanged { get; } - - /// - /// Gets an observable that signals when a ShouldReset fires on the collection. This - /// means that you should forget your previous knowledge of the state - /// of the collection and reread it. - /// - /// This does *not* mean Clear, and if you interpret it as such, you are - /// Doing It Wrong. - /// - IObservable ShouldReset { get; } - - /// - /// Stops change notifications, and returns a disposable which when disposed will trigger a reset event. - /// - /// The disposable to use to turn back on notifications. - IDisposable SuppressChangeNotifications(); - } -} diff --git a/src/ReactiveUI/Legacy/IReactiveNotifyCollectionItemChanged.cs b/src/ReactiveUI/Legacy/IReactiveNotifyCollectionItemChanged.cs deleted file mode 100644 index cce1986ee..000000000 --- a/src/ReactiveUI/Legacy/IReactiveNotifyCollectionItemChanged.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; - -namespace ReactiveUI.Legacy -{ - /// - /// IReactiveNotifyCollectionItemChanged provides notifications for collection item updates, ie when an object in - /// a collection changes. - /// - /// The sender type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReactiveNotifyCollectionItemChanged - { - /// - /// Gets an observable that signals when item changing notifications have occurred for any item in collection that - /// implements IReactiveNotifyPropertyChanged. This is only enabled when - /// ChangeTrackingEnabled is set to True. - /// - IObservable> ItemChanging { get; } - - /// - /// Gets an observable that signals when item change notifications have occurred Item Changed notifications for any item in collection that - /// implements IReactiveNotifyPropertyChanged. This is only enabled when - /// ChangeTrackingEnabled is set to True. - /// - IObservable> ItemChanged { get; } - - /// - /// Gets or sets a value indicating whether to track if contained items INotifyPropertyChanged events have been triggered. - /// - bool ChangeTrackingEnabled { get; set; } - } -} diff --git a/src/ReactiveUI/Legacy/IReadOnlyReactiveCollection.cs b/src/ReactiveUI/Legacy/IReadOnlyReactiveCollection.cs deleted file mode 100644 index 69b6ef530..000000000 --- a/src/ReactiveUI/Legacy/IReadOnlyReactiveCollection.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; - -namespace ReactiveUI.Legacy -{ - /// - /// IReadOnlyReactiveCollection of T represents a read-only collection that can notify when its - /// contents are changed (either items are added/removed, or the object - /// itself changes). - /// - /// It is important to implement the Changing/Changed from - /// IReactiveNotifyPropertyChanged semantically as "Fire when *anything* in - /// the collection or any of its items have changed, in any way". - /// - /// The list type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveCollection : IReadOnlyCollection, IReactiveCollection - { - } -} diff --git a/src/ReactiveUI/Legacy/IReadOnlyReactiveList.cs b/src/ReactiveUI/Legacy/IReadOnlyReactiveList.cs deleted file mode 100644 index 7907c02ff..000000000 --- a/src/ReactiveUI/Legacy/IReadOnlyReactiveList.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; - -namespace ReactiveUI.Legacy -{ - /// - /// IReadOnlyReactiveList of T represents a read-only list that can notify when its - /// contents are changed (either items are added/removed, or the object - /// itself changes). - /// - /// It is important to implement the Changing/Changed from - /// IReactiveNotifyPropertyChanged semantically as "Fire when *anything* in - /// the collection or any of its items have changed, in any way". - /// - /// The list type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public interface IReadOnlyReactiveList : IReadOnlyReactiveCollection, IReadOnlyList - { - /// - /// Gets a value indicating whether the list is empty. - /// - bool IsEmpty { get; } - } -} diff --git a/src/ReactiveUI/Legacy/MoveInfo.cs b/src/ReactiveUI/Legacy/MoveInfo.cs deleted file mode 100644 index c09ee9c7b..000000000 --- a/src/ReactiveUI/Legacy/MoveInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System.Collections.Generic; - -namespace ReactiveUI.Legacy -{ - /// - /// Information about a move between locations within a Reactive collection. - /// - /// The type of item contained in the move. - internal class MoveInfo : IMoveInfo - { - public MoveInfo(IEnumerable movedItems, int from, int to) - { - MovedItems = movedItems; - From = from; - To = to; - } - - public IEnumerable MovedItems { get; protected set; } - - public int From { get; protected set; } - - public int To { get; protected set; } - } -} diff --git a/src/ReactiveUI/Legacy/ObservableCollectionMixin.cs b/src/ReactiveUI/Legacy/ObservableCollectionMixin.cs deleted file mode 100644 index 421916f78..000000000 --- a/src/ReactiveUI/Legacy/ObservableCollectionMixin.cs +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics.Contracts; -using System.Reactive; -using System.Reactive.Concurrency; -using System.Reactive.Linq; - -namespace ReactiveUI.Legacy -{ - /// - /// Extension methods to create collections that "follow" other collections. - /// - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public static class ObservableCollectionMixin - { - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Note that even though this method attaches itself to any - /// IEnumerable, it will only detect changes from objects implementing - /// (like ). - /// If your source collection doesn't implement this, - /// is the way to signal the derived collection to reorder/refilter itself. - /// - /// The type. - /// The new type. - /// The signal type. - /// - /// The source to track. - /// - /// - /// A Select function that will be run on each item. - /// - /// - /// An action that is called on each item when it is removed. - /// - /// - /// A filter to determine whether to exclude items in the derived collection. - /// - /// - /// A comparator method to determine the ordering of the resulting collection. - /// - /// - /// When this Observable is signalled, the derived collection will be manually - /// reordered/refiltered. - /// - /// - /// An optional scheduler used to dispatch change notifications. - /// - /// - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - /// - public static IReactiveDerivedList CreateDerivedCollection( - this IEnumerable @this, - Func selector, - Action onRemoved, - Func filter = null, - Func orderer = null, - IObservable signalReset = null, - IScheduler scheduler = null) - { - Contract.Requires(selector != null); - - IObservable reset = null; - - if (signalReset != null) - { - reset = signalReset.Select(_ => Unit.Default); - } - - if (scheduler == null) - { - scheduler = Scheduler.Immediate; - } - - return new ReactiveDerivedCollection(@this, selector, filter, orderer, onRemoved, reset, scheduler); - } - - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Note that even though this method attaches itself to any - /// IEnumerable, it will only detect changes from objects implementing - /// (like ). - /// If your source collection doesn't implement this, - /// is the way to signal the derived collection to reorder/refilter itself. - /// - /// The type. - /// The new type. - /// The signal type. - /// - /// The source to track. - /// - /// - /// A Select function that will be run on each item. - /// - /// - /// A filter to determine whether to exclude items in the derived collection. - /// - /// - /// A comparator method to determine the ordering of the resulting collection. - /// - /// - /// When this Observable is signalled, the derived collection will be manually - /// reordered/refiltered. - /// - /// - /// An optional scheduler used to dispatch change notifications. - /// - /// - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - /// - public static IReactiveDerivedList CreateDerivedCollection( - this IEnumerable @this, - Func selector, - Func filter = null, - Func orderer = null, - IObservable signalReset = null, - IScheduler scheduler = null) - { - return @this.CreateDerivedCollection(selector, (Action)null, filter, orderer, signalReset, scheduler); - } - - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Be aware that this overload will result in a collection that *only* - /// updates if the source implements INotifyCollectionChanged. If your - /// list changes but isn't a ReactiveList/ObservableCollection, - /// you probably want to use the other overload. - /// - /// The type. - /// The new type. - /// - /// The source to track. - /// - /// - /// A Select function that will be run on each item. - /// - /// - /// An action that is called on each item when it is removed. - /// - /// - /// A filter to determine whether to exclude items in the derived collection. - /// - /// - /// A comparator method to determine the ordering of the resulting collection. - /// - /// - /// An optional scheduler used to dispatch change notifications. - /// - /// - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - /// - public static IReactiveDerivedList CreateDerivedCollection( - this IEnumerable @this, - Func selector, - Action onRemoved, - Func filter = null, - Func orderer = null, - IScheduler scheduler = null) - { - return @this.CreateDerivedCollection(selector, onRemoved, filter, orderer, (IObservable)null, scheduler); - } - - /// - /// Creates a collection whose contents will "follow" another - /// collection; this method is useful for creating ViewModel collections - /// that are automatically updated when the respective Model collection - /// is updated. - /// - /// Be aware that this overload will result in a collection that *only* - /// updates if the source implements INotifyCollectionChanged. If your - /// list changes but isn't a ReactiveList/ObservableCollection, - /// you probably want to use the other overload. - /// - /// The type. - /// The new type. - /// - /// The source to track. - /// - /// - /// A Select function that will be run on each item. - /// - /// - /// A filter to determine whether to exclude items in the derived collection. - /// - /// - /// A comparator method to determine the ordering of the resulting collection. - /// - /// - /// An optional scheduler used to dispatch change notifications. - /// - /// - /// A new collection whose items are equivalent to - /// Collection.Select().Where().OrderBy() and will mirror changes - /// in the initial collection. - /// - public static IReactiveDerivedList CreateDerivedCollection( - this IEnumerable @this, - Func selector, - Func filter = null, - Func orderer = null, - IScheduler scheduler = null) - { - return @this.CreateDerivedCollection(selector, default(Action), filter, orderer, (IObservable)null, scheduler); - } - } -} diff --git a/src/ReactiveUI/Legacy/ReactiveCollectionMixins.cs b/src/ReactiveUI/Legacy/ReactiveCollectionMixins.cs deleted file mode 100644 index e846053fd..000000000 --- a/src/ReactiveUI/Legacy/ReactiveCollectionMixins.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Diagnostics.Contracts; -using System.Linq; -using System.Reactive; -using System.Reactive.Concurrency; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Runtime.CompilerServices; -using System.Threading; -using Splat; - -namespace ReactiveUI.Legacy -{ - /// - /// Extension methods to create collections from observables. - /// - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public static class ReactiveCollectionMixins - { - /// - /// Creates a collection based on an an Observable by adding items - /// provided until the Observable completes. This method guarantees that - /// items are always added in the context of the provided scheduler. - /// - /// The list type. - /// - /// The Observable whose items will be put into the new collection. - /// - /// - /// Optionally specifies the scheduler on which - /// the collection will be populated. Defaults to the main scheduler. - /// - /// - /// A new collection which will be populated with the Observable. - /// - public static IReactiveDerivedList CreateCollection( - this IObservable fromObservable, - IScheduler scheduler) - { - return new ReactiveDerivedCollectionFromObservable(fromObservable, scheduler: scheduler); - } - - /// - /// Creates a collection based on an an Observable by adding items - /// provided until the Observable completes, optionally ensuring a - /// delay. Note that if the Observable never completes and withDelay is - /// set, this method will leak a Timer. This method also guarantees that - /// items are always added in the context of the provided scheduler. - /// - /// The type. - /// - /// The Observable whose items will be put into the new collection. - /// - /// - /// If set, items will be populated in the collection no faster than the delay provided. - /// - /// - /// The handler for errors from the Observable. If not specified, - /// an error will go to DefaultExceptionHandler. - /// - /// - /// Optionally specifies the scheduler on which the collection will be populated. - /// Defaults to the main scheduler. - /// - /// - /// A new collection which will be populated with the Observable. - /// - public static IReactiveDerivedList CreateCollection( - this IObservable fromObservable, - TimeSpan? withDelay = null, - Action onError = null, - IScheduler scheduler = null) - { - return new ReactiveDerivedCollectionFromObservable(fromObservable, withDelay, onError, scheduler); - } - } -} diff --git a/src/ReactiveUI/Legacy/ReactiveDerivedCollection.cs b/src/ReactiveUI/Legacy/ReactiveDerivedCollection.cs deleted file mode 100644 index ca3a60e2a..000000000 --- a/src/ReactiveUI/Legacy/ReactiveDerivedCollection.cs +++ /dev/null @@ -1,872 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Diagnostics; -using System.Diagnostics.Contracts; -using System.Globalization; -using System.Linq; -using System.Reactive; -using System.Reactive.Concurrency; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Runtime.CompilerServices; -using System.Threading; -using Splat; - -#pragma warning disable SA1600 // Elements should be documented -- not used for legacy -#pragma warning disable SA1201 // Ordering -- not used for legacy -#pragma warning disable SA1202 // Ordering -- not used for legacy -#pragma warning disable SA1124 // Do not use regions -- not used for legacy -#pragma warning disable RCS1165 // Unconstrained null check -- not used for legacy -#pragma warning disable CA1001 // Undisposed type -- not used for legacy -#pragma warning disable CA1822 // Mark member static -- not used for legacy -#pragma warning disable SA1100 // Do not use prefix -- not used for legacy -#pragma warning disable SA1407 // Expression should declare precedence -- not used for legacy -#pragma warning disable SA1402 // File many contain only single type -- not used for legacy -#pragma warning disable SA1405 // Asset should provide message -- not used for legacy - -namespace ReactiveUI.Legacy -{ - /// - /// This class represents a change-notifying Collection which is derived from - /// a source collection, via CreateDerivedCollection or via another method. - /// It is read-only, and any attempts to change items in the collection will - /// fail. - /// - /// The source type. - /// The value type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - internal class ReactiveDerivedCollection : ReactiveDerivedCollection, IDisposable - { - private readonly IEnumerable _source; - private readonly Func _selector; - private readonly Func _filter; - private readonly Func _orderer; - private readonly Action _onRemoved; - private readonly IObservable _signalReset; - private readonly IScheduler _scheduler; - - // This list maps indices in this collection to their corresponding indices in the source collection. - private readonly List _indexToSourceIndexMap; - private readonly List _sourceCopy; - private CompositeDisposable _inner; - - public ReactiveDerivedCollection( - IEnumerable source, - Func selector, - Func filter, - Func orderer, - Action onRemoved, - IObservable signalReset, - IScheduler scheduler) - { - Contract.Requires(source != null); - Contract.Requires(selector != null); - - if (filter == null) - { - filter = x => true; - } - - _source = source; - _selector = selector; - _filter = filter; - _orderer = orderer; - _onRemoved = onRemoved ?? (_ => { }); - _signalReset = signalReset; - _scheduler = scheduler; - - _inner = new CompositeDisposable(); - _indexToSourceIndexMap = new List(); - _sourceCopy = new List(); - - _inner.Add(Disposable.Create(() => - { - foreach (var item in this) - { - _onRemoved(item); - } - })); - - AddAllItemsFromSourceCollection(); - WireUpChangeNotifications(); - } - - private static readonly Dictionary hasWarned = new Dictionary(); - - private void WireUpChangeNotifications() - { - var incc = _source as INotifyCollectionChanged; - - if (incc == null) - { - var type = _source.GetType(); - - lock (hasWarned) - { - if (!hasWarned.ContainsKey(type)) - { - this.Log().Warn( - CultureInfo.InvariantCulture, - "{0} doesn't implement INotifyCollectionChanged, derived collection will only update when the Reset() method is invoked manually or the reset observable is signalled.", - type.FullName); - hasWarned.Add(type, true); - } - } - } - else - { - var irncc = _source as IReactiveNotifyCollectionChanged; - var eventObs = irncc != null - ? irncc.Changed - : Observable - .FromEventPattern( - x => incc.CollectionChanged += x, - x => incc.CollectionChanged -= x) - .Select(x => x.EventArgs); - _inner.Add(eventObs.ObserveOn(_scheduler).Subscribe(OnSourceCollectionChanged)); - } - - var irc = _source as IReactiveCollection; - - if (irc != null) - { - _inner.Add(irc.ItemChanged.Select(x => x.Sender).ObserveOn(_scheduler).Subscribe(OnItemChanged)); - } - - if (_signalReset != null) - { - _inner.Add(_signalReset.ObserveOn(_scheduler).Subscribe(x => Reset())); - } - } - - private void OnItemChanged(TSource changedItem) - { - // If you've implemented INotifyPropertyChanged on a struct then you're doing it wrong(TM) and change - // tracking won't work in derived collections (change tracking for value types makes no sense any way) - // NB: It's possible the sender exists in multiple places in the source collection. - var sourceIndices = IndexOfAll(_sourceCopy, changedItem, ReferenceEqualityComparer.Default); - - var shouldBeIncluded = _filter(changedItem); - - foreach (int sourceIndex in sourceIndices) - { - int currentDestinationIndex = GetIndexFromSourceIndex(sourceIndex); - bool isIncluded = currentDestinationIndex >= 0; - - if (isIncluded && !shouldBeIncluded) - { - InternalRemoveAt(currentDestinationIndex); - } - else if (!isIncluded && shouldBeIncluded) - { - InternalInsertAndMap(sourceIndex, _selector(changedItem)); - } - else if (isIncluded && shouldBeIncluded) - { - // The item is already included and it should stay there but it's possible that the change that - // caused this event affects the ordering. This gets a little tricky so let's be verbose. - TValue newItem = _selector(changedItem); - - if (_orderer == null) - { - // We don't have an orderer so we're currently using the source collection index for sorting - // meaning that no item change will affect ordering. Look at our current item and see if it's - // the exact (reference-wise) same object. If it is then we're done, if it's not (for example - // if it's an integer) we'll issue a replace event so that subscribers get the new value. - if (!ReferenceEquals(newItem, this[currentDestinationIndex])) - { - InternalReplace(currentDestinationIndex, newItem); - } - } - else - { - // Don't be tempted to just use the orderer to compare the new item with the previous since - // they'll almost certainly be equal (for reference types). We need to test whether or not the - // new item can stay in the same position that the current item is in without comparing them. - if (CanItemStayAtPosition(newItem, currentDestinationIndex)) - { - // The new item should be in the same position as the current but there's no need to signal - // that in case they are the same object. - if (!ReferenceEquals(newItem, this[currentDestinationIndex])) - { - InternalReplace(currentDestinationIndex, newItem); - } - } - else - { - // The change is forcing us to reorder. We'll use a move operation if the item hasn't - // changed (ie it's the same object) and we'll implement it as a remove and add if the - // object has changed (ie the selector is not an identity function). - if (ReferenceEquals(newItem, this[currentDestinationIndex])) - { - int newDestinationIndex = NewPositionForExistingItem( - sourceIndex, currentDestinationIndex, newItem); - - Debug.Assert(newDestinationIndex != currentDestinationIndex, "This can't be, canItemStayAtPosition said it this couldn't happen"); - - _indexToSourceIndexMap.RemoveAt(currentDestinationIndex); - _indexToSourceIndexMap.Insert(newDestinationIndex, sourceIndex); - - InternalMove(currentDestinationIndex, newDestinationIndex); - } - else - { - InternalRemoveAt(currentDestinationIndex); - InternalInsertAndMap(sourceIndex, newItem); - } - } - } - } - } - } - - /// - /// Gets a value indicating whether or not the item fits (sort-wise) at the provided index. The determination - /// is made by checking whether or not it's considered larger than or equal to the preceeding item and if - /// it's less than or equal to the succeeding item. - /// - /// The item. - /// The current index. - private bool CanItemStayAtPosition(TValue item, int currentIndex) - { - bool hasPrecedingItem = currentIndex > 0; - - if (hasPrecedingItem) - { - bool isGreaterThanOrEqualToPrecedingItem = _orderer(item, this[currentIndex - 1]) >= 0; - if (!isGreaterThanOrEqualToPrecedingItem) - { - return false; - } - } - - bool hasSucceedingItem = currentIndex < Count - 1; - - if (hasSucceedingItem) - { - bool isLessThanOrEqualToSucceedingItem = _orderer(item, this[currentIndex + 1]) <= 0; - if (!isLessThanOrEqualToSucceedingItem) - { - return false; - } - } - - return true; - } - - private void InternalReplace(int destinationIndex, TValue newItem) - { - var item = this[destinationIndex]; - SetItem(destinationIndex, newItem); - _onRemoved(item); - } - - /// - /// Gets the index of the dervived item based on it's originating element index in the source collection. - /// - /// The source index. - private int GetIndexFromSourceIndex(int sourceIndex) - { - return _indexToSourceIndexMap.IndexOf(sourceIndex); - } - - /// - /// Returns one or more positions in the source collection where the given item is found based on the - /// provided equality comparer. - /// - /// The source. - /// The item. - /// The equality comparer. - private List IndexOfAll( - IEnumerable source, - TSource item, - IEqualityComparer equalityComparer) - { - var indices = new List(1); - int sourceIndex = 0; - foreach (var x in source) - { - if (equalityComparer.Equals(x, item)) - { - indices.Add(sourceIndex); - } - - sourceIndex++; - } - - return indices; - } - - private void OnSourceCollectionChanged(NotifyCollectionChangedEventArgs args) - { - if (args.Action == NotifyCollectionChangedAction.Reset) - { - Reset(); - return; - } - - if (args.Action == NotifyCollectionChangedAction.Move) - { - Debug.Assert(args.OldItems.Count == args.NewItems.Count); - - if (args.OldItems.Count > 1 || args.NewItems.Count > 1) - { - throw new NotSupportedException("Derived collections doesn't support multi-item moves"); - } - - // Yeah apparently this can happen. ObservableCollection triggers this notification on Move(0,0) - if (args.OldStartingIndex == args.NewStartingIndex) - { - return; - } - - int oldSourceIndex = args.OldStartingIndex; - int newSourceIndex = args.NewStartingIndex; - - _sourceCopy.RemoveAt(oldSourceIndex); - _sourceCopy.Insert(newSourceIndex, (TSource)args.NewItems[0]); - - int currentDestinationIndex = GetIndexFromSourceIndex(oldSourceIndex); - - MoveSourceIndexInMap(oldSourceIndex, newSourceIndex); - - if (currentDestinationIndex == -1) - { - return; - } - - TValue value = base[currentDestinationIndex]; - - if (_orderer == null) - { - // We mirror the order of the source collection so we'll perform the same move operation - // as the source. As is the case with when we have an orderer we don't test whether or not - // the item should be included or not here. If it has been included at some point it'll - // stay included until onItemChanged picks up a change which filters it. - int newDestinationIndex = NewPositionForExistingItem( - _indexToSourceIndexMap, newSourceIndex, currentDestinationIndex); - - if (newDestinationIndex != currentDestinationIndex) - { - _indexToSourceIndexMap.RemoveAt(currentDestinationIndex); - _indexToSourceIndexMap.Insert(newDestinationIndex, newSourceIndex); - - InternalMove(currentDestinationIndex, newDestinationIndex); - } - else - { - _indexToSourceIndexMap[currentDestinationIndex] = newSourceIndex; - } - } - else - { - // TODO: Conceptually I feel like we shouldn't concern ourselves with ordering when we - // receive a Move notification. If it affects ordering it should be picked up by the - // onItemChange and resorted there instead. - _indexToSourceIndexMap[currentDestinationIndex] = newSourceIndex; - } - - return; - } - - if (args.OldItems != null) - { - _sourceCopy.RemoveRange(args.OldStartingIndex, args.OldItems.Count); - - for (int i = 0; i < args.OldItems.Count; i++) - { - int destinationIndex = GetIndexFromSourceIndex(args.OldStartingIndex + i); - if (destinationIndex != -1) - { - InternalRemoveAt(destinationIndex); - } - } - - int removedCount = args.OldItems.Count; - ShiftIndicesAtOrOverThreshold(args.OldStartingIndex + removedCount, -removedCount); - } - - if (args.NewItems != null) - { - ShiftIndicesAtOrOverThreshold(args.NewStartingIndex, args.NewItems.Count); - - for (int i = 0; i < args.NewItems.Count; i++) - { - var sourceItem = (TSource)args.NewItems[i]; - _sourceCopy.Insert(args.NewStartingIndex + i, sourceItem); - - if (!_filter(sourceItem)) - { - continue; - } - - var destinationItem = _selector(sourceItem); - InternalInsertAndMap(args.NewStartingIndex + i, destinationItem); - } - } - } - - /// - /// Increases (or decreases depending on move direction) all source indices between the source and destination - /// move indices. - /// - /// The old source index. - /// The new source index. - private void MoveSourceIndexInMap(int oldSourceIndex, int newSourceIndex) - { - if (newSourceIndex > oldSourceIndex) - { - // Item is moving towards the end of the list, everything between its current position and its - // new position needs to be shifted down one index - ShiftSourceIndicesInRange(oldSourceIndex + 1, newSourceIndex + 1, -1); - } - else - { - // Item is moving towards the front of the list, everything between its current position and its - // new position needs to be shifted up one index - ShiftSourceIndicesInRange(newSourceIndex, oldSourceIndex, 1); - } - } - - /// - /// Increases (or decreases) all source indices equal to or higher than the threshold. Represents an - /// insert or remove of one or more items in the source list thus causing all subsequent items to shift - /// up or down. - /// - /// The threshold. - /// The value. - private void ShiftIndicesAtOrOverThreshold(int threshold, int value) - { - for (int i = 0; i < _indexToSourceIndexMap.Count; i++) - { - if (_indexToSourceIndexMap[i] >= threshold) - { - _indexToSourceIndexMap[i] += value; - } - } - } - - /// - /// Increases (or decreases) all source indices within the range (lower inclusive, upper exclusive). - /// - /// The start of the range. - /// The end of the range. - /// The value. - private void ShiftSourceIndicesInRange(int rangeStart, int rangeStop, int value) - { - for (int i = 0; i < _indexToSourceIndexMap.Count; i++) - { - int sourceIndex = _indexToSourceIndexMap[i]; - if (sourceIndex >= rangeStart && sourceIndex < rangeStop) - { - _indexToSourceIndexMap[i] += value; - } - } - } - - public override void Reset() - { - using (SuppressChangeNotifications()) - { - InternalClear(); - AddAllItemsFromSourceCollection(); - } - } - - private void AddAllItemsFromSourceCollection() - { - Debug.Assert(_sourceCopy.Count == 0, "Expceted source copy to be empty"); - - int sourceIndex = 0; - - foreach (TSource sourceItem in _source) - { - _sourceCopy.Add(sourceItem); - - if (_filter(sourceItem)) - { - var destinationItem = _selector(sourceItem); - InternalInsertAndMap(sourceIndex, destinationItem); - } - - sourceIndex++; - } - } - - protected override void InternalClear() - { - _indexToSourceIndexMap.Clear(); - _sourceCopy.Clear(); - var items = this.ToArray(); - - base.InternalClear(); - - foreach (var item in items) - { - _onRemoved(item); - } - } - - private void InternalInsertAndMap(int sourceIndex, TValue value) - { - int destinationIndex = PositionForNewItem(sourceIndex, value); - - _indexToSourceIndexMap.Insert(destinationIndex, sourceIndex); - InternalInsert(destinationIndex, value); - } - - protected override void InternalRemoveAt(int destinationIndex) - { - _indexToSourceIndexMap.RemoveAt(destinationIndex); - var item = this[destinationIndex]; - base.InternalRemoveAt(destinationIndex); - _onRemoved(item); - } - - /// - /// Internal equality comparer used for looking up the source object of a property change notification in - /// the source list. - /// - /// The type for comparison. - private class ReferenceEqualityComparer : IEqualityComparer - { - public static readonly ReferenceEqualityComparer Default = new ReferenceEqualityComparer(); - - public bool Equals(T x, T y) - { - return ReferenceEquals(x, y); - } - - public int GetHashCode(T obj) - { - return RuntimeHelpers.GetHashCode(obj); - } - } - - private int PositionForNewItem(int sourceIndex, TValue value) - { - // If we haven't got an orderer we'll simply match our items to that of the source collection. - return _orderer == null - ? PositionForNewItem(_indexToSourceIndexMap, sourceIndex, Comparer.Default.Compare) - : PositionForNewItem(this, 0, Count, value, _orderer); - } - - internal static int PositionForNewItem(IList list, T item, Func orderer) - { - return PositionForNewItem(list, 0, list.Count, item, orderer); - } - - internal static int PositionForNewItem( - IList list, int index, int count, T item, Func orderer) - { - Debug.Assert(index >= 0); - Debug.Assert(count >= 0); - Debug.Assert(list.Count - index >= count); - - if (count == 0) - { - return index; - } - - if (count == 1) - { - return orderer(list[index], item) >= 0 ? index : index + 1; - } - - if (orderer(list[index], item) >= 1) - { - return index; - } - - int low = index, hi = index + count - 1; - int mid, cmp; - - while (low <= hi) - { - mid = low + (hi - low) / 2; - cmp = orderer(list[mid], item); - - if (cmp == 0) - { - return mid; - } - - if (cmp < 0) - { - low = mid + 1; - } - else - { - hi = mid - 1; - } - } - - return low; - } - - /// - /// Calculates a new destination for an updated item that's already in the list. - /// - /// The source index. - /// The current index. - /// The item. - private int NewPositionForExistingItem(int sourceIndex, int currentIndex, TValue item) - { - // If we haven't got an orderer we'll simply match our items to that of the source collection. - return _orderer == null - ? NewPositionForExistingItem(_indexToSourceIndexMap, sourceIndex, currentIndex) - : NewPositionForExistingItem(this, item, currentIndex, _orderer); - } - - /// - /// Calculates a new destination for an updated item that's already in the list. - /// - /// The list type. - /// The list. - /// The item. - /// The current index. - /// The order. - internal static int NewPositionForExistingItem( - IList list, T item, int currentIndex, Func orderer = null) - { - // Since the item changed is most likely a value type we must refrain from ever comparing it to itself. - // We do this by figuring out how the updated item compares to its neighbors. By knowing if it's - // less than or greater than either one of its neighbors we can limit the search range to a range exlusive - // of the current index. - Debug.Assert(list.Count > 0); - - if (list.Count == 1) - { - return 0; - } - - int precedingIndex = currentIndex - 1; - int succeedingIndex = currentIndex + 1; - - // The item on the preceding or succeeding index relative to currentIndex. - T comparand = list[precedingIndex >= 0 ? precedingIndex : succeedingIndex]; - - if (orderer == null) - { - orderer = Comparer.Default.Compare; - } - - // Compare that to the (potentially) new value. - int cmp = orderer(item, comparand); - - int min = 0; - int max = list.Count; - - if (cmp == 0) - { - // The new value is equal to the preceding or succeeding item, it may stay at the current position - return currentIndex; - } - else if (cmp > 0) - { - // The new value is greater than the preceding or succeeding item, limit the search to indices after - // the succeeding item. - min = succeedingIndex; - } - else - { - // The new value is less than the preceding or succeeding item, limit the search to indices before - // the preceding item. - max = precedingIndex; - } - - // Bail if the search range is invalid. - if (min == list.Count || max < 0) - { - return currentIndex; - } - - int ix = PositionForNewItem(list, min, max - min, item, orderer); - - // If the item moves 'forward' in the collection we have to account for the index where - // the item currently resides getting removed first. - return ix >= currentIndex ? ix - 1 : ix; - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - var disp = Interlocked.Exchange(ref _inner, null); - if (disp == null) - { - return; - } - - disp.Dispose(); - } - } - } - - /// - /// This class represents a change-notifying Collection which is derived from - /// a source collection, via CreateDerivedCollection or via another method. - /// It is read-only, and any attempts to change items in the collection will - /// fail. - /// - /// The value type. - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - internal abstract class ReactiveDerivedCollection : ReactiveList, IReactiveDerivedList, IDisposable - { - private const string ReadonlyExceptionMessage = "Derived collections cannot be modified."; - - public override bool IsReadOnly => true; - - public override TValue this[int index] - { - get => base[index]; - set => throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - public override void Add(TValue item) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalAdd(TValue item) - { - base.Add(item); - } - - public override void AddRange(IEnumerable collection) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalAddRange(IEnumerable collection) - { - base.AddRange(collection); - } - - public override void Clear() - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalClear() - { - base.Clear(); - } - - public override void Insert(int index, TValue item) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalInsert(int index, TValue item) - { - base.Insert(index, item); - } - - public override void InsertRange(int index, IEnumerable collection) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalInsertRange(int index, IEnumerable collection) - { - base.InsertRange(index, collection); - } - - public override bool Remove(TValue item) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual bool InternalRemove(TValue item) - { - return base.Remove(item); - } - - public override void RemoveAll(IEnumerable items) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalRemoveAll(IEnumerable items) - { - base.RemoveAll(items); - } - - public override void RemoveAt(int index) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalRemoveAt(int index) - { - base.RemoveAt(index); - } - - public override void Move(int oldIndex, int newIndex) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalMove(int oldIndex, int newIndex) - { - base.Move(oldIndex, newIndex); - } - - public override void RemoveRange(int index, int count) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalRemoveRange(int index, int count) - { - base.RemoveRange(index, count); - } - - public override void Sort(Comparison comparison) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalSort(Comparison comparison) - { - base.Sort(comparison); - } - - public override void Sort(IComparer comparer = null) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalSort(IComparer comparer = null) - { - base.Sort(comparer); - } - - public override void Sort(int index, int count, IComparer comparer) - { - throw new InvalidOperationException(ReadonlyExceptionMessage); - } - - protected virtual void InternalSort(int index, int count, IComparer comparer) - { - base.Sort(index, count, comparer); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - } - } -} diff --git a/src/ReactiveUI/Legacy/ReactiveDerivedCollectionFromObservable.cs b/src/ReactiveUI/Legacy/ReactiveDerivedCollectionFromObservable.cs deleted file mode 100644 index 9897c8ea6..000000000 --- a/src/ReactiveUI/Legacy/ReactiveDerivedCollectionFromObservable.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Reactive.Concurrency; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Threading; - -namespace ReactiveUI.Legacy -{ - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - internal class ReactiveDerivedCollectionFromObservable : ReactiveDerivedCollection - { - private SingleAssignmentDisposable _inner; - - public ReactiveDerivedCollectionFromObservable( - IObservable observable, - TimeSpan? withDelay = null, - Action onError = null, - IScheduler scheduler = null) - { - scheduler = scheduler ?? RxApp.MainThreadScheduler; - _inner = new SingleAssignmentDisposable(); - - onError = onError ?? (ex => RxApp.DefaultExceptionHandler.OnNext(ex)); - if (withDelay == null) - { - _inner.Disposable = observable.ObserveOn(scheduler).Subscribe(InternalAdd, onError); - return; - } - - // On a timer, dequeue items from queue if they are available - var queue = new Queue(); - var disconnect = Observable.Timer(withDelay.Value, withDelay.Value, scheduler) - .Subscribe(_ => - { - if (queue.Count > 0) - { - InternalAdd(queue.Dequeue()); - } - }); - - _inner.Disposable = disconnect; - - // When new items come in from the observable, stuff them in the queue. - observable.ObserveOn(scheduler).Subscribe(queue.Enqueue, onError); - - // This is a bit clever - keep a running count of the items actually - // added and compare them to the final count of items provided by the - // Observable. Combine the two values, and when they're equal, - // disconnect the timer - ItemsAdded.Scan(0, (acc, _) => acc + 1).Zip( - observable.Aggregate(0, (acc, _) => acc + 1), - (l, r) => l == r).Where(x => x).Subscribe(_ => disconnect.Dispose()); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - var disp = Interlocked.Exchange(ref _inner, null); - if (disp == null) - { - return; - } - - disp.Dispose(); - } - } - } -} diff --git a/src/ReactiveUI/Legacy/ReactiveList.cs b/src/ReactiveUI/Legacy/ReactiveList.cs deleted file mode 100644 index 0ad4ebb8d..000000000 --- a/src/ReactiveUI/Legacy/ReactiveList.cs +++ /dev/null @@ -1,1084 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.ComponentModel; -using System.Diagnostics; -using System.Globalization; -using System.Linq; -using System.Reactive; -using System.Reactive.Concurrency; -using System.Reactive.Disposables; -using System.Reactive.Linq; -using System.Reactive.Subjects; -using System.Runtime.Serialization; -using System.Threading; -using Splat; - -#pragma warning disable SA1600 // Elements should be documented -- not used for legacy -#pragma warning disable SA1201 // Ordering -- not used for legacy -#pragma warning disable SA1202 // Ordering -- not used for legacy -#pragma warning disable SA1124 // Do not use regions -- not used for legacy -#pragma warning disable RCS1165 // Unconstrained null check -- not used for legacy -#pragma warning disable CA1001 // Undisposed type -- not used for legacy -#pragma warning disable CA1062 // null check - -namespace ReactiveUI.Legacy -{ - [DebuggerDisplay("Count = {Count}")] - [DebuggerTypeProxy(typeof(CollectionDebugView<>))] - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public class ReactiveList : IReactiveList, IReadOnlyReactiveList, IList - { -#if NET_461 - /// - public event NotifyCollectionChangedEventHandler CollectionChanging; - - protected virtual void RaiseCollectionChanging(NotifyCollectionChangedEventArgs args) - { - // WPF doesn't seem to care much about Range notifications in this case, - // so we'll just pass those right through - CollectionChanging?.Invoke(this, args); - } - - /// - public event NotifyCollectionChangedEventHandler CollectionChanged; - - protected virtual void RaiseCollectionChanged(NotifyCollectionChangedEventArgs args) - { - // WPF throws "Range actions are not supported" under - // certain circumstances, so we catch those here first - CollectionChanged?.Invoke(this, ReplaceIfUnsupported(args)); - } - - private static NotifyCollectionChangedEventArgs ReplaceIfUnsupported(NotifyCollectionChangedEventArgs args) - { - // see System.Windows.Data.ListCollectionView.ValidateCollectionChangedEventArgs - switch (args.Action) - { - case NotifyCollectionChangedAction.Add when args.NewItems.Count != 1: - case NotifyCollectionChangedAction.Remove when args.OldItems.Count != 1: - case NotifyCollectionChangedAction.Replace when args.NewItems.Count != 1 || args.OldItems.Count != 1: - case NotifyCollectionChangedAction.Move when args.NewItems.Count != 1: - return new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); - default: - return args; - } - } - - /// - public event PropertyChangingEventHandler PropertyChanging; - - /// - void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) - { - var handler = PropertyChanging; - if (handler != null) - { - handler(this, args); - } - } - - /// - public event PropertyChangedEventHandler PropertyChanged; - - /// - void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) - { - var handler = PropertyChanged; - if (handler != null) - { - handler(this, args); - } - } -#else - /// - public event NotifyCollectionChangedEventHandler CollectionChanging - { - add => CollectionChangingEventManager.AddHandler(this, value); - remove => CollectionChangingEventManager.RemoveHandler(this, value); - } - - /// - public event NotifyCollectionChangedEventHandler CollectionChanged - { - add => CollectionChangedEventManager.AddHandler(this, value); - remove => CollectionChangedEventManager.RemoveHandler(this, value); - } - - /// - public event PropertyChangingEventHandler PropertyChanging - { - add => PropertyChangingEventManager.AddHandler(this, value); - remove => PropertyChangingEventManager.RemoveHandler(this, value); - } - - /// - public event PropertyChangedEventHandler PropertyChanged - { - add => PropertyChangedEventManager.AddHandler(this, value); - remove => PropertyChangedEventManager.RemoveHandler(this, value); - } - - protected virtual void RaiseCollectionChanging(NotifyCollectionChangedEventArgs args) - { - CollectionChangingEventManager.DeliverEvent(this, args); - } - - protected virtual void RaiseCollectionChanged(NotifyCollectionChangedEventArgs args) - { - CollectionChangedEventManager.DeliverEvent(this, args); - } - - /// - void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args) - { - PropertyChangingEventManager.DeliverEvent(this, args); - } - - /// - void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) - { - PropertyChangedEventManager.DeliverEvent(this, args); - } -#endif - - private static bool _hasWhinedAboutNoResetSub; - [IgnoreDataMember] - private Subject _changing; - [IgnoreDataMember] - private Subject _changed; - - [DataMember] - private List _inner; - - [IgnoreDataMember] - private Lazy> _beforeItemsAdded; - [IgnoreDataMember] - private Lazy> _itemsAdded; - [IgnoreDataMember] - private Lazy> _beforeItemsRemoved; - [IgnoreDataMember] - private Lazy> _itemsRemoved; - [IgnoreDataMember] - private Lazy>> _itemChanging; - [IgnoreDataMember] - private Lazy>> _itemChanged; - [IgnoreDataMember] - private Lazy>> _beforeItemsMoved; - [IgnoreDataMember] - private Lazy>> _itemsMoved; - - [IgnoreDataMember] - private Dictionary _propertyChangeWatchers; - - [IgnoreDataMember] - private int _resetSubCount; - [IgnoreDataMember] - private int _resetNotificationCount; - - [IgnoreDataMember] - public double ResetChangeThreshold { get; set; } - - // NB: This exists so the serializer doesn't whine - // - // 2nd NB: VB.NET doesn't deal well with default parameters, create - // some overloads so people can continue to make bad life choices instead - // of using C# - public ReactiveList() - { - SetupRx(); - } - - public ReactiveList(IEnumerable initialContents) - { - SetupRx(initialContents); - } - - public ReactiveList(IEnumerable initialContents = null, double resetChangeThreshold = 0.3, IScheduler scheduler = null) - { - SetupRx(initialContents, resetChangeThreshold, scheduler); - } - - [OnDeserialized] - private void SetupRx(StreamingContext context) - { - SetupRx(); - } - - private void SetupRx(IEnumerable initialContents = null, double resetChangeThreshold = 0.3, IScheduler scheduler = null) - { - scheduler = scheduler ?? RxApp.MainThreadScheduler; - - _inner = _inner ?? new List(); - - _changing = new Subject(); - _changing.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(RaiseCollectionChanging); - - _changed = new Subject(); - _changed.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(RaiseCollectionChanged); - - ResetChangeThreshold = resetChangeThreshold; - - _beforeItemsAdded = new Lazy>(() => new Subject()); - _itemsAdded = new Lazy>(() => new Subject()); - _beforeItemsRemoved = new Lazy>(() => new Subject()); - _itemsRemoved = new Lazy>(() => new Subject()); - _itemChanging = new Lazy>>(() => new ScheduledSubject>(scheduler)); - _itemChanged = new Lazy>>(() => new ScheduledSubject>(scheduler)); - _beforeItemsMoved = new Lazy>>(() => new Subject>()); - _itemsMoved = new Lazy>>(() => new Subject>()); - - // NB: We have to do this instead of initializing _inner so that - // Collection's accounting is correct - foreach (var item in initialContents ?? Enumerable.Empty()) - { - Add(item); - } - - // NB: ObservableCollection has a Secret Handshake with WPF where - // they fire an INPC notification with the token "Item[]". Emulate - // it here - CountChanging.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanging(nameof(Count))); - - CountChanged.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged(nameof(Count))); - - IsEmptyChanged.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged(nameof(IsEmpty))); - - Changing.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanging("Item[]")); - - Changed.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("Item[]")); - } - - /// - public bool IsEmpty => Count == 0; - - /* - * Collection core methods - */ - - protected void InsertItem(int index, T item) - { - if (!this.AreChangeNotificationsEnabled()) - { - _inner.Insert(index, item); - - if (ChangeTrackingEnabled) - { - AddItemToPropertyTracking(item); - } - - return; - } - - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index); - - _changing.OnNext(ea); - if (_beforeItemsAdded.IsValueCreated) - { - _beforeItemsAdded.Value.OnNext(item); - } - - _inner.Insert(index, item); - - _changed.OnNext(ea); - if (_itemsAdded.IsValueCreated) - { - _itemsAdded.Value.OnNext(item); - } - - if (ChangeTrackingEnabled) - { - AddItemToPropertyTracking(item); - } - } - - protected void RemoveItem(int index) - { - var item = _inner[index]; - - if (!this.AreChangeNotificationsEnabled()) - { - _inner.RemoveAt(index); - - if (ChangeTrackingEnabled) - { - RemoveItemFromPropertyTracking(item); - } - - return; - } - - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index); - - _changing.OnNext(ea); - if (_beforeItemsRemoved.IsValueCreated) - { - _beforeItemsRemoved.Value.OnNext(item); - } - - _inner.RemoveAt(index); - - _changed.OnNext(ea); - if (_itemsRemoved.IsValueCreated) - { - _itemsRemoved.Value.OnNext(item); - } - - if (ChangeTrackingEnabled) - { - RemoveItemFromPropertyTracking(item); - } - } - - protected void MoveItem(int oldIndex, int newIndex) - { - var item = _inner[oldIndex]; - - if (!this.AreChangeNotificationsEnabled()) - { - _inner.RemoveAt(oldIndex); - _inner.Insert(newIndex, item); - - return; - } - - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, item, newIndex, oldIndex); - var mi = new MoveInfo(new[] { item }, oldIndex, newIndex); - - _changing.OnNext(ea); - if (_beforeItemsMoved.IsValueCreated) - { - _beforeItemsMoved.Value.OnNext(mi); - } - - _inner.RemoveAt(oldIndex); - _inner.Insert(newIndex, item); - - _changed.OnNext(ea); - if (_itemsMoved.IsValueCreated) - { - _itemsMoved.Value.OnNext(mi); - } - } - - protected void SetItem(int index, T item) - { - if (!this.AreChangeNotificationsEnabled()) - { - if (ChangeTrackingEnabled) - { - RemoveItemFromPropertyTracking(_inner[index]); - AddItemToPropertyTracking(item); - } - - _inner[index] = item; - - return; - } - - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, item, _inner[index], index); - - _changing.OnNext(ea); - - if (ChangeTrackingEnabled) - { - RemoveItemFromPropertyTracking(_inner[index]); - AddItemToPropertyTracking(item); - } - - _inner[index] = item; - _changed.OnNext(ea); - } - - protected void ClearItems() - { - if (!this.AreChangeNotificationsEnabled()) - { - _inner.Clear(); - - if (ChangeTrackingEnabled) - { - ClearAllPropertyChangeWatchers(); - } - - return; - } - - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); - - _changing.OnNext(ea); - _inner.Clear(); - _changed.OnNext(ea); - - if (ChangeTrackingEnabled) - { - ClearAllPropertyChangeWatchers(); - } - } - - /* - * List methods we can make faster by possibly sending ShouldReset - * notifications instead of thrashing the UI by readding items - * one at a time - */ - - /// - public virtual void AddRange(IEnumerable collection) - { - if (collection == null) - { - throw new ArgumentNullException(nameof(collection)); - } - - // we need list to implement at least IEnumerable and IList - // because NotifyCollectionChangedEventArgs expects an IList - var list = collection as List ?? collection.ToList(); - var disp = IsLengthAboveResetThreshold(list.Count) - ? SuppressChangeNotifications() : Disposable.Empty; - - using (disp) - { - // reset notification - if (!this.AreChangeNotificationsEnabled()) - { - _inner.AddRange(list); - - if (ChangeTrackingEnabled) - { - foreach (var item in list) - { - AddItemToPropertyTracking(item); - } - } - } - - // range notification - else if (RxApp.SupportsRangeNotifications) - { - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, list, _inner.Count/*we are appending a range*/); - - _changing.OnNext(ea); - - if (_beforeItemsAdded.IsValueCreated) - { - foreach (var item in list) - { - _beforeItemsAdded.Value.OnNext(item); - } - } - - _inner.AddRange(list); - - _changed.OnNext(ea); - if (_itemsAdded.IsValueCreated) - { - foreach (var item in list) - { - _itemsAdded.Value.OnNext(item); - } - } - - if (ChangeTrackingEnabled) - { - foreach (var item in list) - { - AddItemToPropertyTracking(item); - } - } - } - else - { - // per item notification - foreach (var item in list) - { - Add(item); - } - } - } - } - - /// - public virtual void InsertRange(int index, IEnumerable collection) - { - if (collection == null) - { - throw new ArgumentNullException(nameof(collection)); - } - - // we need list to implement at least IEnumerable and IList - // because NotifyCollectionChangedEventArgs expects an IList - var list = collection as List ?? collection.ToList(); - var disp = IsLengthAboveResetThreshold(list.Count) ? - SuppressChangeNotifications() : Disposable.Empty; - - using (disp) - { - // reset notification - if (!this.AreChangeNotificationsEnabled()) - { - _inner.InsertRange(index, list); - - if (ChangeTrackingEnabled) - { - foreach (var item in list) - { - AddItemToPropertyTracking(item); - } - } - } - - // range notification - else if (RxApp.SupportsRangeNotifications) - { - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, list, index); - - _changing.OnNext(ea); - if (_beforeItemsAdded.IsValueCreated) - { - foreach (var item in list) - { - _beforeItemsAdded.Value.OnNext(item); - } - } - - _inner.InsertRange(index, list); - - _changed.OnNext(ea); - if (_itemsAdded.IsValueCreated) - { - foreach (var item in list) - { - _itemsAdded.Value.OnNext(item); - } - } - - if (ChangeTrackingEnabled) - { - foreach (var item in list) - { - AddItemToPropertyTracking(item); - } - } - } - else - { - // per item notification - foreach (var item in list) - { - Insert(index++, item); - } - } - } - } - - /// - public virtual void RemoveRange(int index, int count) - { - var disp = IsLengthAboveResetThreshold(count) ? - SuppressChangeNotifications() : Disposable.Empty; - - using (disp) - { - var items = new List(count); - - foreach (var i in Enumerable.Range(index, count)) - { - items.Add(_inner[i]); - } - - // reset notification - if (!this.AreChangeNotificationsEnabled()) - { - _inner.RemoveRange(index, count); - - if (ChangeTrackingEnabled) - { - foreach (var item in items) - { - RemoveItemFromPropertyTracking(item); - } - } - } - - // range notification - else if (RxApp.SupportsRangeNotifications) - { - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, items, index); - - _changing.OnNext(ea); - if (_beforeItemsRemoved.IsValueCreated) - { - foreach (var item in items) - { - _beforeItemsRemoved.Value.OnNext(item); - } - } - - _inner.RemoveRange(index, count); - _changed.OnNext(ea); - - if (ChangeTrackingEnabled) - { - foreach (var item in items) - { - RemoveItemFromPropertyTracking(item); - } - } - - if (_itemsRemoved.IsValueCreated) - { - foreach (var item in items) - { - _itemsRemoved.Value.OnNext(item); - } - } - } - else - { - // per item notification - foreach (var item in items) - { - Remove(item); - } - } - } - } - - /// - public virtual void RemoveAll(IEnumerable items) - { - if (items == null) - { - throw new ArgumentNullException(nameof(items)); - } - - var disp = IsLengthAboveResetThreshold(items.Count()) ? - SuppressChangeNotifications() : Disposable.Empty; - - using (disp) - { - // NB: If we don't do this, we'll break Collection's - // accounting of the length - foreach (var v in items) - { - Remove(v); - } - } - } - - /// - public virtual void Sort(int index, int count, IComparer comparer) - { - _inner.Sort(index, count, comparer); - Reset(); - } - - /// - public virtual void Sort(Comparison comparison) - { - _inner.Sort(comparison); - Reset(); - } - - /// - public virtual void Sort(IComparer comparer = null) - { - _inner.Sort(comparer ?? Comparer.Default); - Reset(); - } - - /// - public virtual void Reset() - { - var ea = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); - _changing.OnNext(ea); - _changed.OnNext(ea); - } - - private bool IsLengthAboveResetThreshold(int toChangeLength) - { - return (double)toChangeLength / _inner.Count > ResetChangeThreshold && - toChangeLength > 10; - } - - /* - * IReactiveCollection - */ - - /// - public bool ChangeTrackingEnabled - { - get => _propertyChangeWatchers != null; - set - { - if (_propertyChangeWatchers != null && value) - { - return; - } - - if (_propertyChangeWatchers == null && !value) - { - return; - } - - if (value) - { - _propertyChangeWatchers = new Dictionary(); - foreach (var item in _inner) - { - AddItemToPropertyTracking(item); - } - } - else - { - ClearAllPropertyChangeWatchers(); - _propertyChangeWatchers = null; - } - } - } - - /// - public IDisposable SuppressChangeNotifications() - { - NotifyCollectionChangedEventArgs resetEventArgs = null; - - if (Interlocked.Increment(ref _resetNotificationCount) == 1) - { - // Changes were not suppressed before, publish a Changing reset notification. - resetEventArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); - _changing.OnNext(resetEventArgs); - } - - if (!_hasWhinedAboutNoResetSub && _resetSubCount == 0) - { - LogHost.Default.Warn("SuppressChangeNotifications was called (perhaps via AddRange), yet you do not"); - LogHost.Default.Warn("have a subscription to ShouldReset. This probably isn't what you want, as ItemsAdded"); - LogHost.Default.Warn("and friends will appear to 'miss' items"); - _hasWhinedAboutNoResetSub = true; - } - - return new CompositeDisposable(IReactiveObjectExtensions.SuppressChangeNotifications(this), Disposable.Create(() => - { - if (Interlocked.Decrement(ref _resetNotificationCount) == 0) - { - if (resetEventArgs == null) - { - resetEventArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); - } - - _changed.OnNext(resetEventArgs); - } - })); - } - - /// - public IObservable BeforeItemsAdded => _beforeItemsAdded.Value; - - /// - public IObservable ItemsAdded => _itemsAdded.Value; - - /// - public IObservable BeforeItemsRemoved => _beforeItemsRemoved.Value; - - /// - public IObservable ItemsRemoved => _itemsRemoved.Value; - - /// - public IObservable> BeforeItemsMoved => _beforeItemsMoved.Value; - - /// - public IObservable> ItemsMoved => _itemsMoved.Value; - - /// - public IObservable> ItemChanging => _itemChanging.Value; - - /// - public IObservable> ItemChanged => _itemChanged.Value; - - /// - public IObservable CountChanging - { - get { return _changing.Select(_ => _inner.Count).DistinctUntilChanged(); } - } - - /// - public IObservable CountChanged - { - get { return _changed.Select(_ => _inner.Count).DistinctUntilChanged(); } - } - - /// - public IObservable IsEmptyChanged - { - get { return _changed.Select(_ => _inner.Count == 0).DistinctUntilChanged(); } - } - - /// - public IObservable Changing => _changing; - - /// - public IObservable Changed => _changed; - - /// - public IObservable ShouldReset - { - get - { - return RefcountSubscribers( - _changed.SelectMany(x => - x.Action != NotifyCollectionChangedAction.Reset ? - Observable.Empty : - Observables.Unit), x => _resetSubCount += x); - } - } - - /* - * Property Change Tracking - */ - - private static IObservable RefcountSubscribers(IObservable input, Action block) - { - return Observable.Create(subj => - { - block(1); - - return new CompositeDisposable( - input.Subscribe(subj), - Disposable.Create(() => block(-1))); - }); - } - - private void AddItemToPropertyTracking(T toTrack) - { - if (_propertyChangeWatchers.ContainsKey(toTrack)) - { - _propertyChangeWatchers[toTrack].AddRef(); - return; - } - - var changing = Observable>.Never; - var changed = Observable>.Never; - var ro = toTrack as IReactiveObject; - if (ro != null) - { - changing = ro.GetChangingObservable().Select(i => new ReactivePropertyChangingEventArgs(toTrack, i.PropertyName)); - changed = ro.GetChangedObservable().Select(i => new ReactivePropertyChangedEventArgs(toTrack, i.PropertyName)); - goto isSetup; - } - - var inpc = toTrack as INotifyPropertyChanged; - if (inpc != null) - { - changed = Observable.FromEventPattern(x => inpc.PropertyChanged += x, x => inpc.PropertyChanged -= x) - .Select(x => new ReactivePropertyChangedEventArgs(toTrack, x.EventArgs.PropertyName)); - goto isSetup; - } - - this.Log().Warn(CultureInfo.InvariantCulture, "Property change notifications are enabled and type {0} isn't INotifyPropertyChanged or IReactiveObject", typeof(T)); - - isSetup: - var toDispose = new[] - { - changing.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_itemChanging.Value.OnNext), - changed.Where(_ => this.AreChangeNotificationsEnabled()).Subscribe(_itemChanged.Value.OnNext), - }; - - _propertyChangeWatchers.Add( - toTrack, - new RefcountDisposeWrapper(Disposable.Create(() => - { - toDispose[0].Dispose(); - toDispose[1].Dispose(); - _propertyChangeWatchers.Remove(toTrack); - }))); - } - - private void RemoveItemFromPropertyTracking(T toUntrack) - { - _propertyChangeWatchers[toUntrack].Release(); - } - - private void ClearAllPropertyChangeWatchers() - { - while (_propertyChangeWatchers.Count > 0) - { - _propertyChangeWatchers.Values.First().Release(); - } - } - - #region Super Boring IList crap - - // The BinarySearch methods aren't technically on IList, they're implemented straight on List - // but by proxying this call we can make use of the nice built in methods that operate on the internal - // array of the inner list instead of jumping around proxying through the index. - public int BinarySearch(T item) - { - return _inner.BinarySearch(item); - } - - public int BinarySearch(T item, IComparer comparer) - { - return _inner.BinarySearch(item, comparer); - } - - public int BinarySearch(int index, int count, T item, IComparer comparer) - { - return _inner.BinarySearch(index, count, item, comparer); - } - - /// - public IEnumerator GetEnumerator() - { - return _inner.GetEnumerator(); - } - - /// - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - /// - public virtual void Add(T item) - { - InsertItem(_inner.Count, item); - } - - /// - public virtual void Clear() - { - ClearItems(); - } - - /// - public bool Contains(T item) - { - return _inner.Contains(item); - } - - /// - public void CopyTo(T[] array, int arrayIndex) - { - _inner.CopyTo(array, arrayIndex); - } - - /// - public virtual bool Remove(T item) - { - int index = _inner.IndexOf(item); - if (index < 0) - { - return false; - } - - RemoveItem(index); - return true; - } - - /// - public int Count => _inner.Count; - - /// - public virtual bool IsReadOnly => false; - - /// - public int IndexOf(T item) - { - return _inner.IndexOf(item); - } - - /// - public virtual void Insert(int index, T item) - { - InsertItem(index, item); - } - - /// - public virtual void RemoveAt(int index) - { - RemoveItem(index); - } - - public virtual void Move(int oldIndex, int newIndex) - { - MoveItem(oldIndex, newIndex); - } - - /// - public virtual T this[int index] - { - get => _inner[index]; - set => SetItem(index, value); - } - - /// - int IList.Add(object value) - { - Add((T)value); - return Count - 1; - } - - /// - bool IList.Contains(object value) - { - return IsCompatibleObject(value) && Contains((T)value); - } - - /// - int IList.IndexOf(object value) - { - return IsCompatibleObject(value) ? IndexOf((T)value) : -1; - } - - /// - void IList.Insert(int index, object value) - { - Insert(index, (T)value); - } - - /// - bool IList.IsFixedSize => false; - - /// - void IList.Remove(object value) - { - if (IsCompatibleObject(value)) - { - Remove((T)value); - } - } - - /// - object IList.this[int index] - { - get => this[index]; - set => this[index] = (T)value; - } - - /// - void ICollection.CopyTo(Array array, int index) - { - ((IList)_inner).CopyTo(array, index); - } - - /// - bool ICollection.IsSynchronized => false; - - /// - object ICollection.SyncRoot => this; - - private static bool IsCompatibleObject(object value) - { - return (value is T) || ((value == null) && (default(T) == null)); - } - #endregion - } -} - -// vim: tw=120 ts=4 sw=4 et : diff --git a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs index 6d4cb2eea..15c51860f 100644 --- a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs +++ b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs @@ -32,7 +32,8 @@ public static void InitializeReactiveUI(this IMutableDependencyResolver resolver "ReactiveUI.XamForms", "ReactiveUI.Winforms", "ReactiveUI.Wpf", - "ReactiveUI.Uno" + "ReactiveUI.Uno", + "ReactiveUI.Blazor" }; // Set up the built-in registration @@ -100,12 +101,8 @@ private static void RegisterType(IMutableDependencyResolver resolver, TypeInfo t [SuppressMessage("Redundancy", "CA1801: Redundant parameter", Justification = "Used on some platforms")] private static Func TypeFactory(TypeInfo typeInfo) { -#if PORTABLE && !WASM - throw new Exception("You are referencing the Portable version of ReactiveUI in an App. Reference the platform-specific version."); -#else return Expression.Lambda>(Expression.New( typeInfo.DeclaredConstructors.First(ci => ci.IsPublic && !ci.GetParameters().Any()))).Compile(); -#endif } [SuppressMessage("Globalization", "CA1307: operator could change based on locale settings", Justification = "Replace() does not have third parameter on all platforms")] diff --git a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs index 7f8f28733..f66cecc94 100644 --- a/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs +++ b/src/ReactiveUI/Mixins/ReactiveNotifyPropertyChangedMixin.cs @@ -19,16 +19,16 @@ namespace ReactiveUI /// public static class ReactiveNotifyPropertyChangedMixin { - private static readonly MemoizingMRUCache, ICreatesObservableForProperty> notifyFactoryCache = - new MemoizingMRUCache, ICreatesObservableForProperty>( + private static readonly MemoizingMRUCache<(Type senderType, string propertyName, bool beforeChange), ICreatesObservableForProperty> notifyFactoryCache = + new MemoizingMRUCache<(Type senderType, string propertyName, bool beforeChange), ICreatesObservableForProperty>( (t, _) => { return Locator.Current.GetServices() - .Aggregate(Tuple.Create(0, (ICreatesObservableForProperty)null), (acc, x) => + .Aggregate((score: 0, binding: (ICreatesObservableForProperty)null), (acc, x) => { - int score = x.GetAffinityForObject(t.Item1, t.Item2, t.Item3); - return score > acc.Item1 ? Tuple.Create(score, x) : acc; - }).Item2; + int score = x.GetAffinityForObject(t.senderType, t.propertyName, t.beforeChange); + return score > acc.score ? (score, x) : acc; + }).binding; }, RxApp.BigCacheLimit); static ReactiveNotifyPropertyChangedMixin() @@ -210,7 +210,7 @@ private static IObservable> NestedObservedChange private static IObservable> NotifyForProperty(object sender, Expression expression, bool beforeChange, bool suppressWarnings) { var propertyName = expression.GetMemberInfo().Name; - var result = notifyFactoryCache.Get(Tuple.Create(sender.GetType(), propertyName, beforeChange)); + var result = notifyFactoryCache.Get((sender.GetType(), propertyName, beforeChange)); if (result == null) { @@ -221,5 +221,3 @@ private static IObservable> NotifyForProperty(ob } } } - -// vim: tw=120 ts=4 sw=4 et : diff --git a/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs b/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs index 56f3588d5..f939fa534 100644 --- a/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs +++ b/src/ReactiveUI/ObservableForProperty/INPCObservableForProperty.cs @@ -43,34 +43,46 @@ public IObservable> GetNotificationForProperty(o if (beforeChanged) { - var obs = Observable.FromEventPattern( - x => before.PropertyChanging += x, x => before.PropertyChanging -= x); + var obs = Observable.FromEvent( + eventHandler => + { + void Handler(object eventSender, PropertyChangingEventArgs e) => eventHandler(e.PropertyName); + return Handler; + }, + x => before.PropertyChanging += x, + x => before.PropertyChanging -= x); if (expression.NodeType == ExpressionType.Index) { - return obs.Where(x => string.IsNullOrEmpty(x.EventArgs.PropertyName) - || x.EventArgs.PropertyName.Equals(propertyName + "[]", StringComparison.InvariantCulture)) + return obs.Where(x => string.IsNullOrEmpty(x) + || x.Equals(propertyName + "[]", StringComparison.InvariantCulture)) .Select(x => new ObservedChange(sender, expression)); } - return obs.Where(x => string.IsNullOrEmpty(x.EventArgs.PropertyName) - || x.EventArgs.PropertyName.Equals(propertyName, StringComparison.InvariantCulture)) + return obs.Where(x => string.IsNullOrEmpty(x) + || x.Equals(propertyName, StringComparison.InvariantCulture)) .Select(x => new ObservedChange(sender, expression)); } else { - var obs = Observable.FromEventPattern( - x => after.PropertyChanged += x, x => after.PropertyChanged -= x); + var obs = Observable.FromEvent( + eventHandler => + { + void Handler(object eventSender, PropertyChangedEventArgs e) => eventHandler(e.PropertyName); + return Handler; + }, + x => after.PropertyChanged += x, + x => after.PropertyChanged -= x); if (expression.NodeType == ExpressionType.Index) { - return obs.Where(x => string.IsNullOrEmpty(x.EventArgs.PropertyName) - || x.EventArgs.PropertyName.Equals(propertyName + "[]", StringComparison.InvariantCulture)) + return obs.Where(x => string.IsNullOrEmpty(x) + || x.Equals(propertyName + "[]", StringComparison.InvariantCulture)) .Select(x => new ObservedChange(sender, expression)); } - return obs.Where(x => string.IsNullOrEmpty(x.EventArgs.PropertyName) - || x.EventArgs.PropertyName.Equals(propertyName, StringComparison.InvariantCulture)) + return obs.Where(x => string.IsNullOrEmpty(x) + || x.Equals(propertyName, StringComparison.InvariantCulture)) .Select(x => new ObservedChange(sender, expression)); } } diff --git a/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs b/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs index 77f64447b..16e59faa3 100644 --- a/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs +++ b/src/ReactiveUI/Platforms/android/AndroidObservableForWidgets.cs @@ -22,7 +22,7 @@ namespace ReactiveUI /// public class AndroidObservableForWidgets : ICreatesObservableForProperty { - private static readonly IDictionary, Func>>> dispatchTable; + private static readonly IDictionary<(Type viewType, string propertyName), Func>>> dispatchTable; static AndroidObservableForWidgets() { @@ -37,7 +37,7 @@ static AndroidObservableForWidgets() CreateTimePickerHourFromWidget(), CreateTimePickerMinuteFromWidget(), CreateFromAdapterView(), - }.ToDictionary(k => Tuple.Create(k.Type, k.Property), v => v.Func); + }.ToDictionary(k => (viewType: k.Type, propertyName: k.Property), v => v.Func); } /// @@ -48,7 +48,7 @@ public int GetAffinityForObject(Type type, string propertyName, bool beforeChang return 0; } - return dispatchTable.Keys.Any(x => x.Item1.IsAssignableFrom(type) && x.Item2 == propertyName) ? 5 : 0; + return dispatchTable.Keys.Any(x => x.viewType.IsAssignableFrom(type) && x.propertyName == propertyName) ? 5 : 0; } /// @@ -60,35 +60,49 @@ public IObservable> GetNotificationForProperty(o } var type = sender.GetType(); - var tableItem = dispatchTable.Keys.First(x => x.Item1.IsAssignableFrom(type) && x.Item2 == propertyName); + var tableItem = dispatchTable.Keys.First(x => x.viewType.IsAssignableFrom(type) && x.propertyName == propertyName); return dispatchTable[tableItem](sender, expression); } - private static DispatchTuple CreateFromAdapterView() + private static DispatchItem CreateFromAdapterView() { // AdapterView is more complicated because there are two events - one for select and one for deselect // respond to both const string propName = "SelectedItem"; - return new DispatchTuple + return new DispatchItem { Type = typeof(AdapterView), Property = propName, Func = (x, ex) => { - var v = (AdapterView)x; - - return Observable.Merge( - Observable.FromEventPattern(h => v.ItemSelected += h, h => v.ItemSelected -= h) - .Select(_ => new ObservedChange(v, ex)), - Observable.FromEventPattern(h => v.NothingSelected += h, h => v.NothingSelected -= h) - .Select(_ => new ObservedChange(v, ex))); + var adapterView = (AdapterView)x; + + var itemSelected = Observable.FromEvent, ObservedChange>( + eventHandler => + { + void Handler(object sender, AdapterView.ItemSelectedEventArgs e) => eventHandler(new ObservedChange(adapterView, ex)); + return Handler; + }, + h => adapterView.ItemSelected += h, + h => adapterView.ItemSelected -= h); + + var nothingSelected = Observable.FromEvent, ObservedChange>( + eventHandler => + { + void Handler(object sender, AdapterView.NothingSelectedEventArgs e) => eventHandler(new ObservedChange(adapterView, ex)); + return Handler; + }, + h => adapterView.NothingSelected += h, + h => adapterView.NothingSelected -= h); + + return Observable.Merge(itemSelected, nothingSelected); } }; } - private static DispatchTuple CreateTimePickerHourFromWidget() + private static DispatchItem CreateTimePickerHourFromWidget() { if ((int)Build.VERSION.SdkInt >= 23) { @@ -100,7 +114,7 @@ private static DispatchTuple CreateTimePickerHourFromWidget() #pragma warning restore 618 } - private static DispatchTuple CreateTimePickerMinuteFromWidget() + private static DispatchItem CreateTimePickerMinuteFromWidget() { if ((int)Build.VERSION.SdkInt >= 23) { @@ -112,7 +126,7 @@ private static DispatchTuple CreateTimePickerMinuteFromWidget() #pragma warning restore 618 } - private static DispatchTuple CreateFromWidget(Expression> property, Action> addHandler, Action> removeHandler) + private static DispatchItem CreateFromWidget(Expression> property, Action> addHandler, Action> removeHandler) where TView : View where TEventArgs : EventArgs { @@ -120,21 +134,23 @@ private static DispatchTuple CreateFromWidget(Expression { - var v = (TView)x; + var view = (TView)x; - return Observable.FromEventPattern(h => addHandler(v, h), h => removeHandler(v, h)) - .Select(_ => new ObservedChange(v, ex)); + return Observable.FromEvent, TEventArgs>( + h => addHandler(view, h), + h => removeHandler(view, h)) + .Select(_ => new ObservedChange(view, ex)); } }; } - private class DispatchTuple + private class DispatchItem { public Type Type { get; set; } diff --git a/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs b/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs index 3e879f1db..15919e0c8 100644 --- a/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs +++ b/src/ReactiveUI/Platforms/android/FlexibleCommandBinder.cs @@ -100,7 +100,7 @@ protected static IDisposable ForEvent(ICommand command, object target, IObservab object latestParam = null; var ctl = target; - var actionDisp = Observable.FromEventPattern(ctl, eventName).Subscribe((e) => + var actionDisp = Observable.FromEventPattern(ctl, eventName).Subscribe(_ => { if (command.CanExecute(latestParam)) { @@ -120,8 +120,14 @@ protected static IDisposable ForEvent(ICommand command, object target, IObservab var compDisp = new CompositeDisposable( actionDisp, commandParameter.Subscribe(x => latestParam = x), - Observable.FromEventPattern(x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x) - .Select(_ => command.CanExecute(latestParam)) + Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(command.CanExecute(latestParam)); + return Handler; + }, + x => command.CanExecuteChanged += x, + x => command.CanExecuteChanged -= x) .Subscribe(x => enabledSetter(target, x, null))); return compDisp; diff --git a/src/ReactiveUI/Platforms/android/ReactiveActivity.cs b/src/ReactiveUI/Platforms/android/ReactiveActivity.cs index 00f95337e..5b30fb514 100644 --- a/src/ReactiveUI/Platforms/android/ReactiveActivity.cs +++ b/src/ReactiveUI/Platforms/android/ReactiveActivity.cs @@ -70,7 +70,7 @@ public class ReactiveActivity : Activity, IReactiveObject, IReactiveNotifyProper { private readonly Subject _activated = new Subject(); private readonly Subject _deactivated = new Subject(); - private readonly Subject> _activityResult = new Subject>(); + private readonly Subject<(int requestCode, Result resultCode, Intent intent)> _activityResult = new Subject<(int requestCode, Result resultCode, Intent intent)>(); /// /// Initializes a new instance of the class. @@ -134,7 +134,7 @@ public IObservable> Changed /// /// The activity result. /// - public IObservable> ActivityResult => _activityResult.AsObservable(); + public IObservable<(int requestCode, Result resultCode, Intent intent)> ActivityResult => _activityResult.AsObservable(); /// /// When this method is called, an object will not fire change @@ -163,13 +163,13 @@ void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) /// The intent. /// The request code. /// A task with the result and the intent. - public Task> StartActivityForResultAsync(Intent intent, int requestCode) + public Task<(Result resultCode, Intent intent)> StartActivityForResultAsync(Intent intent, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.resultCode, x.intent)) .FirstAsync() .ToTask(); @@ -183,13 +183,13 @@ public Task> StartActivityForResultAsync(Intent intent, in /// The type. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Type type, int requestCode) + public Task<(Result resultCode, Intent intent)> StartActivityForResultAsync(Type type, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.resultCode, x.intent)) .FirstAsync() .ToTask(); @@ -215,7 +215,7 @@ protected override void OnResume() protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); - _activityResult.OnNext(Tuple.Create(requestCode, resultCode, data)); + _activityResult.OnNext((requestCode, resultCode, data)); } /// diff --git a/src/ReactiveUI/Platforms/android/ReactiveListAdapter.cs b/src/ReactiveUI/Platforms/android/ReactiveListAdapter.cs deleted file mode 100644 index f1c1f3961..000000000 --- a/src/ReactiveUI/Platforms/android/ReactiveListAdapter.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Reactive.Disposables; -using System.Threading; -using Android.Views; -using Android.Widget; -using Splat; - -#pragma warning disable CA1062 // null check -- legacy. -#pragma warning disable SA1600 // Elements should be documented - -namespace ReactiveUI.Legacy -{ - [Obsolete("ReactiveList is no longer supported. We suggest replacing it with DynamicData https://github.com/rolandpheasant/dynamicdata")] - public class ReactiveListAdapter : BaseAdapter, IEnableLogger - where TViewModel : class - { - private readonly IReadOnlyReactiveList _list; - private readonly Func _viewCreator; - private readonly Action _viewInitializer; - private IDisposable _inner; - - public ReactiveListAdapter( - IReadOnlyReactiveList backingList, - Func viewCreator, - Action viewInitializer = null) - { - _list = backingList; - _viewCreator = viewCreator; - _viewInitializer = viewInitializer; - - _inner = _list.Changed.Subscribe(_ => NotifyDataSetChanged()); - } - - /// - public override bool HasStableIds - { - get { return true; } - } - - /// - public override int Count - { - get { return _list.Count; } - } - - /// - public override TViewModel this[int index] - { - get { return _list[index]; } - } - - /// - public override long GetItemId(int position) - { - return _list[position].GetHashCode(); - } - - /// - public override View GetView(int position, View convertView, ViewGroup parent) - { - View theView = convertView; - var data = _list[position]; - - if (theView == null) - { - theView = _viewCreator(data, parent); - } - - var ivf = theView.GetViewHost() as IViewFor; - if (ivf != null) - { - ivf.ViewModel = data; - } - - if (_viewInitializer != null) - { - _viewInitializer(data, theView); - } - - return theView; - } - - /// - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - Interlocked.Exchange(ref _inner, Disposable.Empty).Dispose(); - } - } -#pragma warning restore SA1600 // Elements should be documented -} diff --git a/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs b/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs index 3a8b8834f..f9564bef3 100644 --- a/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs +++ b/src/ReactiveUI/Platforms/android/ReactivePreferenceActivity.cs @@ -70,7 +70,7 @@ public class ReactivePreferenceActivity : PreferenceActivity, IReactiveObject, I { private readonly Subject _activated = new Subject(); private readonly Subject _deactivated = new Subject(); - private readonly Subject> _activityResult = new Subject>(); + private readonly Subject<(int requestCode, Result resultCode, Intent intent)> _activityResult = new Subject<(int requestCode, Result resultCode, Intent intent)>(); /// /// Initializes a new instance of the class. @@ -134,7 +134,7 @@ public event PropertyChangedEventHandler PropertyChanged /// /// The deactivated. /// - public IObservable> ActivityResult => _activityResult.AsObservable(); + public IObservable<(int requestCode, Result resultCode, Intent intent)> ActivityResult => _activityResult.AsObservable(); /// /// When this method is called, an object will not fire change @@ -163,13 +163,13 @@ void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args) /// The intent. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Intent intent, int requestCode) + public Task<(Result resultCode, Intent intent)> StartActivityForResultAsync(Intent intent, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.resultCode, x.intent)) .FirstAsync() .ToTask(); @@ -183,13 +183,13 @@ public Task> StartActivityForResultAsync(Intent intent, in /// The type. /// The request code. /// A task with the result and intent. - public Task> StartActivityForResultAsync(Type type, int requestCode) + public Task<(Result resultCode, Intent intent)> StartActivityForResultAsync(Type type, int requestCode) { // NB: It's important that we set up the subscription *before* we // call ActivityForResult var ret = ActivityResult - .Where(x => x.Item1 == requestCode) - .Select(x => Tuple.Create(x.Item2, x.Item3)) + .Where(x => x.requestCode == requestCode) + .Select(x => (x.resultCode, x.intent)) .FirstAsync() .ToTask(); @@ -201,7 +201,7 @@ public Task> StartActivityForResultAsync(Type type, int re protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); - _activityResult.OnNext(Tuple.Create(requestCode, resultCode, data)); + _activityResult.OnNext((requestCode, resultCode, data)); } /// diff --git a/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs b/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs index 64a06a3b6..2b975f679 100644 --- a/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs +++ b/src/ReactiveUI/Platforms/apple-common/KVOObservableForProperty.cs @@ -25,16 +25,16 @@ namespace ReactiveUI /// public class KVOObservableForProperty : ICreatesObservableForProperty { - private static readonly MemoizingMRUCache, bool> declaredInNSObject; + private static readonly MemoizingMRUCache<(Type type, string propertyName), bool> declaredInNSObject; static KVOObservableForProperty() { var monotouchAssemblyName = typeof(NSObject).Assembly.FullName; - declaredInNSObject = new MemoizingMRUCache, bool>( + declaredInNSObject = new MemoizingMRUCache<(Type type, string propertyName), bool>( (pair, _) => { - var thisType = pair.Item1; + var thisType = pair.type; // Types that aren't NSObjects at all are uninteresting to us if (typeof(NSObject).IsAssignableFrom(thisType) == false) @@ -44,7 +44,7 @@ static KVOObservableForProperty() while (thisType != null) { - if (thisType.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Any(x => x.Name == pair.Item2)) + if (thisType.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Any(x => x.Name == pair.propertyName)) { // NB: This is a not-completely correct way to detect if // an object is defined in an Obj-C class (it will fail if @@ -63,7 +63,7 @@ static KVOObservableForProperty() /// public int GetAffinityForObject(Type type, string propertyName, bool beforeChanged = false) { - return declaredInNSObject.Get(Tuple.Create(type, propertyName)) ? 15 : 0; + return declaredInNSObject.Get((type, propertyName)) ? 15 : 0; } /// diff --git a/src/ReactiveUI/Platforms/apple-common/TargetActionCommandBinder.cs b/src/ReactiveUI/Platforms/apple-common/TargetActionCommandBinder.cs index 6e1ec04e4..b99861f47 100644 --- a/src/ReactiveUI/Platforms/apple-common/TargetActionCommandBinder.cs +++ b/src/ReactiveUI/Platforms/apple-common/TargetActionCommandBinder.cs @@ -110,8 +110,14 @@ public IDisposable BindCommandToObject(ICommand command, object target, IObserva var compDisp = new CompositeDisposable( actionDisp, commandParameter.Subscribe(x => latestParam = x), - Observable.FromEventPattern(x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x) - .Select(_ => command.CanExecute(latestParam)) + Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(command.CanExecute(latestParam)); + return Handler; + }, + x => command.CanExecuteChanged += x, + x => command.CanExecuteChanged -= x) .Subscribe(x => { enabledSetter(target, x, null); diff --git a/src/ReactiveUI/Platforms/net461/ComponentModelTypeConverter.cs b/src/ReactiveUI/Platforms/net4/ComponentModelTypeConverter.cs similarity index 81% rename from src/ReactiveUI/Platforms/net461/ComponentModelTypeConverter.cs rename to src/ReactiveUI/Platforms/net4/ComponentModelTypeConverter.cs index 88cf30bce..0dc53c5b2 100644 --- a/src/ReactiveUI/Platforms/net461/ComponentModelTypeConverter.cs +++ b/src/ReactiveUI/Platforms/net4/ComponentModelTypeConverter.cs @@ -14,25 +14,25 @@ namespace ReactiveUI /// public class ComponentModelTypeConverter : IBindingTypeConverter { - private readonly MemoizingMRUCache, TypeConverter> _typeConverterCache = new MemoizingMRUCache, TypeConverter>( + private readonly MemoizingMRUCache<(Type fromType, Type toType), TypeConverter> _typeConverterCache = new MemoizingMRUCache<(Type fromType, Type toType), TypeConverter>( (types, _) => { // NB: String is a Magical Type(tm) to TypeConverters. If we are // converting from string => int, we need the Int converter, not // the string converter :-/ - if (types.Item1 == typeof(string)) + if (types.fromType == typeof(string)) { - types = Tuple.Create(types.Item2, types.Item1); + types = (types.toType, types.fromType); } - var converter = TypeDescriptor.GetConverter(types.Item1); - return converter.CanConvertTo(types.Item2) ? converter : null; + var converter = TypeDescriptor.GetConverter(types.fromType); + return converter.CanConvertTo(types.toType) ? converter : null; }, RxApp.SmallCacheLimit); /// public int GetAffinityForObjects(Type fromType, Type toType) { - var converter = _typeConverterCache.Get(Tuple.Create(fromType, toType)); + var converter = _typeConverterCache.Get((fromType, toType)); return converter != null ? 10 : 0; } @@ -46,7 +46,7 @@ public bool TryConvert(object from, Type toType, object conversionHint, out obje } var fromType = from.GetType(); - var converter = _typeConverterCache.Get(Tuple.Create(fromType, toType)); + var converter = _typeConverterCache.Get((fromType, toType)); if (converter == null) { diff --git a/src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/net4/PlatformRegistrations.cs similarity index 100% rename from src/ReactiveUI/Platforms/net461/PlatformRegistrations.cs rename to src/ReactiveUI/Platforms/net4/PlatformRegistrations.cs diff --git a/src/ReactiveUI/Platforms/netcoreapp2.0/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/netcoreapp2/PlatformRegistrations.cs similarity index 100% rename from src/ReactiveUI/Platforms/netcoreapp2.0/PlatformRegistrations.cs rename to src/ReactiveUI/Platforms/netcoreapp2/PlatformRegistrations.cs diff --git a/src/ReactiveUI/Platforms/netcoreapp3/ComponentModelTypeConverter.cs b/src/ReactiveUI/Platforms/netcoreapp3/ComponentModelTypeConverter.cs new file mode 100644 index 000000000..0dc53c5b2 --- /dev/null +++ b/src/ReactiveUI/Platforms/netcoreapp3/ComponentModelTypeConverter.cs @@ -0,0 +1,86 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.ComponentModel; +using Splat; + +namespace ReactiveUI +{ + /// + /// Binding Type Converter for component model. + /// + public class ComponentModelTypeConverter : IBindingTypeConverter + { + private readonly MemoizingMRUCache<(Type fromType, Type toType), TypeConverter> _typeConverterCache = new MemoizingMRUCache<(Type fromType, Type toType), TypeConverter>( + (types, _) => + { + // NB: String is a Magical Type(tm) to TypeConverters. If we are + // converting from string => int, we need the Int converter, not + // the string converter :-/ + if (types.fromType == typeof(string)) + { + types = (types.toType, types.fromType); + } + + var converter = TypeDescriptor.GetConverter(types.fromType); + return converter.CanConvertTo(types.toType) ? converter : null; + }, RxApp.SmallCacheLimit); + + /// + public int GetAffinityForObjects(Type fromType, Type toType) + { + var converter = _typeConverterCache.Get((fromType, toType)); + return converter != null ? 10 : 0; + } + + /// + public bool TryConvert(object from, Type toType, object conversionHint, out object result) + { + if (from == null) + { + result = null; + return true; + } + + var fromType = from.GetType(); + var converter = _typeConverterCache.Get((fromType, toType)); + + if (converter == null) + { + throw new ArgumentException($"Can't convert {fromType} to {toType}. To fix this, register a IBindingTypeConverter"); + } + + try + { + // TODO: This should use conversionHint to determine whether this is locale-aware or not + result = (fromType == typeof(string)) ? + converter.ConvertFrom(from) : converter.ConvertTo(from, toType); + + return true; + } + catch (FormatException) + { + result = null; + return false; + } + catch (Exception e) + { + // Errors from ConvertFrom end up here but wrapped in + // outer exception. Add more types here as required. + // IndexOutOfRangeException is given when trying to + // convert empty strings with some/all? converters + if (e.InnerException is IndexOutOfRangeException || + e.InnerException is FormatException) + { + result = null; + return false; + } + + throw new Exception($"Can't convert from {@from.GetType()} to {toType}.", e); + } + } + } +} diff --git a/src/ReactiveUI/Platforms/netcoreapp3/PlatformRegistrations.cs b/src/ReactiveUI/Platforms/netcoreapp3/PlatformRegistrations.cs new file mode 100644 index 000000000..618daa0be --- /dev/null +++ b/src/ReactiveUI/Platforms/netcoreapp3/PlatformRegistrations.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Reactive.Concurrency; + +namespace ReactiveUI +{ + /// + /// Platform registrations for a .NET Core application. + /// + public class PlatformRegistrations : IWantsToRegisterStuff + { + /// + public void Register(Action, Type> registerFunction) + { + if (registerFunction == null) + { + throw new ArgumentNullException(nameof(registerFunction)); + } + + registerFunction(() => new ComponentModelTypeConverter(), typeof(IBindingTypeConverter)); + RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; + RxApp.MainThreadScheduler = DefaultScheduler.Instance; + } + } +} diff --git a/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs b/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs index b9ed713dd..30b093a4c 100644 --- a/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs +++ b/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Reactive.Linq; using System.Reflection; +using Windows.Foundation; using Windows.UI.Xaml; namespace ReactiveUI @@ -25,7 +26,7 @@ public int GetAffinityForView(Type view) } /// - public IObservable GetActivationForView(IActivatable view) + public IObservable GetActivationForView(IActivatableView view) { var fe = view as FrameworkElement; @@ -34,13 +35,23 @@ public IObservable GetActivationForView(IActivatable view) return Observable.Empty; } - var viewLoaded = WindowsObservable.FromEventPattern( + var viewLoaded = Observable.FromEvent, bool>( + eventHandler => + { + void Handler(FrameworkElement sender, object e) => eventHandler(true); + return Handler; + }, x => fe.Loading += x, - x => fe.Loading -= x).Select(_ => true); + x => fe.Loading -= x); - var viewUnloaded = Observable.FromEventPattern( + var viewUnloaded = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, RoutedEventArgs e) => eventHandler(false); + return Handler; + }, x => fe.Unloaded += x, - x => fe.Unloaded -= x).Select(_ => false); + x => fe.Unloaded -= x); return viewLoaded .Merge(viewUnloaded) diff --git a/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs b/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs index 925e6e49a..5c24f2426 100644 --- a/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs +++ b/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs @@ -29,8 +29,8 @@ namespace ReactiveUI /// public class SingleWindowDispatcherScheduler : IScheduler { + private const CoreDispatcherPriority Priority = default; private static CoreDispatcher _dispatcher; - private readonly CoreDispatcherPriority _priority; /// /// Initializes a new instance of the class. @@ -127,10 +127,13 @@ public IDisposable Schedule(TState state, DateTimeOffset dueTime, Func /// The exception. - private void RaiseUnhandledException(Exception ex) + private static void RaiseUnhandledException(Exception ex) { - var timer = new DispatcherTimer(); - timer.Interval = TimeSpan.Zero; + var timer = new DispatcherTimer + { + Interval = TimeSpan.Zero + }; + timer.Tick += RaiseToDispatcher; timer.Start(); @@ -156,7 +159,7 @@ private IDisposable ScheduleOnDispatcherNow(TState state, Func { if (!d.IsDisposed) diff --git a/src/ReactiveUI/Platforms/uikit-common/CommonReactiveSource.cs b/src/ReactiveUI/Platforms/uikit-common/CommonReactiveSource.cs index be3ce5eb1..e81855ed7 100644 --- a/src/ReactiveUI/Platforms/uikit-common/CommonReactiveSource.cs +++ b/src/ReactiveUI/Platforms/uikit-common/CommonReactiveSource.cs @@ -29,7 +29,7 @@ internal sealed class CommonReactiveSource> _pendingChanges; + private readonly IList<(int section, PendingChange pendingChange)> _pendingChanges; private bool _isCollectingChanges; private IReadOnlyList _sectionInfo; @@ -44,7 +44,7 @@ public CommonReactiveSource(IUICollViewAdapter adapter) _mainDisposables = new CompositeDisposable(); _sectionInfoDisposable = new SerialDisposable(); _mainDisposables.Add(_sectionInfoDisposable); - _pendingChanges = new List>(); + _pendingChanges = new List<(int section, PendingChange pendingChange)>(); _sectionInfo = Array.Empty(); _mainDisposables.Add( @@ -310,7 +310,7 @@ private void SubscribeToSectionInfoChanges(int sectionInfoId, IReadOnlyList this.Log().Error(CultureInfo.InvariantCulture, "[#{0}] Error while watching section collection: {1}", sectionInfoId, ex))); @@ -334,29 +334,29 @@ private void ApplyPendingChanges(int sectionInfoId) { this.Log().Debug(CultureInfo.InvariantCulture, "[#{0}] The pending changes (in order received) are:", sectionInfoId); - foreach (var pendingChange in _pendingChanges) + foreach (var pendingSectionChange in _pendingChanges) { this.Log().Debug( CultureInfo.InvariantCulture, "[#{0}] Section {1}: Action = {2}, OldStartingIndex = {3}, NewStartingIndex = {4}, OldItems.Count = {5}, NewItems.Count = {6}", sectionInfoId, - pendingChange.Item1, - pendingChange.Item2.Action, - pendingChange.Item2.OldStartingIndex, - pendingChange.Item2.NewStartingIndex, - pendingChange.Item2.OldItems == null ? "null" : pendingChange.Item2.OldItems.Count.ToString(CultureInfo.InvariantCulture), - pendingChange.Item2.NewItems == null ? "null" : pendingChange.Item2.NewItems.Count.ToString(CultureInfo.InvariantCulture)); + pendingSectionChange.section, + pendingSectionChange.pendingChange.Action, + pendingSectionChange.pendingChange.OldStartingIndex, + pendingSectionChange.pendingChange.NewStartingIndex, + pendingSectionChange.pendingChange.OldItems == null ? "null" : pendingSectionChange.pendingChange.OldItems.Count.ToString(CultureInfo.InvariantCulture), + pendingSectionChange.pendingChange.NewItems == null ? "null" : pendingSectionChange.pendingChange.NewItems.Count.ToString(CultureInfo.InvariantCulture)); } } - foreach (var sectionedUpdates in _pendingChanges.GroupBy(x => x.Item1)) + foreach (var sectionedUpdates in _pendingChanges.GroupBy(x => x.section)) { - var section = sectionedUpdates.First().Item1; + var section = sectionedUpdates.First().section; this.Log().Debug(CultureInfo.InvariantCulture, "[#{0}] Processing updates for section {1}", sectionInfoId, section); var allSectionChanges = sectionedUpdates - .Select(x => x.Item2) + .Select(x => x.pendingChange) .ToList(); if (allSectionChanges.Any(x => x.Action == NotifyCollectionChangedAction.Reset)) diff --git a/src/ReactiveUI/Platforms/uikit-common/FlexibleCommandBinder.cs b/src/ReactiveUI/Platforms/uikit-common/FlexibleCommandBinder.cs index 204e11072..480ea3036 100644 --- a/src/ReactiveUI/Platforms/uikit-common/FlexibleCommandBinder.cs +++ b/src/ReactiveUI/Platforms/uikit-common/FlexibleCommandBinder.cs @@ -121,8 +121,14 @@ protected static IDisposable ForEvent(ICommand command, object target, IObservab return new CompositeDisposable( actionDisp, commandParameter.Subscribe(x => latestParam = x), - Observable.FromEventPattern(x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x) - .Select(_ => command.CanExecute(latestParam)) + Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(command.CanExecute(latestParam)); + return Handler; + }, + x => command.CanExecuteChanged += x, + x => command.CanExecuteChanged -= x) .Subscribe(x => enabledSetter(target, x, null))); } @@ -174,8 +180,14 @@ protected static IDisposable ForTargetAction(ICommand command, object target, IO return new CompositeDisposable( actionDisp, commandParameter.Subscribe(x => latestParam = x), - Observable.FromEventPattern(x => command.CanExecuteChanged += x, x => command.CanExecuteChanged -= x) - .Select(_ => command.CanExecute(latestParam)) + Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(command.CanExecute(latestParam)); + return Handler; + }, + x => command.CanExecuteChanged += x, + x => command.CanExecuteChanged -= x) .Subscribe(x => enabledSetter(target, x, null))); } diff --git a/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSource.cs b/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSource.cs index 8c71f3a36..d6f1c75a9 100644 --- a/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSource.cs +++ b/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSource.cs @@ -9,7 +9,6 @@ using System.ComponentModel; using System.Reactive.Subjects; using Foundation; -using ReactiveUI.Legacy; using Splat; using UIKit; @@ -80,7 +79,7 @@ public event PropertyChangedEventHandler PropertyChanged /// Gets or sets the data that should be displayed by this /// . You should /// probably bind your view model to this property. - /// If the list implements , + /// If the list implements , /// then the source will react to changes to the contents of the list as well. /// /// The data. diff --git a/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSourceExtensions.cs b/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSourceExtensions.cs index a24f944e4..0a164226e 100644 --- a/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSourceExtensions.cs +++ b/src/ReactiveUI/Platforms/uikit-common/ReactiveCollectionViewSourceExtensions.cs @@ -10,7 +10,6 @@ using System.Reactive.Disposables; using System.Reactive.Linq; using Foundation; -using ReactiveUI.Legacy; using UIKit; namespace ReactiveUI @@ -24,7 +23,7 @@ public static class ReactiveCollectionViewSourceExtensions /// Extension method that binds an observable of a list of collection /// sections as the source of a . /// If your is also an instance of - /// , then this method + /// , then this method /// will silently update the bindings whenever it changes as well. /// Otherwise, it will just log a message. /// diff --git a/src/ReactiveUI/Platforms/uikit-common/ReactiveNavigationController.cs b/src/ReactiveUI/Platforms/uikit-common/ReactiveNavigationController.cs index 1c43bd86d..5569664a5 100644 --- a/src/ReactiveUI/Platforms/uikit-common/ReactiveNavigationController.cs +++ b/src/ReactiveUI/Platforms/uikit-common/ReactiveNavigationController.cs @@ -20,7 +20,7 @@ namespace ReactiveUI /// [SuppressMessage("Design", "CA1010: Implement generic IEnumerable", Justification = "UI Kit exposes IEnumerable")] [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Classes with the same class names within.")] - public abstract class ReactiveNavigationController : UINavigationController, IReactiveNotifyPropertyChanged, IHandleObservableErrors, IReactiveObject, ICanActivate, IActivatable + public abstract class ReactiveNavigationController : UINavigationController, IReactiveNotifyPropertyChanged, IHandleObservableErrors, IReactiveObject, ICanActivate, IActivatableView { private Subject _activated = new Subject(); private Subject _deactivated = new Subject(); diff --git a/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs b/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs index 30b8e089c..34c0561c3 100644 --- a/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs +++ b/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSource.cs @@ -9,7 +9,6 @@ using System.ComponentModel; using System.Reactive.Subjects; using Foundation; -using ReactiveUI.Legacy; using Splat; using UIKit; @@ -79,8 +78,6 @@ public event PropertyChangedEventHandler PropertyChanged /// Gets or sets the data that should be displayed by this /// . You should /// probably bind your view model to this property. - /// If the list implements , - /// then the source will react to changes to the contents of the list as well. /// /// The data. public IReadOnlyList> Data diff --git a/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSourceExtensions.cs b/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSourceExtensions.cs index b956e8530..767f6881a 100644 --- a/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSourceExtensions.cs +++ b/src/ReactiveUI/Platforms/uikit-common/ReactiveTableViewSourceExtensions.cs @@ -22,7 +22,7 @@ public static class ReactiveTableViewSourceExtensions /// Extension method that binds an observable of a list of table /// sections as the source of a . /// If your is also an instance of - /// , then this method + /// , then this method /// will silently update the bindings whenever it changes as well. /// Otherwise, it will just log a message. /// diff --git a/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs b/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs index 8efa1e98f..7cd17efbe 100644 --- a/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs +++ b/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs @@ -4,6 +4,7 @@ // See the LICENSE file in the project root for full license information. using System; +using System.Diagnostics.CodeAnalysis; using System.Linq; #if NETFX_CORE || HAS_UNO @@ -32,6 +33,7 @@ public class AutoDataTemplateBindingHook : IPropertyBindingHook /// /// Gets the default item template. /// + [SuppressMessage("Design", "CA1307: Use the currency locale settings", Justification = "Not available on all platforms.")] public static Lazy DefaultItemTemplate { get; } = new Lazy(() => { #if NETFX_CORE || HAS_UNO diff --git a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs index 9bda85398..c1bdbddcd 100644 --- a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs @@ -35,7 +35,7 @@ namespace ReactiveUI #if HAS_UNO partial #endif - class RoutedViewHost : TransitioningContentControl, IActivatable, IEnableLogger + class RoutedViewHost : TransitioningContentControl, IActivatableView, IEnableLogger { /// /// The router dependency property. @@ -86,16 +86,22 @@ public RoutedViewHost() platformGetter = () => platform.GetOrientation(); } - ViewContractObservable = Observable.FromEventPattern(x => SizeChanged += x, x => SizeChanged -= x) - .Select(_ => platformGetter()) + ViewContractObservable = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, SizeChangedEventArgs e) => eventHandler(platformGetter()); + return Handler; + }, + x => SizeChanged += x, + x => SizeChanged -= x) .DistinctUntilChanged() .StartWith(platformGetter()) - .Select(x => x != null ? x : default(string)); + .Select(x => x); var vmAndContract = Observable.CombineLatest( this.WhenAnyObservable(x => x.Router.CurrentViewModel), this.WhenAnyObservable(x => x.ViewContractObservable), - Tuple.Create); + (viewModel, contract) => (viewModel, contract)); this.WhenActivated(d => { @@ -105,21 +111,21 @@ public RoutedViewHost() d(vmAndContract.DistinctUntilChanged().Subscribe( x => { - if (x.Item1 == null) + if (x.viewModel == null) { Content = DefaultContent; return; } var viewLocator = ViewLocator ?? ReactiveUI.ViewLocator.Current; - var view = viewLocator.ResolveView(x.Item1, x.Item2) ?? viewLocator.ResolveView(x.Item1, null); + var view = viewLocator.ResolveView(x.viewModel, x.contract) ?? viewLocator.ResolveView(x.viewModel, null); if (view == null) { - throw new Exception($"Couldn't find view for '{x.Item1}'."); + throw new Exception($"Couldn't find view for '{x.viewModel}'."); } - view.ViewModel = x.Item1; + view.ViewModel = x.viewModel; Content = view; }, ex => RxApp.DefaultExceptionHandler.OnNext(ex))); }); diff --git a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs index 050ce5c3f..209cf93e4 100644 --- a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs @@ -95,8 +95,14 @@ public ViewModelViewHost() platformGetter = () => platform.GetOrientation(); } - ViewContractObservable = Observable.FromEventPattern(x => SizeChanged += x, x => SizeChanged -= x) - .Select(_ => platformGetter()) + ViewContractObservable = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, SizeChangedEventArgs e) => eventHandler(platformGetter()); + return Handler; + }, + x => SizeChanged += x, + x => SizeChanged -= x) .StartWith(platformGetter()) .DistinctUntilChanged(); diff --git a/src/ReactiveUI/Platforms/xamarin-common/ComponentModelTypeConverter.cs b/src/ReactiveUI/Platforms/xamarin-common/ComponentModelTypeConverter.cs index 8d329a1ea..c7a5ed75f 100644 --- a/src/ReactiveUI/Platforms/xamarin-common/ComponentModelTypeConverter.cs +++ b/src/ReactiveUI/Platforms/xamarin-common/ComponentModelTypeConverter.cs @@ -14,25 +14,25 @@ namespace ReactiveUI /// public class ComponentModelTypeConverter : IBindingTypeConverter { - private readonly MemoizingMRUCache, TypeConverter> _typeConverterCache = new MemoizingMRUCache, TypeConverter>( + private readonly MemoizingMRUCache<(Type fromType, Type toType), TypeConverter> _typeConverterCache = new MemoizingMRUCache<(Type fromType, Type toType), TypeConverter>( (types, _) => { // NB: String is a Magical Type(tm) to TypeConverters. If we are // converting from string => int, we need the Int converter, not // the string converter :-/ - if (types.Item1 == typeof(string)) + if (types.fromType == typeof(string)) { - types = Tuple.Create(types.Item2, types.Item1); + types = (types.toType, types.fromType); } - var converter = TypeDescriptor.GetConverter(types.Item1); - return converter.CanConvertTo(types.Item2) ? converter : null; + var converter = TypeDescriptor.GetConverter(types.fromType); + return converter.CanConvertTo(types.toType) ? converter : null; }, RxApp.SmallCacheLimit); /// public int GetAffinityForObjects(Type fromType, Type toType) { - var converter = _typeConverterCache.Get(Tuple.Create(fromType, toType)); + var converter = _typeConverterCache.Get((fromType, toType)); return converter != null ? 10 : 0; } @@ -46,7 +46,7 @@ public bool TryConvert(object from, Type toType, object conversionHint, out obje } var fromType = from.GetType(); - var converter = _typeConverterCache.Get(Tuple.Create(fromType, toType)); + var converter = _typeConverterCache.Get((fromType, toType)); if (converter == null) { diff --git a/src/ReactiveUI/Properties/AssemblyInfo.cs b/src/ReactiveUI/Properties/AssemblyInfo.cs index 2ae17c833..1b291f9c3 100644 --- a/src/ReactiveUI/Properties/AssemblyInfo.cs +++ b/src/ReactiveUI/Properties/AssemblyInfo.cs @@ -6,6 +6,7 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("ReactiveUI.Tests")] +[assembly: InternalsVisibleTo("ReactiveUI.Blazor")] [assembly: InternalsVisibleTo("ReactiveUI.Winforms")] [assembly: InternalsVisibleTo("ReactiveUI.Wpf")] [assembly: InternalsVisibleTo("ReactiveUI.XamForms")] diff --git a/src/ReactiveUI/ReactiveCommand/CombinedReactiveCommand.cs b/src/ReactiveUI/ReactiveCommand/CombinedReactiveCommand.cs index 551edfef5..da6519fc1 100644 --- a/src/ReactiveUI/ReactiveCommand/CombinedReactiveCommand.cs +++ b/src/ReactiveUI/ReactiveCommand/CombinedReactiveCommand.cs @@ -113,8 +113,7 @@ protected internal CombinedReactiveCommand( _exceptions = new ScheduledSubject(outputScheduler, RxApp.DefaultExceptionHandler); - CanExecute - .Subscribe(_ => OnCanExecuteChanged()); + CanExecute.Subscribe(OnCanExecuteChanged); } /// diff --git a/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs b/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs index 1638111f0..0e8c72232 100644 --- a/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs +++ b/src/ReactiveUI/ReactiveCommand/ReactiveCommand.cs @@ -667,8 +667,7 @@ protected internal ReactiveCommand( _exceptions = new ScheduledSubject(outputScheduler, RxApp.DefaultExceptionHandler); - _canExecuteSubscription = _canExecute - .Subscribe(_ => OnCanExecuteChanged()); + _canExecuteSubscription = _canExecute.Subscribe(OnCanExecuteChanged); } private enum ExecutionDemarcation diff --git a/src/ReactiveUI/ReactiveCommand/ReactiveCommandBase.cs b/src/ReactiveUI/ReactiveCommand/ReactiveCommandBase.cs index 5bc83f367..184c0d9df 100644 --- a/src/ReactiveUI/ReactiveCommand/ReactiveCommandBase.cs +++ b/src/ReactiveUI/ReactiveCommand/ReactiveCommandBase.cs @@ -74,6 +74,7 @@ namespace ReactiveUI public abstract class ReactiveCommandBase : IObservable, ICommand, IReactiveCommand { private EventHandler _canExecuteChanged; + private bool _canExecuteValue; /// event EventHandler ICommand.CanExecuteChanged @@ -189,8 +190,10 @@ void ICommand.Execute(object parameter) /// /// Will trigger a event when the CanExecute condition has changed. /// - protected void OnCanExecuteChanged() + /// The new value of the execute. + protected void OnCanExecuteChanged(bool newValue) { + _canExecuteValue = newValue; _canExecuteChanged?.Invoke(this, EventArgs.Empty); } @@ -202,7 +205,7 @@ protected void OnCanExecuteChanged() /// If the command can be executed. protected virtual bool ICommandCanExecute(object parameter) { - return CanExecute.FirstAsync().Wait(); + return _canExecuteValue; } /// diff --git a/src/ReactiveUI/ReactiveCommand/ReactiveCommandMixins.cs b/src/ReactiveUI/ReactiveCommand/ReactiveCommandMixins.cs index 82d9aab1e..564075616 100644 --- a/src/ReactiveUI/ReactiveCommand/ReactiveCommandMixins.cs +++ b/src/ReactiveUI/ReactiveCommand/ReactiveCommandMixins.cs @@ -28,9 +28,14 @@ public static class ReactiveCommandMixins /// from the command. public static IDisposable InvokeCommand(this IObservable item, ICommand command) { - var canExecuteChanged = Observable - .FromEventPattern(h => command.CanExecuteChanged += h, h => command.CanExecuteChanged -= h) - .Select(_ => Unit.Default) + var canExecuteChanged = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(Unit.Default); + return Handler; + }, + h => command.CanExecuteChanged += h, + h => command.CanExecuteChanged -= h) .StartWith(Unit.Default); return WithLatestFromFixed(item, canExecuteChanged, (value, _) => InvokeCommandInfo.From(command, command.CanExecute(value), value)) @@ -78,12 +83,18 @@ public static IDisposable InvokeCommand(this IObservable item, Re public static IDisposable InvokeCommand(this IObservable item, TTarget target, Expression> commandProperty) where TTarget : class { - var command = target.WhenAnyValue(commandProperty); - var commandCanExecuteChanged = command - .Select(c => c == null ? Observable.Empty : Observable - .FromEventPattern(h => c.CanExecuteChanged += h, h => c.CanExecuteChanged -= h) - .Select(_ => c) - .StartWith(c)) + var commandObs = target.WhenAnyValue(commandProperty); + var commandCanExecuteChanged = commandObs + .Select(command => command == null ? Observable.Empty : Observable + .FromEvent( + eventHandler => + { + void Handler(object sender, EventArgs e) => eventHandler(command); + return Handler; + }, + h => command.CanExecuteChanged += h, + h => command.CanExecuteChanged -= h) + .StartWith(command)) .Switch(); return WithLatestFromFixed(item, commandCanExecuteChanged, (value, cmd) => InvokeCommandInfo.From(cmd, cmd.CanExecute(value), value)) diff --git a/src/ReactiveUI/ReactiveUI.csproj b/src/ReactiveUI/ReactiveUI.csproj index 55435d539..6500abacd 100644 --- a/src/ReactiveUI/ReactiveUI.csproj +++ b/src/ReactiveUI/ReactiveUI.csproj @@ -1,7 +1,7 @@  netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;MonoAndroid81;netcoreapp2.0;tizen40 - $(TargetFrameworks);net461;uap10.0.16299 + $(TargetFrameworks);net461;uap10.0.16299;netcoreapp3.0 ReactiveUI ReactiveUI A MVVM framework that integrates with the Reactive Extensions for .NET to create elegant, testable User Interfaces that run on any mobile or desktop platform. Supports Xamarin.iOS, Xamarin.Android, Xamarin.Mac, Xamarin Forms, WPF, Windows Forms, Windows Phone 8.1, Windows Store and Universal Windows Platform (UWP). @@ -18,11 +18,23 @@ - + + + + + + + + + + + + + @@ -32,11 +44,11 @@ - + - + @@ -79,8 +91,13 @@ - - + + + + + + + diff --git a/src/ReactiveUI/Routing/MessageBus.cs b/src/ReactiveUI/Routing/MessageBus.cs index fff0ff770..3f8bfbc53 100644 --- a/src/ReactiveUI/Routing/MessageBus.cs +++ b/src/ReactiveUI/Routing/MessageBus.cs @@ -96,7 +96,7 @@ public IObservable ListenIncludeLatest(string contract = null) public bool IsRegistered(Type type, string contract = null) { bool ret = false; - WithMessageBus(type, contract, (mb, tuple) => { ret = mb.ContainsKey(tuple) && mb[tuple].IsAlive; }); + WithMessageBus(type, contract, (mb, item) => { ret = mb.ContainsKey(item) && mb[item].IsAlive; }); return ret; } @@ -145,16 +145,16 @@ private ISubject SetupSubjectIfNecessary(string contract) { ISubject ret = null; - WithMessageBus(typeof(T), contract, (mb, tuple) => + WithMessageBus(typeof(T), contract, (mb, item) => { - if (mb.TryGetValue(tuple, out NotAWeakReference subjRef) && subjRef.IsAlive) + if (mb.TryGetValue(item, out NotAWeakReference subjRef) && subjRef.IsAlive) { ret = (ISubject)subjRef.Target; return; } - ret = new ScheduledSubject(GetScheduler(tuple), null, new BehaviorSubject(default(T))); - mb[tuple] = new NotAWeakReference(ret); + ret = new ScheduledSubject(GetScheduler(item), null, new BehaviorSubject(default(T))); + mb[item] = new NotAWeakReference(ret); }); return ret; @@ -167,18 +167,18 @@ private void WithMessageBus( { lock (_messageBus) { - var tuple = (type, contract); - block(_messageBus, tuple); - if (_messageBus.ContainsKey(tuple) && !_messageBus[tuple].IsAlive) + var item = (type, contract); + block(_messageBus, item); + if (_messageBus.ContainsKey(item) && !_messageBus[item].IsAlive) { - _messageBus.Remove(tuple); + _messageBus.Remove(item); } } } - private IScheduler GetScheduler((Type type, string contract) tuple) + private IScheduler GetScheduler((Type type, string contract) item) { - _schedulerMappings.TryGetValue(tuple, out IScheduler scheduler); + _schedulerMappings.TryGetValue(item, out IScheduler scheduler); return scheduler ?? CurrentThreadScheduler.Instance; } } diff --git a/src/ReactiveUI/VariadicTemplates.cs b/src/ReactiveUI/VariadicTemplates.cs index 077e85fc0..50876c633 100644 --- a/src/ReactiveUI/VariadicTemplates.cs +++ b/src/ReactiveUI/VariadicTemplates.cs @@ -96,7 +96,7 @@ public static IObservable WhenAnyDynamic(this TSender This, /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable> WhenAnyValue( + public static IObservable<(T1,T2)> WhenAnyValue( this TSender This, Expression> property1, Expression> property2 @@ -104,7 +104,7 @@ Expression> property2 { return This.WhenAny(property1, property2, (c1, c2) => - Tuple.Create(c1.Value, c2.Value)); + (c1.Value, c2.Value)); } /// @@ -172,7 +172,7 @@ public static IObservable WhenAnyDynamic(this TSender This, /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable> WhenAnyValue( + public static IObservable<(T1,T2,T3)> WhenAnyValue( this TSender This, Expression> property1, Expression> property2, @@ -181,7 +181,7 @@ Expression> property3 { return This.WhenAny(property1, property2, property3, (c1, c2, c3) => - Tuple.Create(c1.Value, c2.Value, c3.Value)); + (c1.Value, c2.Value, c3.Value)); } /// @@ -255,7 +255,7 @@ public static IObservable WhenAnyDynamic(this TSender This, /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable> WhenAnyValue( + public static IObservable<(T1,T2,T3,T4)> WhenAnyValue( this TSender This, Expression> property1, Expression> property2, @@ -265,7 +265,7 @@ Expression> property4 { return This.WhenAny(property1, property2, property3, property4, (c1, c2, c3, c4) => - Tuple.Create(c1.Value, c2.Value, c3.Value, c4.Value)); + (c1.Value, c2.Value, c3.Value, c4.Value)); } /// @@ -345,7 +345,7 @@ public static IObservable WhenAnyDynamic(this TSender This, /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable> WhenAnyValue( + public static IObservable<(T1,T2,T3,T4,T5)> WhenAnyValue( this TSender This, Expression> property1, Expression> property2, @@ -356,7 +356,7 @@ Expression> property5 { return This.WhenAny(property1, property2, property3, property4, property5, (c1, c2, c3, c4, c5) => - Tuple.Create(c1.Value, c2.Value, c3.Value, c4.Value, c5.Value)); + (c1.Value, c2.Value, c3.Value, c4.Value, c5.Value)); } /// @@ -442,7 +442,7 @@ public static IObservable WhenAnyDynamic(this TSender This, /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable> WhenAnyValue( + public static IObservable<(T1,T2,T3,T4,T5,T6)> WhenAnyValue( this TSender This, Expression> property1, Expression> property2, @@ -454,7 +454,7 @@ Expression> property6 { return This.WhenAny(property1, property2, property3, property4, property5, property6, (c1, c2, c3, c4, c5, c6) => - Tuple.Create(c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value)); + (c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value)); } /// @@ -546,7 +546,7 @@ public static IObservable WhenAnyDynamic(this TSender This, /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable> WhenAnyValue( + public static IObservable<(T1,T2,T3,T4,T5,T6,T7)> WhenAnyValue( this TSender This, Expression> property1, Expression> property2, @@ -559,7 +559,7 @@ Expression> property7 { return This.WhenAny(property1, property2, property3, property4, property5, property6, property7, (c1, c2, c3, c4, c5, c6, c7) => - Tuple.Create(c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value)); + (c1.Value, c2.Value, c3.Value, c4.Value, c5.Value, c6.Value, c7.Value)); } /// diff --git a/src/ReactiveUI/VariadicTemplates.tt b/src/ReactiveUI/VariadicTemplates.tt index cb1dcf3a5..a4a850cb6 100644 --- a/src/ReactiveUI/VariadicTemplates.tt +++ b/src/ReactiveUI/VariadicTemplates.tt @@ -69,7 +69,7 @@ namespace ReactiveUI /// method in constructors to set up bindings between properties that also /// need an initial setup. /// - public static IObservable>> WhenAnyValue>( + public static IObservable<(<#= String.Join(",", templParams) #>)> WhenAnyValue>( this TSender This, <# for(int i=1; i <= length; i++) { #> Expression>> property<#=i#><# if (i != length) { #>,<# } #> @@ -78,7 +78,7 @@ namespace ReactiveUI { return This.WhenAny(<#= valuePropertyParams #>, (<#= valueSelectorParams #>) => - Tuple.Create(<#= valueSelectorArgs #>)); + (<#= valueSelectorArgs #>)); } <# } #> diff --git a/version.json b/version.json index aa38eccf6..c330ae86a 100644 --- a/version.json +++ b/version.json @@ -1,8 +1,8 @@ { - "version": "9.22", + "version": "10.0", "publicReleaseRefSpec": [ "^refs/heads/master$", // we release out of master - "^refs/heads/develop$", // we release out of develop + "^refs/heads/preview/.*", // we release previews "^refs/heads/rel/\\d+\\.\\d+\\.\\d+" // we also release branches starting with rel/N.N.N ], "nugetPackageVersion":{