From 0c3823266ffdb1240f808f77365c3ed9cf34f5e6 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Wed, 12 Jun 2019 06:26:07 +0300 Subject: [PATCH 01/24] Added wasm files. --- src/ReactiveUI.Fody.Tests/FodyWeavers.xsd | 1 + src/ReactiveUI.Uno/GlobalSuppressions.cs | 10 +++ src/ReactiveUI.Uno/ReactivePage.cs | 52 ++++++++++++++ src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 23 +++++++ .../net461/GeneratedInternalTypeHelper.g.cs | 62 +++++++++++++++++ src/ReactiveUI.sln | 67 +++++++++++++++++-- 6 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 src/ReactiveUI.Uno/GlobalSuppressions.cs create mode 100644 src/ReactiveUI.Uno/ReactivePage.cs create mode 100644 src/ReactiveUI.Uno/ReactiveUI.Uno.csproj create mode 100644 src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs diff --git a/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd b/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd index f3ac47620a..5cedd530b9 100644 --- a/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd +++ b/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd @@ -4,6 +4,7 @@ + diff --git a/src/ReactiveUI.Uno/GlobalSuppressions.cs b/src/ReactiveUI.Uno/GlobalSuppressions.cs new file mode 100644 index 0000000000..3e7a416ca0 --- /dev/null +++ b/src/ReactiveUI.Uno/GlobalSuppressions.cs @@ -0,0 +1,10 @@ + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1158:Static member in generic type should use a type parameter.", Justification = "", Scope = "member", Target = "~F:ReactiveUI.Uno.ReactivePage`1.ViewModelProperty")] + diff --git a/src/ReactiveUI.Uno/ReactivePage.cs b/src/ReactiveUI.Uno/ReactivePage.cs new file mode 100644 index 0000000000..360041250c --- /dev/null +++ b/src/ReactiveUI.Uno/ReactivePage.cs @@ -0,0 +1,52 @@ +// 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 Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace ReactiveUI.Uno +{ + /// + /// This is a that is also an . + /// + /// The type of the view model. + public class ReactivePage : Page, IViewFor + where TViewModel : class + { + /// + /// The view model bindable property. + /// + public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactivePage), + new PropertyMetadata(default, OnViewModelChanged)); + + /// + public TViewModel ViewModel + { + get => (TViewModel)GetValue(ViewModelProperty); + set => SetValue(ViewModelProperty, value); + } + + /// + object IViewFor.ViewModel + { + get => ViewModel; + set => ViewModel = (TViewModel)value; + } + + /// + protected override void OnDataContextChanged() + { + base.OnDataContextChanged(); + ViewModel = DataContext as TViewModel; + } + + private static void OnViewModelChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) + { + } + } +} diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj new file mode 100644 index 0000000000..012fc09591 --- /dev/null +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -0,0 +1,23 @@ + + + xamarinmac20;MonoAndroid90;xamarinios10;netstandard2.0 + $(TargetFrameworks);uap10.0.17763 + ReactiveUI.Uno + + Uno-Platform specific extensions to ReactiveUI + netstandard2.0 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs new file mode 100644 index 0000000000..136dd1ba9b --- /dev/null +++ b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace XamlGeneratedNamespace { + + + /// + /// GeneratedInternalTypeHelper + /// + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper { + + /// + /// CreateInstance + /// + protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) { + return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) + | (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture); + } + + /// + /// GetPropertyValue + /// + protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) { + return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture); + } + + /// + /// SetPropertyValue + /// + protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) { + propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture); + } + + /// + /// CreateDelegate + /// + protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) { + return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod + | (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] { + delegateType, + handler}, null))); + } + + /// + /// AddEventHandler + /// + protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) { + eventInfo.AddEventHandler(target, handler); + } + } +} + diff --git a/src/ReactiveUI.sln b/src/ReactiveUI.sln index f9c29ccc32..9fcb731103 100644 --- a/src/ReactiveUI.sln +++ b/src/ReactiveUI.sln @@ -1,6 +1,7 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.15 + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29001.49 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BD9762CF-E104-481C-96A6-26E624B86283}" ProjectSection(SolutionItems) = preProject @@ -38,7 +39,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Fody.Tests", "Re EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReactiveUI.Splat.Tests", "ReactiveUI.Splat.Tests\ReactiveUI.Splat.Tests.csproj", "{7ED6D69F-138F-40BD-9F37-3E4050E4D19B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactiveUI.Testing.Tests", "ReactiveUI.Testing.Tests\ReactiveUI.Testing.Tests.csproj", "{CD8B19A9-316E-4FBC-8F0C-87ADC6AAD684}" +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}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -816,6 +819,62 @@ Global {CD8B19A9-316E-4FBC-8F0C-87ADC6AAD684}.Release|x64.Build.0 = Release|Any CPU {CD8B19A9-316E-4FBC-8F0C-87ADC6AAD684}.Release|x86.ActiveCfg = Release|Any CPU {CD8B19A9-316E-4FBC-8F0C-87ADC6AAD684}.Release|x86.Build.0 = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|Mixed Platforms.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|Mixed Platforms.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|ARM.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|iPhone.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|Mixed Platforms.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|Mixed Platforms.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|x64.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|x64.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|x86.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.AppStore|x86.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|ARM.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|iPhone.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|x64.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|x64.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|x86.ActiveCfg = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Debug|x86.Build.0 = Debug|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|Any CPU.Build.0 = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|ARM.ActiveCfg = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|ARM.Build.0 = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|iPhone.ActiveCfg = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|iPhone.Build.0 = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {36FC3269-B7D0-4D79-A54A-B26B6190E8A2}.Release|x64.ActiveCfg = Release|Any CPU + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From bee2b58fa3aa34d75dc51b0cf09d499991c060c4 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Wed, 12 Jun 2019 06:33:49 +0300 Subject: [PATCH 02/24] Fixed ReactivePage.OnViewModelChanging implementation --- src/ReactiveUI.Uno/ReactivePage.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ReactiveUI.Uno/ReactivePage.cs b/src/ReactiveUI.Uno/ReactivePage.cs index 360041250c..6ad30eefdf 100644 --- a/src/ReactiveUI.Uno/ReactivePage.cs +++ b/src/ReactiveUI.Uno/ReactivePage.cs @@ -47,6 +47,10 @@ protected override void OnDataContextChanged() private static void OnViewModelChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) { + if (dependencyObject is IDataContextProvider dcp) + { + dcp.DataContext = args.NewValue; + } } } } From 009d692365bf1b9b55c6fafa02ea6157d17c41a3 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Mon, 17 Jun 2019 07:47:36 +0300 Subject: [PATCH 03/24] Added Uno platform initial support --- src/ReactiveUI.Uno/GlobalSuppressions.cs | 19 ++++-- src/ReactiveUI.Uno/ReactivePage.cs | 56 ----------------- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 17 ++++- .../net461/GeneratedInternalTypeHelper.g.cs | 62 +------------------ .../Platforms/uap/ActivationForViewFetcher.cs | 4 +- .../AutoDataTemplateBindingHook.cs | 4 +- .../windows-common/BooleanToVisibilityHint.cs | 4 +- .../BooleanToVisibilityTypeConverter.cs | 4 +- .../windows-common/PlatformOperations.cs | 2 +- .../windows-common/ReactiveUserControl.cs | 2 +- .../windows-common/RoutedViewHost.cs | 2 +- 11 files changed, 42 insertions(+), 134 deletions(-) delete mode 100644 src/ReactiveUI.Uno/ReactivePage.cs diff --git a/src/ReactiveUI.Uno/GlobalSuppressions.cs b/src/ReactiveUI.Uno/GlobalSuppressions.cs index 3e7a416ca0..724ec5c4ed 100644 --- a/src/ReactiveUI.Uno/GlobalSuppressions.cs +++ b/src/ReactiveUI.Uno/GlobalSuppressions.cs @@ -1,10 +1,21 @@ - -// This file is used by Code Analysis to maintain SuppressMessage +// 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. + +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. -// Project-level suppressions either have no target or are given +// Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. - [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1158:Static member in generic type should use a type parameter.", Justification = "", Scope = "member", Target = "~F:ReactiveUI.Uno.ReactivePage`1.ViewModelProperty")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ReactiveUserControl`1")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ReactiveUserControl`1")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.RoutedViewHost")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.RoutedViewHost")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.TransitioningContentControl")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.TransitioningContentControl")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ViewModelViewHost")] +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ViewModelViewHost")] \ No newline at end of file diff --git a/src/ReactiveUI.Uno/ReactivePage.cs b/src/ReactiveUI.Uno/ReactivePage.cs deleted file mode 100644 index 6ad30eefdf..0000000000 --- a/src/ReactiveUI.Uno/ReactivePage.cs +++ /dev/null @@ -1,56 +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 Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ReactiveUI.Uno -{ - /// - /// This is a that is also an . - /// - /// The type of the view model. - public class ReactivePage : Page, IViewFor - where TViewModel : class - { - /// - /// The view model bindable property. - /// - public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register( - nameof(ViewModel), - typeof(TViewModel), - typeof(ReactivePage), - new PropertyMetadata(default, OnViewModelChanged)); - - /// - public TViewModel ViewModel - { - get => (TViewModel)GetValue(ViewModelProperty); - set => SetValue(ViewModelProperty, value); - } - - /// - object IViewFor.ViewModel - { - get => ViewModel; - set => ViewModel = (TViewModel)value; - } - - /// - protected override void OnDataContextChanged() - { - base.OnDataContextChanged(); - ViewModel = DataContext as TViewModel; - } - - private static void OnViewModelChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) - { - if (dependencyObject is IDataContextProvider dcp) - { - dcp.DataContext = args.NewValue; - } - } - } -} diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index 012fc09591..4a70a2157c 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -6,7 +6,22 @@ Uno-Platform specific extensions to ReactiveUI netstandard2.0 - + + + HAS_UNO + + + + + + + + + + + + + diff --git a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs index 136dd1ba9b..c65238fb38 100644 --- a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs +++ b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs @@ -1,62 +1,2 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace XamlGeneratedNamespace { - - - /// - /// GeneratedInternalTypeHelper - /// - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper { - - /// - /// CreateInstance - /// - protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) { - return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) - | (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture); - } - - /// - /// GetPropertyValue - /// - protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) { - return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture); - } - - /// - /// SetPropertyValue - /// - protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) { - propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture); - } - - /// - /// CreateDelegate - /// - protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) { - return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod - | (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] { - delegateType, - handler}, null))); - } - - /// - /// AddEventHandler - /// - protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) { - eventInfo.AddEventHandler(target, handler); - } - } -} + diff --git a/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs b/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs index c2070d81de..b9ed713dda 100644 --- a/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs +++ b/src/ReactiveUI/Platforms/uap/ActivationForViewFetcher.cs @@ -7,8 +7,6 @@ using System.Linq; using System.Reactive.Linq; using System.Reflection; -using System.Windows; - using Windows.UI.Xaml; namespace ReactiveUI @@ -51,4 +49,4 @@ public IObservable GetActivationForView(IActivatable view) .DistinctUntilChanged(); } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs b/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs index 9625e81af3..0883cda32e 100644 --- a/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs +++ b/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs @@ -6,7 +6,7 @@ using System; using System.Linq; -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Markup; @@ -30,7 +30,7 @@ public class AutoDataTemplateBindingHook : IPropertyBindingHook /// public static Lazy DefaultItemTemplate { get; } = new Lazy(() => { -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO const string template = "" + "" + ""; diff --git a/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityHint.cs b/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityHint.cs index 96dd5183fa..630789ba90 100644 --- a/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityHint.cs +++ b/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityHint.cs @@ -5,7 +5,7 @@ using System; using System.Diagnostics.CodeAnalysis; -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO using Windows.UI.Xaml; #else using System.Windows; @@ -30,7 +30,7 @@ public enum BooleanToVisibilityHint /// Inverse = 1 << 1, -#if !NETFX_CORE +#if !NETFX_CORE && !HAS_UNO /// /// Use the hidden version rather than the Collapsed. /// diff --git a/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityTypeConverter.cs b/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityTypeConverter.cs index a93f03c301..9836336249 100644 --- a/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityTypeConverter.cs +++ b/src/ReactiveUI/Platforms/windows-common/BooleanToVisibilityTypeConverter.cs @@ -4,7 +4,7 @@ // See the LICENSE file in the project root for full license information. using System; -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO using Windows.UI.Xaml; #else using System.Windows; @@ -44,7 +44,7 @@ public bool TryConvert(object from, Type toType, object conversionHint, out obje if (toType == typeof(Visibility)) { var fromAsBool = hint.HasFlag(BooleanToVisibilityHint.Inverse) ? !(bool)@from : (bool)from; -#if !NETFX_CORE +#if !NETFX_CORE && !HAS_UNO var notVisible = hint.HasFlag(BooleanToVisibilityHint.UseHidden) ? Visibility.Hidden : Visibility.Collapsed; #else var notVisible = Visibility.Collapsed; diff --git a/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs b/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs index dd872681f5..d63d06bef0 100644 --- a/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs +++ b/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs @@ -19,7 +19,7 @@ public class PlatformOperations : IPlatformOperations /// public string GetOrientation() { -#if NETFX_CORE +#if !NETFX_CORE return Windows.Graphics.Display.DisplayInformation.GetForCurrentView().CurrentOrientation.ToString(); #else return null; diff --git a/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs b/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs index a9b7b2a705..b36f4a6f70 100755 --- a/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs +++ b/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs @@ -5,7 +5,7 @@ namespace ReactiveUI { -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; #else diff --git a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs index e48eb30616..b9cbde5c17 100644 --- a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs @@ -11,7 +11,7 @@ using ReactiveUI; using Splat; -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; #else From 21ae794f3130a7d8aad0369dd2c6cf1af8f38011 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Mon, 17 Jun 2019 07:55:44 +0300 Subject: [PATCH 04/24] Fixed linked files references --- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 9 ++------- .../Platforms/windows-common/ViewModelViewHost.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index 4a70a2157c..db20f03702 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -11,16 +11,11 @@ HAS_UNO + + - - - - - - - diff --git a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs index 3f7ccf1154..a10d56545f 100644 --- a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs @@ -11,7 +11,7 @@ using System.Windows; using Splat; -#if NETFX_CORE +#if NETFX_CORE || HAS_UNO using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; #else @@ -25,7 +25,12 @@ namespace ReactiveUI /// the ViewModel property and display it. This control is very useful /// inside a DataTemplate to display the View associated with a ViewModel. /// - public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger, IDisposable + public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger +#if !HAS_UNO +#pragma warning disable SA1001 // Commas should be spaced correctly + , IDisposable +#pragma warning restore SA1001 // Commas should be spaced correctly +#endif { /// /// The default content dependency property. From 99e1f39fe4f4d5aabee46c20292b5b64e2e88283 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Mon, 17 Jun 2019 08:24:19 +0300 Subject: [PATCH 05/24] Fix wrong preprocessor directive --- src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs b/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs index d63d06bef0..85146be577 100644 --- a/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs +++ b/src/ReactiveUI/Platforms/windows-common/PlatformOperations.cs @@ -19,7 +19,7 @@ public class PlatformOperations : IPlatformOperations /// public string GetOrientation() { -#if !NETFX_CORE +#if NETFX_CORE || HAS_UNO return Windows.Graphics.Display.DisplayInformation.GetForCurrentView().CurrentOrientation.ToString(); #else return null; From c284a5e045b6da3523684218425f523f1a074406 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 17 Jun 2019 15:52:48 +1000 Subject: [PATCH 06/24] Fixes --- build.cake | 2 ++ .../ReactiveUI.Events.Uno.csproj | 16 ++++++++++++++++ src/ReactiveUI.Fody.Tests/FodyWeavers.xsd | 1 - src/ReactiveUI.Uno/GlobalSuppressions.cs | 10 ---------- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 10 ++-------- 5 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj delete mode 100644 src/ReactiveUI.Uno/GlobalSuppressions.cs diff --git a/build.cake b/build.cake index 0c0e13e2fb..cf872302b6 100644 --- a/build.cake +++ b/build.cake @@ -20,10 +20,12 @@ var packageWhitelist = new List MakeAbsolute(File("./src/ReactiveUI.Events/ReactiveUI.Events.csproj")), MakeAbsolute(File("./src/ReactiveUI.Events.XamEssentials/ReactiveUI.Events.XamEssentials.csproj")), MakeAbsolute(File("./src/ReactiveUI.Events.XamForms/ReactiveUI.Events.XamForms.csproj")), + MakeAbsolute(File("./src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj")), MakeAbsolute(File("./src/ReactiveUI.Fody/ReactiveUI.Fody.csproj")), MakeAbsolute(File("./src/ReactiveUI.Fody.Helpers/ReactiveUI.Fody.Helpers.csproj")), MakeAbsolute(File("./src/ReactiveUI.AndroidSupport/ReactiveUI.AndroidSupport.csproj")), MakeAbsolute(File("./src/ReactiveUI.XamForms/ReactiveUI.XamForms.csproj")), + MakeAbsolute(File("./src/ReactiveUI.Uno/ReactiveUI.Uno.csproj")), }; if (IsRunningOnWindows()) diff --git a/src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj b/src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj new file mode 100644 index 0000000000..db0509e152 --- /dev/null +++ b/src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj @@ -0,0 +1,16 @@ + + + netstandard2.0 + ReactiveUI.Events + Provides Observable-based events API for Uno UI controls/eventhandlers. The contents of this package is automatically generated, please target pull-requests to the code generator. + ReactiveUI.Events.Uno + $(NoWarn);CS1570;CA1812 + + + + + + + + + diff --git a/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd b/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd index 5cedd530b9..f3ac47620a 100644 --- a/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd +++ b/src/ReactiveUI.Fody.Tests/FodyWeavers.xsd @@ -4,7 +4,6 @@ - diff --git a/src/ReactiveUI.Uno/GlobalSuppressions.cs b/src/ReactiveUI.Uno/GlobalSuppressions.cs deleted file mode 100644 index 3e7a416ca0..0000000000 --- a/src/ReactiveUI.Uno/GlobalSuppressions.cs +++ /dev/null @@ -1,10 +0,0 @@ - -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1158:Static member in generic type should use a type parameter.", Justification = "", Scope = "member", Target = "~F:ReactiveUI.Uno.ReactivePage`1.ViewModelProperty")] - diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index 012fc09591..5dd73dd508 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -1,11 +1,8 @@  - xamarinmac20;MonoAndroid90;xamarinios10;netstandard2.0 - $(TargetFrameworks);uap10.0.17763 + netstandard2.0 ReactiveUI.Uno - Uno-Platform specific extensions to ReactiveUI - netstandard2.0 @@ -14,10 +11,7 @@ + - - - - \ No newline at end of file From fc9e3bc17428e4aa1ff1310b477f8af989c4d8e4 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Mon, 17 Jun 2019 22:44:48 +0300 Subject: [PATCH 07/24] Updated message suppression --- src/ReactiveUI.Uno/GlobalSuppressions.cs | 21 ------- .../net461/GeneratedInternalTypeHelper.g.cs | 62 ++++++++++++++++++- .../uap/TransitioningContentControl.Empty.cs | 2 + .../AutoDataTemplateBindingHook.cs | 7 ++- .../windows-common/ReactiveUserControl.cs | 2 + .../windows-common/RoutedViewHost.cs | 2 + .../windows-common/ViewModelViewHost.cs | 2 + 7 files changed, 73 insertions(+), 25 deletions(-) delete mode 100644 src/ReactiveUI.Uno/GlobalSuppressions.cs diff --git a/src/ReactiveUI.Uno/GlobalSuppressions.cs b/src/ReactiveUI.Uno/GlobalSuppressions.cs deleted file mode 100644 index 724ec5c4ed..0000000000 --- a/src/ReactiveUI.Uno/GlobalSuppressions.cs +++ /dev/null @@ -1,21 +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. - -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.Uno.ReactivePage`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1158:Static member in generic type should use a type parameter.", Justification = "", Scope = "member", Target = "~F:ReactiveUI.Uno.ReactivePage`1.ViewModelProperty")] - -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ReactiveUserControl`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ReactiveUserControl`1")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.RoutedViewHost")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.RoutedViewHost")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.TransitioningContentControl")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.TransitioningContentControl")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ViewModelViewHost")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "", Scope = "type", Target = "~T:ReactiveUI.ViewModelViewHost")] \ No newline at end of file diff --git a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs index c65238fb38..136dd1ba9b 100644 --- a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs +++ b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs @@ -1,2 +1,62 @@ - +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace XamlGeneratedNamespace { + + + /// + /// GeneratedInternalTypeHelper + /// + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper { + + /// + /// CreateInstance + /// + protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) { + return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) + | (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture); + } + + /// + /// GetPropertyValue + /// + protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) { + return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture); + } + + /// + /// SetPropertyValue + /// + protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) { + propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture); + } + + /// + /// CreateDelegate + /// + protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) { + return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod + | (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] { + delegateType, + handler}, null))); + } + + /// + /// AddEventHandler + /// + protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) { + eventInfo.AddEventHandler(target, handler); + } + } +} diff --git a/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs b/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs index 7d6707470c..c49282b728 100644 --- a/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs +++ b/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs @@ -3,6 +3,7 @@ // 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.Diagnostics.CodeAnalysis; using Windows.UI.Xaml.Controls; namespace ReactiveUI @@ -10,6 +11,7 @@ namespace ReactiveUI /// /// A control with a single transition. /// + [SuppressMessage("Design", "CA1010", Justification = "Not required")] public class TransitioningContentControl : ContentControl { } diff --git a/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs b/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs index 0883cda32e..66488417ee 100644 --- a/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs +++ b/src/ReactiveUI/Platforms/windows-common/AutoDataTemplateBindingHook.cs @@ -31,9 +31,10 @@ public class AutoDataTemplateBindingHook : IPropertyBindingHook public static Lazy DefaultItemTemplate { get; } = new Lazy(() => { #if NETFX_CORE || HAS_UNO - const string template = "" + - "" + - ""; + const string template = +@" + +"; return (DataTemplate)XamlReader.Load(template); #else const string template = " /// The type of the view model backing the view. /// + [SuppressMessage("Design", "CA1010", Justification = "Not required")] public abstract class ReactiveUserControl : UserControl, IViewFor where TViewModel : class diff --git a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs index b9cbde5c17..d8199d3560 100644 --- a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reactive.Linq; using System.Windows; @@ -25,6 +26,7 @@ namespace ReactiveUI /// the View and wire up the ViewModel whenever a new ViewModel is /// navigated to. Put this control as the only control in your Window. /// + [SuppressMessage("Design", "CA1010", Justification = "Not required")] public class RoutedViewHost : TransitioningContentControl, IActivatable, IEnableLogger { /// diff --git a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs index a10d56545f..0cbd55f6a5 100644 --- a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.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.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; @@ -25,6 +26,7 @@ namespace ReactiveUI /// the ViewModel property and display it. This control is very useful /// inside a DataTemplate to display the View associated with a ViewModel. /// + [SuppressMessage("Design", "CA1010", Justification = "Not required")] public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger #if !HAS_UNO #pragma warning disable SA1001 // Commas should be spaced correctly From 3472b76c7c5a589de647ed65e65b52fb63fb60d3 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Mon, 17 Jun 2019 22:47:24 +0300 Subject: [PATCH 08/24] Expanded suppression messages --- .../Platforms/uap/TransitioningContentControl.Empty.cs | 2 +- src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs | 2 +- src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs | 2 +- src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs b/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs index c49282b728..fce59720d9 100644 --- a/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs +++ b/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs @@ -11,7 +11,7 @@ namespace ReactiveUI /// /// A control with a single transition. /// - [SuppressMessage("Design", "CA1010", Justification = "Not required")] + [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] public class TransitioningContentControl : ContentControl { } diff --git a/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs b/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs index 5e2832125e..2b38b7e2b6 100755 --- a/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs +++ b/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs @@ -77,7 +77,7 @@ namespace ReactiveUI /// /// The type of the view model backing the view. /// - [SuppressMessage("Design", "CA1010", Justification = "Not required")] + [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] public abstract class ReactiveUserControl : UserControl, IViewFor where TViewModel : class diff --git a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs index d8199d3560..dcc1c0a12e 100644 --- a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs @@ -26,7 +26,7 @@ namespace ReactiveUI /// the View and wire up the ViewModel whenever a new ViewModel is /// navigated to. Put this control as the only control in your Window. /// - [SuppressMessage("Design", "CA1010", Justification = "Not required")] + [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] public class RoutedViewHost : TransitioningContentControl, IActivatable, IEnableLogger { /// diff --git a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs index 0cbd55f6a5..0309aaa672 100644 --- a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs @@ -26,7 +26,7 @@ namespace ReactiveUI /// the ViewModel property and display it. This control is very useful /// inside a DataTemplate to display the View associated with a ViewModel. /// - [SuppressMessage("Design", "CA1010", Justification = "Not required")] + [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger #if !HAS_UNO #pragma warning disable SA1001 // Commas should be spaced correctly From 780abf217020e45efbe222c0a167b5489a96301d Mon Sep 17 00:00:00 2001 From: Shimmy <2716316+weitzhandler@users.noreply.github.com> Date: Mon, 17 Jun 2019 22:54:21 +0300 Subject: [PATCH 09/24] Deleting g.cs file manually --- .../net461/GeneratedInternalTypeHelper.g.cs | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs diff --git a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs b/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs deleted file mode 100644 index 136dd1ba9b..0000000000 --- a/src/ReactiveUI.Wpf/obj/Debug/net461/GeneratedInternalTypeHelper.g.cs +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace XamlGeneratedNamespace { - - - /// - /// GeneratedInternalTypeHelper - /// - [System.Diagnostics.DebuggerNonUserCodeAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper { - - /// - /// CreateInstance - /// - protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) { - return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) - | (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture); - } - - /// - /// GetPropertyValue - /// - protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) { - return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture); - } - - /// - /// SetPropertyValue - /// - protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) { - propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture); - } - - /// - /// CreateDelegate - /// - protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) { - return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod - | (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] { - delegateType, - handler}, null))); - } - - /// - /// AddEventHandler - /// - protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) { - eventInfo.AddEventHandler(target, handler); - } - } -} - From 684c97991de205376063b7f279d225defd0fbb65 Mon Sep 17 00:00:00 2001 From: Geoffrey Huntley Date: Tue, 18 Jun 2019 12:51:57 +1000 Subject: [PATCH 10/24] extensions for reactiveui --- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index db20f03702..30faf49a94 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -4,7 +4,7 @@ $(TargetFrameworks);uap10.0.17763 ReactiveUI.Uno - Uno-Platform specific extensions to ReactiveUI + Uno-Platform specific extensions for ReactiveUI netstandard2.0 @@ -30,4 +30,4 @@ - \ No newline at end of file + From ba001818b9313dc6b4ee0295d014633df8493515 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Tue, 18 Jun 2019 06:22:24 +0300 Subject: [PATCH 11/24] Remove HAS_UNO directive from production --- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index 30faf49a94..1566709680 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -6,8 +6,8 @@ Uno-Platform specific extensions for ReactiveUI netstandard2.0 - - + + HAS_UNO From 74976853492eb8875c5a444a4cb6642a958e7c5d Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Tue, 18 Jun 2019 06:24:36 +0300 Subject: [PATCH 12/24] Updated Uno Platform brand name --- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index 1566709680..f659cbeb90 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -4,7 +4,7 @@ $(TargetFrameworks);uap10.0.17763 ReactiveUI.Uno - Uno-Platform specific extensions for ReactiveUI + Uno Platform specific extensions for ReactiveUI netstandard2.0 From 36bdda5b2d0e26dce21858b5f84ad034bdc98067 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Tue, 18 Jun 2019 06:32:43 +0300 Subject: [PATCH 13/24] Updated Reactive.Wasm to the new NuGet package --- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index f659cbeb90..7cc82bf4c2 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -27,7 +27,7 @@ - + From 0e3932c6d4846311dfcfd6173efda9e9526f86d4 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 18 Jun 2019 14:30:28 +1000 Subject: [PATCH 14/24] Add back in the ReactivePage.cs --- src/ReactiveUI.Uno/ReactivePage.cs | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/ReactiveUI.Uno/ReactivePage.cs diff --git a/src/ReactiveUI.Uno/ReactivePage.cs b/src/ReactiveUI.Uno/ReactivePage.cs new file mode 100644 index 0000000000..440d3a43d0 --- /dev/null +++ b/src/ReactiveUI.Uno/ReactivePage.cs @@ -0,0 +1,56 @@ +// 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 Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace ReactiveUI.Uno +{ + /// + /// This is a that is also an . + /// + /// The type of the view model. + public class ReactivePage : Page, IViewFor + where TViewModel : class + { + /// + /// The view model bindable property. + /// + public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register( + nameof(ViewModel), + typeof(TViewModel), + typeof(ReactivePage), + new PropertyMetadata(default, OnViewModelChanged)); + + /// + public TViewModel ViewModel + { + get => (TViewModel)GetValue(ViewModelProperty); + set => SetValue(ViewModelProperty, value); + } + + /// + object IViewFor.ViewModel + { + get => ViewModel; + set => ViewModel = (TViewModel)value; + } + + /// + protected override void OnDataContextChanged() + { + base.OnDataContextChanged(); + ViewModel = DataContext as TViewModel; + } + + private static void OnViewModelChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) + { + if (dependencyObject is IDataContextProvider dcp) + { + dcp.DataContext = args.NewValue; + } + } + } +} From 14ea2194fae056cd181f9a5d06157b79e20e234d Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 18 Jun 2019 14:59:43 +1000 Subject: [PATCH 15/24] remove the reactive page since that will be added to the windows-common project --- src/ReactiveUI.Uno/ReactivePage.cs | 56 ------------------------------ 1 file changed, 56 deletions(-) delete mode 100644 src/ReactiveUI.Uno/ReactivePage.cs diff --git a/src/ReactiveUI.Uno/ReactivePage.cs b/src/ReactiveUI.Uno/ReactivePage.cs deleted file mode 100644 index 440d3a43d0..0000000000 --- a/src/ReactiveUI.Uno/ReactivePage.cs +++ /dev/null @@ -1,56 +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 Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ReactiveUI.Uno -{ - /// - /// This is a that is also an . - /// - /// The type of the view model. - public class ReactivePage : Page, IViewFor - where TViewModel : class - { - /// - /// The view model bindable property. - /// - public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register( - nameof(ViewModel), - typeof(TViewModel), - typeof(ReactivePage), - new PropertyMetadata(default, OnViewModelChanged)); - - /// - public TViewModel ViewModel - { - get => (TViewModel)GetValue(ViewModelProperty); - set => SetValue(ViewModelProperty, value); - } - - /// - object IViewFor.ViewModel - { - get => ViewModel; - set => ViewModel = (TViewModel)value; - } - - /// - protected override void OnDataContextChanged() - { - base.OnDataContextChanged(); - ViewModel = DataContext as TViewModel; - } - - private static void OnViewModelChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) - { - if (dependencyObject is IDataContextProvider dcp) - { - dcp.DataContext = args.NewValue; - } - } - } -} From 335034d08b2dd9c328dbfd2e67f33655e8021bcc Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Wed, 19 Jun 2019 07:35:24 +0300 Subject: [PATCH 16/24] Add Uno to RxUI initialization --- src/ReactiveUI/Mixins/DependencyResolverMixins.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs index 8f500dabb5..7bbb31af68 100644 --- a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs +++ b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs @@ -31,7 +31,8 @@ public static void InitializeReactiveUI(this IMutableDependencyResolver resolver { "ReactiveUI.XamForms", "ReactiveUI.Winforms", - "ReactiveUI.Wpf" + "ReactiveUI.Wpf", + "ReactiveUI.Uno" }; // Set up the built-in registration From 9f064fbab441d30bf59014473f68702968df77cc Mon Sep 17 00:00:00 2001 From: Shimmy <2716316+weitzhandler@users.noreply.github.com> Date: Wed, 19 Jun 2019 08:32:09 +0300 Subject: [PATCH 17/24] Added some README stuff about Uno --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1ed01c905c..b973c7fde8 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Install the following packages to start building your own ReactiveUI app. Not | Xamarin.Mac | [ReactiveUI][MacDoc] | [![CoreBadge]][Core] | [ReactiveUI.Events][CoreEvents] | | Tizen | [ReactiveUI][CoreDoc] | [![CoreBadge]][Core] | [ReactiveUI.Events][CoreEvents] | | Avalonia | [Avalonia.ReactiveUI][AvaDoc] | [![AvaBadge]][Ava] | None | +| Uno | [ReactiveUI.Uno][UnoDoc] | | None | | Any | [ReactiveUI.Validation][ValidationsDocs] | [![ValidationsBadge]][ValidationsCore] | None [Core]: https://www.nuget.org/packages/ReactiveUI/ From a1db0c2e8c08050552a331883cd9a19a744f0d11 Mon Sep 17 00:00:00 2001 From: Shimmy <2716316+weitzhandler@users.noreply.github.com> Date: Wed, 19 Jun 2019 08:35:53 +0300 Subject: [PATCH 18/24] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b973c7fde8..53ee86376c 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Install the following packages to start building your own ReactiveUI app. Not [TestDoc]: https://reactiveui.net/docs/handbook/testing/ [UniDoc]: https://reactiveui.net/docs/getting-started/installation/universal-windows-platform +[UnoDoc]: https://reactiveui.net/docs/getting-started/installation/universal-windows-platform [Wpf]: https://www.nuget.org/packages/ReactiveUI.WPF/ [WpfEvents]: https://www.nuget.org/packages/ReactiveUI.Events.WPF/ From fe9c1c76ca396f4452807f4460a2c81fcc1bbe32 Mon Sep 17 00:00:00 2001 From: Shimmy Weitzhandler <2716316+weitzhandler@users.noreply.github.com> Date: Wed, 19 Jun 2019 09:34:42 +0300 Subject: [PATCH 19/24] Reverted README changes --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 53ee86376c..1ed01c905c 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ Install the following packages to start building your own ReactiveUI app. Not | Xamarin.Mac | [ReactiveUI][MacDoc] | [![CoreBadge]][Core] | [ReactiveUI.Events][CoreEvents] | | Tizen | [ReactiveUI][CoreDoc] | [![CoreBadge]][Core] | [ReactiveUI.Events][CoreEvents] | | Avalonia | [Avalonia.ReactiveUI][AvaDoc] | [![AvaBadge]][Ava] | None | -| Uno | [ReactiveUI.Uno][UnoDoc] | | None | | Any | [ReactiveUI.Validation][ValidationsDocs] | [![ValidationsBadge]][ValidationsCore] | None [Core]: https://www.nuget.org/packages/ReactiveUI/ @@ -79,7 +78,6 @@ Install the following packages to start building your own ReactiveUI app. Not [TestDoc]: https://reactiveui.net/docs/handbook/testing/ [UniDoc]: https://reactiveui.net/docs/getting-started/installation/universal-windows-platform -[UnoDoc]: https://reactiveui.net/docs/getting-started/installation/universal-windows-platform [Wpf]: https://www.nuget.org/packages/ReactiveUI.WPF/ [WpfEvents]: https://www.nuget.org/packages/ReactiveUI.Events.WPF/ From aaf53e7792ee889f9f2a0acd3bf65e3aa3683804 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 25 Jun 2019 15:36:52 +1000 Subject: [PATCH 20/24] adding results to parent directories --- .../ReactiveUI.Events.Uno.csproj | 16 ---- .../ActivationForViewFetcher.cs | 67 +++++++++++++++++ src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 30 ++++++-- src/ReactiveUI.Uno/WinRTAppDataDriver.cs | 74 +++++++++++++++++++ .../netstandard/PlatformRegistrations.cs | 30 ++++++++ 5 files changed, 194 insertions(+), 23 deletions(-) delete mode 100644 src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj create mode 100644 src/ReactiveUI.Uno/ActivationForViewFetcher.cs create mode 100644 src/ReactiveUI.Uno/WinRTAppDataDriver.cs create mode 100644 src/ReactiveUI.Uno/platforms/netstandard/PlatformRegistrations.cs diff --git a/src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj b/src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj deleted file mode 100644 index db3a1332b7..0000000000 --- a/src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;MonoAndroid81;MonoAndroid90 - ReactiveUI.Events - Provides Observable-based events API for Uno UI controls/eventhandlers. The contents of this package is automatically generated, please target pull-requests to the code generator. - ReactiveUI.Events.Uno - $(NoWarn);CS1570;CA1812 - - - - - - - - - diff --git a/src/ReactiveUI.Uno/ActivationForViewFetcher.cs b/src/ReactiveUI.Uno/ActivationForViewFetcher.cs new file mode 100644 index 0000000000..8e34880d5b --- /dev/null +++ b/src/ReactiveUI.Uno/ActivationForViewFetcher.cs @@ -0,0 +1,67 @@ +// 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. + +#if HAS_UNO +using System; +using System.Linq; +using System.Reactive; +using System.Reactive.Linq; +using System.Reflection; + +using Windows.Foundation; +using Windows.UI.Xaml; + +namespace ReactiveUI +{ + /// + /// ActiveationForViewFetcher is how ReactiveUI determine when a + /// View is activated or deactivated. This is usually only used when porting + /// ReactiveUI to a new UI framework. + /// + public class ActivationForViewFetcher : IActivationForViewFetcher + { + /// + public int GetAffinityForView(Type view) + { + return typeof(FrameworkElement).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ? 10 : 0; + } + + /// + public IObservable GetActivationForView(IActivatable view) + { + var fe = view as FrameworkElement; + + if (fe == null) + { + return Observable.Empty; + } + + var viewLoaded = Observable.FromEvent( + eventHandler => + { + void Handler(object sender, RoutedEventArgs e) => eventHandler(true); + return Handler; + }, + x => fe.Loading += x, + x => fe.Loading -= x); + + var viewUnloaded = Observable.FromEvent( + handler => + { + void EventHandler(object sender, RoutedEventArgs e) => handler(false); + return EventHandler; + }, + x => fe.Unloaded += x, + x => fe.Unloaded -= x); + + return viewLoaded + .Merge(viewUnloaded) + .Select(b => b ? fe.WhenAnyValue(x => x.IsHitTestVisible).SkipWhile(x => !x) : Observables.False) + .Switch() + .DistinctUntilChanged(); + } + } +} +#endif diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index edfe2d53ee..ec1aba88a9 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -1,24 +1,40 @@  - netstandard2.0 + netstandard2.0;MonoAndroid81 ReactiveUI.Uno Uno Platform specific extensions for ReactiveUI HAS_UNO + $(NoWarn);SA1648;CA1816;CA1001;CS0108;CS0114 - - + + + - + + + + + + + + + + + + + + + - - - + + + diff --git a/src/ReactiveUI.Uno/WinRTAppDataDriver.cs b/src/ReactiveUI.Uno/WinRTAppDataDriver.cs new file mode 100644 index 0000000000..0c36002ff0 --- /dev/null +++ b/src/ReactiveUI.Uno/WinRTAppDataDriver.cs @@ -0,0 +1,74 @@ +// 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 +{ + /// + /// 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'); + 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) + { + 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.Uno/platforms/netstandard/PlatformRegistrations.cs b/src/ReactiveUI.Uno/platforms/netstandard/PlatformRegistrations.cs new file mode 100644 index 0000000000..c7080fe789 --- /dev/null +++ b/src/ReactiveUI.Uno/platforms/netstandard/PlatformRegistrations.cs @@ -0,0 +1,30 @@ +// 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 +{ + /// + /// UWP platform registrations. + /// + /// + public class PlatformRegistrations : IWantsToRegisterStuff + { + /// + public void Register(Action, Type> registerFunction) + { + registerFunction(() => new PlatformOperations(), typeof(IPlatformOperations)); + registerFunction(() => new ActivationForViewFetcher(), typeof(IActivationForViewFetcher)); + registerFunction(() => new DependencyObjectObservableForProperty(), typeof(ICreatesObservableForProperty)); + registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter)); + registerFunction(() => new AutoDataTemplateBindingHook(), typeof(IPropertyBindingHook)); + RxApp.TaskpoolScheduler = WasmScheduler.Default; + RxApp.MainThreadScheduler = WasmScheduler.Default; + registerFunction(() => new WinRTAppDataDriver(), typeof(ISuspensionDriver)); + } + } +} From f6148b75aca56dc7d32dea80f100cdb479ef46d6 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 26 Jun 2019 12:13:22 +1000 Subject: [PATCH 21/24] Further work on getting uno in --- .../ActivationForViewFetcher.cs | 13 +- src/ReactiveUI.Uno/CoreDispatcherScheduler.cs | 251 ++++++++++++++++++ .../netstandard => }/PlatformRegistrations.cs | 17 +- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 17 +- .../uap/TransitioningContentControl.Empty.cs | 6 +- .../Platforms/windows-common/ReactivePage.cs | 10 +- .../windows-common/ReactiveUserControl.cs | 10 +- .../windows-common/RoutedViewHost.cs | 6 +- .../windows-common/ViewModelViewHost.cs | 6 +- 9 files changed, 309 insertions(+), 27 deletions(-) create mode 100644 src/ReactiveUI.Uno/CoreDispatcherScheduler.cs rename src/ReactiveUI.Uno/{platforms/netstandard => }/PlatformRegistrations.cs (71%) diff --git a/src/ReactiveUI.Uno/ActivationForViewFetcher.cs b/src/ReactiveUI.Uno/ActivationForViewFetcher.cs index 8e34880d5b..2c0304a17f 100644 --- a/src/ReactiveUI.Uno/ActivationForViewFetcher.cs +++ b/src/ReactiveUI.Uno/ActivationForViewFetcher.cs @@ -3,7 +3,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for full license information. -#if HAS_UNO using System; using System.Linq; using System.Reactive; @@ -38,12 +37,13 @@ public IObservable GetActivationForView(IActivatable view) return Observable.Empty; } +#pragma warning disable SA1114 // Parameter list after. +#if NETSTANDARD || MAC var viewLoaded = Observable.FromEvent( - eventHandler => - { - void Handler(object sender, RoutedEventArgs e) => eventHandler(true); - return Handler; - }, +#else + var viewLoaded = Observable.FromEvent, bool>( +#endif + eventHandler => (_, __) => eventHandler(true), x => fe.Loading += x, x => fe.Loading -= x); @@ -64,4 +64,3 @@ public IObservable GetActivationForView(IActivatable view) } } } -#endif diff --git a/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs b/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs new file mode 100644 index 0000000000..de999eff51 --- /dev/null +++ b/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs @@ -0,0 +1,251 @@ +// 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.Runtime.ExceptionServices; +using System.Text; +using System.Threading; + +using Windows.UI.Core; +using Windows.UI.Xaml; + +namespace System.Reactive.Concurrency +{ + /// + /// Represents an object that schedules units of work on a . + /// + /// + /// This scheduler type is typically used indirectly through the and methods that use the current Dispatcher. + /// + [CLSCompliant(false)] + public sealed class CoreDispatcherScheduler : LocalScheduler, ISchedulerPeriodic + { + /// + /// Constructs a that schedules units of work on the given . + /// + /// Dispatcher to schedule work on. + /// is null. + public CoreDispatcherScheduler(CoreDispatcher dispatcher) + { + Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); + Priority = CoreDispatcherPriority.Normal; + } + + /// + /// Constructs a that schedules units of work on the given with the given priority. + /// + /// Dispatcher to schedule work on. + /// Priority for scheduled units of work. + /// is null. + public CoreDispatcherScheduler(CoreDispatcher dispatcher, CoreDispatcherPriority priority) + { + Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); + Priority = priority; + } + + /// + /// Gets the scheduler that schedules work on the associated with the current Window. + /// + public static CoreDispatcherScheduler Current + { + get + { + var window = Window.Current; + if (window == null) + { + throw new InvalidOperationException("There is no current window that has been created."); + } + + return new CoreDispatcherScheduler(window.Dispatcher); + } + } + + /// + /// Gets the associated with the . + /// + public CoreDispatcher Dispatcher { get; } + + /// + /// Gets the priority at which work is scheduled. + /// + public CoreDispatcherPriority Priority { get; } + + /// + /// Schedules an action to be executed on the dispatcher. + /// + /// The type of the state passed to the scheduled action. + /// State passed to the action to be executed. + /// Action to be executed. + /// The disposable object used to cancel the scheduled action (best effort). + /// is null. + public override IDisposable Schedule(TState state, Func action) + { + if (action == null) + { + throw new ArgumentNullException(nameof(action)); + } + + var d = new SingleAssignmentDisposable(); + + var res = Dispatcher.RunAsync(Priority, () => + { + if (!d.IsDisposed) + { + try + { + d.Disposable = action(this, state); + } + catch (Exception ex) + { + // + // Work-around for the behavior of throwing from RunAsync not propagating + // the exception to the Application.UnhandledException event (as of W8RP) + // as our users have come to expect from previous XAML stacks using Rx. + // + // If we wouldn't do this, there'd be an observable behavioral difference + // between scheduling with TimeSpan.Zero or using this overload. + // + // For scheduler implementation guidance rules, see TaskPoolScheduler.cs + // in System.Reactive.PlatformServices\Reactive\Concurrency. + // + var timer = new DispatcherTimer + { + Interval = TimeSpan.Zero + }; + timer.Tick += (o, e) => + { + timer.Stop(); + ExceptionDispatchInfo.Capture(ex).Throw(); + }; + + timer.Start(); + } + } + }); + + return StableCompositeDisposable.Create( + d, + Disposable.Create(res, _ => _.Cancel()) + ); + } + + /// + /// Schedules an action to be executed after on the dispatcher, using a object. + /// + /// The type of the state passed to the scheduled action. + /// State passed to the action to be executed. + /// Action to be executed. + /// Relative time after which to execute the action. + /// The disposable object used to cancel the scheduled action (best effort). + /// is null. + public override IDisposable Schedule(TState state, TimeSpan dueTime, Func action) + { + if (action == null) + { + throw new ArgumentNullException(nameof(action)); + } + + var dt = Scheduler.Normalize(dueTime); + if (dt.Ticks == 0) + { + return Schedule(state, action); + } + + return ScheduleSlow(state, dt, action); + } + + private IDisposable ScheduleSlow(TState state, TimeSpan dueTime, Func action) + { + var d = new MultipleAssignmentDisposable(); + + var timer = new DispatcherTimer(); + + timer.Tick += (o, e) => + { + var t = Interlocked.Exchange(ref timer, null); + if (t != null) + { + try + { + d.Disposable = action(this, state); + } + finally + { + t.Stop(); + action = null; + } + } + }; + + timer.Interval = dueTime; + timer.Start(); + + d.Disposable = Disposable.Create(() => + { + var t = Interlocked.Exchange(ref timer, null); + if (t != null) + { + t.Stop(); + action = (_, __) => Disposable.Empty; + } + }); + + return d; + } + + /// + /// Schedules a periodic piece of work on the dispatcher, using a object. + /// + /// The type of the state passed to the scheduled action. + /// Initial state passed to the action upon the first iteration. + /// Period for running the work periodically. + /// Action to be executed, potentially updating the state. + /// The disposable object used to cancel the scheduled recurring action (best effort). + /// is null. + /// is less than . + public IDisposable SchedulePeriodic(TState state, TimeSpan period, Func action) + { + // + // According to MSDN documentation, the default is TimeSpan.Zero, so that's definitely valid. + // Empirical observation - negative values seem to be normalized to TimeSpan.Zero, but let's not go there. + // + if (period < TimeSpan.Zero) + { + throw new ArgumentOutOfRangeException(nameof(period)); + } + + if (action == null) + { + throw new ArgumentNullException(nameof(action)); + } + + var timer = new DispatcherTimer(); + + var state1 = state; + + timer.Tick += (o, e) => + { + state1 = action(state1); + }; + + timer.Interval = period; + timer.Start(); + + return Disposable.Create(() => + { + var t = Interlocked.Exchange(ref timer, null); + if (t != null) + { + t.Stop(); + action = _ => _; + } + }); + } + } +} diff --git a/src/ReactiveUI.Uno/platforms/netstandard/PlatformRegistrations.cs b/src/ReactiveUI.Uno/PlatformRegistrations.cs similarity index 71% rename from src/ReactiveUI.Uno/platforms/netstandard/PlatformRegistrations.cs rename to src/ReactiveUI.Uno/PlatformRegistrations.cs index c7080fe789..635580b71a 100644 --- a/src/ReactiveUI.Uno/platforms/netstandard/PlatformRegistrations.cs +++ b/src/ReactiveUI.Uno/PlatformRegistrations.cs @@ -5,6 +5,7 @@ using System; using System.Reactive.Concurrency; +using System.Reactive.PlatformServices; namespace ReactiveUI { @@ -22,8 +23,20 @@ public void Register(Action, Type> registerFunction) registerFunction(() => new DependencyObjectObservableForProperty(), typeof(ICreatesObservableForProperty)); registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter)); registerFunction(() => new AutoDataTemplateBindingHook(), typeof(IPropertyBindingHook)); - RxApp.TaskpoolScheduler = WasmScheduler.Default; - RxApp.MainThreadScheduler = WasmScheduler.Default; + +#if NETSTANDARD + if (WasmPlatformEnlightenmentProvider.IsWasm) + { + RxApp.TaskpoolScheduler = WasmScheduler.Default; + RxApp.MainThreadScheduler = WasmScheduler.Default; + } + else +#endif + { + RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; + RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => CoreDispatcherScheduler.Current); + } + registerFunction(() => new WinRTAppDataDriver(), typeof(ISuspensionDriver)); } } diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index ec1aba88a9..0378c60847 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -1,10 +1,10 @@  - netstandard2.0;MonoAndroid81 + netstandard20;MonoAndroid81;MonoAndroid90;Xamarin.iOS10;Xamarin.Mac20 ReactiveUI.Uno Uno Platform specific extensions for ReactiveUI HAS_UNO - $(NoWarn);SA1648;CA1816;CA1001;CS0108;CS0114 + $(NoWarn);SA1648;CA1816;CA1001;CS0108;CS0114;CS3021;CS1574;CA1303 @@ -18,22 +18,21 @@ - - - - - + - + + + + - + diff --git a/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs b/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs index fce59720d9..0771c0478f 100644 --- a/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs +++ b/src/ReactiveUI/Platforms/uap/TransitioningContentControl.Empty.cs @@ -12,7 +12,11 @@ namespace ReactiveUI /// A control with a single transition. /// [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] - public class TransitioningContentControl : ContentControl + public +#if HAS_UNO + partial +#endif + class TransitioningContentControl : ContentControl { } } diff --git a/src/ReactiveUI/Platforms/windows-common/ReactivePage.cs b/src/ReactiveUI/Platforms/windows-common/ReactivePage.cs index 2a98bafeae..7a69a74ea9 100644 --- a/src/ReactiveUI/Platforms/windows-common/ReactivePage.cs +++ b/src/ReactiveUI/Platforms/windows-common/ReactivePage.cs @@ -78,9 +78,13 @@ namespace ReactiveUI /// The type of the view model backing the view. /// [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] - public abstract class ReactivePage : - Page, IViewFor - where TViewModel : class + public abstract +#if HAS_UNO + partial +#endif + class ReactivePage : + Page, IViewFor + where TViewModel : class { /// /// The view model dependency property. diff --git a/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs b/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs index 2b38b7e2b6..5514a7fdba 100755 --- a/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs +++ b/src/ReactiveUI/Platforms/windows-common/ReactiveUserControl.cs @@ -78,9 +78,13 @@ namespace ReactiveUI /// The type of the view model backing the view. /// [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] - public abstract class ReactiveUserControl : - UserControl, IViewFor - where TViewModel : class + public abstract +#if HAS_UNO + partial +#endif + class ReactiveUserControl : + UserControl, IViewFor + where TViewModel : class { /// /// The view model dependency property. diff --git a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs index dcc1c0a12e..e32fe5b870 100644 --- a/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/RoutedViewHost.cs @@ -27,7 +27,11 @@ namespace ReactiveUI /// navigated to. Put this control as the only control in your Window. /// [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] - public class RoutedViewHost : TransitioningContentControl, IActivatable, IEnableLogger + public +#if HAS_UNO + partial +#endif + class RoutedViewHost : TransitioningContentControl, IActivatable, IEnableLogger { /// /// The router dependency property. diff --git a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs index 0309aaa672..cf1845a752 100644 --- a/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs +++ b/src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs @@ -27,7 +27,11 @@ namespace ReactiveUI /// inside a DataTemplate to display the View associated with a ViewModel. /// [SuppressMessage("Design", "CA1010:Collections should implement generic interface", Justification = "Deliberate usage")] - public class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger + public +#if HAS_UNO + partial +#endif + class ViewModelViewHost : TransitioningContentControl, IViewFor, IEnableLogger #if !HAS_UNO #pragma warning disable SA1001 // Commas should be spaced correctly , IDisposable From 214b5a8dcd4be5e28c656abcbb4e284cbaf7eedb Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 26 Jun 2019 12:20:25 +1000 Subject: [PATCH 22/24] Remove the events project, will be back in another iteration --- build.cake | 1 - 1 file changed, 1 deletion(-) diff --git a/build.cake b/build.cake index cf872302b6..f5c7106f7e 100644 --- a/build.cake +++ b/build.cake @@ -20,7 +20,6 @@ var packageWhitelist = new List MakeAbsolute(File("./src/ReactiveUI.Events/ReactiveUI.Events.csproj")), MakeAbsolute(File("./src/ReactiveUI.Events.XamEssentials/ReactiveUI.Events.XamEssentials.csproj")), MakeAbsolute(File("./src/ReactiveUI.Events.XamForms/ReactiveUI.Events.XamForms.csproj")), - MakeAbsolute(File("./src/ReactiveUI.Events.Uno/ReactiveUI.Events.Uno.csproj")), MakeAbsolute(File("./src/ReactiveUI.Fody/ReactiveUI.Fody.csproj")), MakeAbsolute(File("./src/ReactiveUI.Fody.Helpers/ReactiveUI.Fody.Helpers.csproj")), MakeAbsolute(File("./src/ReactiveUI.AndroidSupport/ReactiveUI.AndroidSupport.csproj")), From a25e37fb357385f92147fb28af3bcdc52d6849e8 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 26 Jun 2019 12:31:37 +1000 Subject: [PATCH 23/24] turn off exception when in WASM mode --- src/ReactiveUI.Uno/ReactiveUI.Uno.csproj | 6 +++++- src/ReactiveUI/Mixins/DependencyResolverMixins.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj index 0378c60847..df310a8c91 100644 --- a/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj +++ b/src/ReactiveUI.Uno/ReactiveUI.Uno.csproj @@ -5,7 +5,11 @@ Uno Platform specific extensions for ReactiveUI HAS_UNO $(NoWarn);SA1648;CA1816;CA1001;CS0108;CS0114;CS3021;CS1574;CA1303 - + + + + HAS_UNO;WASM + diff --git a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs index 7bbb31af68..6cb135c258 100644 --- a/src/ReactiveUI/Mixins/DependencyResolverMixins.cs +++ b/src/ReactiveUI/Mixins/DependencyResolverMixins.cs @@ -91,7 +91,7 @@ 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 +#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( From 0df2271389a8785b5a2b561edee5438866e54bb4 Mon Sep 17 00:00:00 2001 From: Rodney Littles II <6969701+RLittlesII@users.noreply.github.com> Date: Wed, 26 Jun 2019 00:23:12 -0400 Subject: [PATCH 24/24] grouped registrations --- src/ReactiveUI.Uno/PlatformRegistrations.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ReactiveUI.Uno/PlatformRegistrations.cs b/src/ReactiveUI.Uno/PlatformRegistrations.cs index 635580b71a..3da21b3400 100644 --- a/src/ReactiveUI.Uno/PlatformRegistrations.cs +++ b/src/ReactiveUI.Uno/PlatformRegistrations.cs @@ -23,6 +23,7 @@ public void Register(Action, Type> registerFunction) registerFunction(() => new DependencyObjectObservableForProperty(), typeof(ICreatesObservableForProperty)); registerFunction(() => new BooleanToVisibilityTypeConverter(), typeof(IBindingTypeConverter)); registerFunction(() => new AutoDataTemplateBindingHook(), typeof(IPropertyBindingHook)); + registerFunction(() => new WinRTAppDataDriver(), typeof(ISuspensionDriver)); #if NETSTANDARD if (WasmPlatformEnlightenmentProvider.IsWasm) @@ -36,8 +37,6 @@ public void Register(Action, Type> registerFunction) RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; RxApp.MainThreadScheduler = new WaitForDispatcherScheduler(() => CoreDispatcherScheduler.Current); } - - registerFunction(() => new WinRTAppDataDriver(), typeof(ISuspensionDriver)); } } }