From 9d73fba278c02cc21b9c7c4560baaf582333b697 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Sat, 8 Jul 2023 10:12:17 +0100 Subject: [PATCH] Housekeeping: Update Obsolete notation to fix warnings (#3561) --- src/Directory.build.props | 6 ++-- src/Directory.build.targets | 13 -------- src/ReactiveUI.Blend/ReactiveUI.Blend.csproj | 4 +-- .../ReactiveUI.Fody.Analyzer.csproj | 1 + .../ObservableAsPropertyWeaver.cs | 4 +-- .../ReactiveDependencyPropertyWeaver.cs | 23 +++---------- .../ReactiveUIPropertyWeaver.cs | 23 +++---------- .../winforms/DefaultPropertyBindingTests.cs | 16 +++++++++ .../wpf/Mocks/WpfActiveContentApp.cs | 4 --- .../wpf/Mocks/WpfActiveContentFixture.cs | 7 ++-- .../Common/AutoDataTemplateBindingHook.cs | 1 - .../Common/BooleanToVisibilityHint.cs | 1 - .../Common/PlatformOperations.cs | 2 ++ .../Common/ReactiveUserControl.cs | 3 +- src/ReactiveUI.Uwp/Common/RoutedViewHost.cs | 20 ++++------- .../Common/ViewModelViewHost.cs | 2 +- .../Rx/Linq/DispatcherObservable.cs | 3 +- .../PanelSetMethodBindingConverter.cs | 13 +++----- .../ReactiveUI.Winforms.csproj | 14 ++------ .../WinformsCreatesObservableForProperty.cs | 10 ++---- .../android/AndroidObservableForWidgets.cs | 33 +++++++++++-------- .../Platforms/android/LinkerOverrides.cs | 13 +++++++- .../Platforms/android/ReactiveFragment.cs | 27 ++++++++++++--- .../android/ReactivePreferenceActivity.cs | 15 +++++++-- .../android/ReactivePreferenceFragment.cs | 27 ++++++++++++--- .../Platforms/android/UsbManagerExtensions.cs | 21 ++++++++++++ src/ReactiveUI/ReactiveUI.csproj | 2 +- version.json | 2 +- 28 files changed, 166 insertions(+), 144 deletions(-) diff --git a/src/Directory.build.props b/src/Directory.build.props index 5d3dfb925d..18b6ece2b3 100644 --- a/src/Directory.build.props +++ b/src/Directory.build.props @@ -45,9 +45,9 @@ - - - + + + diff --git a/src/Directory.build.targets b/src/Directory.build.targets index 881b2e6b1b..5be3242591 100644 --- a/src/Directory.build.targets +++ b/src/Directory.build.targets @@ -10,22 +10,9 @@ $(DefineConstants);NETSTANDARD;PORTABLE - - $(DefineConstants);NETCOREAPP - - - $(DefineConstants);NETCOREAPP2 - - - $(DefineConstants);NETCOREAPP3 - $(DefineConstants);NET_461;XAML - - 10.0.16299.0 - $(DefineConstants);NETFX_CORE;XAML;WINDOWS_UWP - $(DefineConstants);MONO;UIKIT;COCOA;IOS diff --git a/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj b/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj index d66094ee12..9640de9203 100644 --- a/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj +++ b/src/ReactiveUI.Blend/ReactiveUI.Blend.csproj @@ -16,12 +16,10 @@ - - - + diff --git a/src/ReactiveUI.Fody.Analyzer/ReactiveUI.Fody.Analyzer.csproj b/src/ReactiveUI.Fody.Analyzer/ReactiveUI.Fody.Analyzer.csproj index e38a833d52..b37f865a83 100644 --- a/src/ReactiveUI.Fody.Analyzer/ReactiveUI.Fody.Analyzer.csproj +++ b/src/ReactiveUI.Fody.Analyzer/ReactiveUI.Fody.Analyzer.csproj @@ -6,6 +6,7 @@ Rosyln extension that checks correct usage of the Fody extension. mvvm;reactiveui;rx;reactive extensions;observable;LINQ;events;frp;xamarin;android;ios;mac;forms;monodroid;monotouch;xamarin.android;xamarin.ios;xamarin.forms;xamarin.mac;xamarin.tvos;wpf;net;netstandard;net472;uwp;tizen;unoplatform;fody; False + true diff --git a/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs b/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs index bb3934d6c0..20e6286576 100644 --- a/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs +++ b/src/ReactiveUI.Fody/ObservableAsPropertyWeaver.cs @@ -99,7 +99,7 @@ public void Execute() targetType.Fields.Add(field); // It's an auto-property, so remove the generated field - if (property.SetMethod is not null && property.SetMethod.HasBody) + if (property.SetMethod?.HasBody == true) { // Remove old field (the generated backing field for the auto property) var oldField = (FieldReference)property.GetMethod.Body.Instructions.Single(x => x.Operand is FieldReference).Operand; @@ -188,4 +188,4 @@ public void EmitDefaultValue(MethodBody methodBody, ILProcessor il, TypeReferenc } } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Fody/ReactiveDependencyPropertyWeaver.cs b/src/ReactiveUI.Fody/ReactiveDependencyPropertyWeaver.cs index 3533208d79..e66f7d8ddf 100644 --- a/src/ReactiveUI.Fody/ReactiveDependencyPropertyWeaver.cs +++ b/src/ReactiveUI.Fody/ReactiveDependencyPropertyWeaver.cs @@ -77,24 +77,9 @@ public void Execute() var reactiveObject = new TypeReference("ReactiveUI", "IReactiveObject", ModuleDefinition, reactiveUI); var targetTypes = ModuleDefinition.GetAllTypes().Where(x => x.BaseType is not null && reactiveObject.IsAssignableFrom(x.BaseType)).ToArray(); - var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve(); - if (reactiveObjectExtensions is null) - { - throw new Exception("reactiveObjectExtensions is null"); - } - - var raisePropertyChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaisePropertyChanged")); - if (raisePropertyChangedMethod is null) - { - throw new Exception("raisePropertyChangedMethod is null"); - } - - var reactiveDependencyAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveDependencyAttribute", helpers); - if (reactiveDependencyAttribute is null) - { - throw new Exception("reactiveDecoratorAttribute is null"); - } - + var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve() ?? throw new Exception("reactiveObjectExtensions is null"); + var raisePropertyChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaisePropertyChanged")) ?? throw new Exception("raisePropertyChangedMethod is null"); + var reactiveDependencyAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveDependencyAttribute", helpers) ?? throw new Exception("reactiveDecoratorAttribute is null"); foreach (var targetType in targetTypes.Where(x => x.Properties.Any(y => y.IsDefined(reactiveDependencyAttribute))).ToArray()) { foreach (var facadeProperty in targetType.Properties.Where(x => x.IsDefined(reactiveDependencyAttribute)).ToArray()) @@ -240,4 +225,4 @@ public void Execute() } } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Fody/ReactiveUIPropertyWeaver.cs b/src/ReactiveUI.Fody/ReactiveUIPropertyWeaver.cs index 6286232f40..1df8800e34 100644 --- a/src/ReactiveUI.Fody/ReactiveUIPropertyWeaver.cs +++ b/src/ReactiveUI.Fody/ReactiveUIPropertyWeaver.cs @@ -79,24 +79,9 @@ public void Execute() LogInfo?.Invoke($"{helpers.Name} {helpers.Version}"); var reactiveObject = new TypeReference("ReactiveUI", "IReactiveObject", ModuleDefinition, reactiveUI); var targetTypes = ModuleDefinition.GetAllTypes().Where(x => x.BaseType is not null && reactiveObject.IsAssignableFrom(x.BaseType)).ToArray(); - var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve(); - if (reactiveObjectExtensions is null) - { - throw new Exception("reactiveObjectExtensions is null"); - } - - var raiseAndSetIfChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaiseAndSetIfChanged")); - if (raiseAndSetIfChangedMethod is null) - { - throw new Exception("raiseAndSetIfChangedMethod is null"); - } - - var reactiveAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveAttribute", helpers); - if (reactiveAttribute is null) - { - throw new Exception("reactiveAttribute is null"); - } - + var reactiveObjectExtensions = new TypeReference("ReactiveUI", "IReactiveObjectExtensions", ModuleDefinition, reactiveUI).Resolve() ?? throw new Exception("reactiveObjectExtensions is null"); + var raiseAndSetIfChangedMethod = ModuleDefinition.ImportReference(reactiveObjectExtensions.Methods.Single(x => x.Name == "RaiseAndSetIfChanged")) ?? throw new Exception("raiseAndSetIfChangedMethod is null"); + var reactiveAttribute = ModuleDefinition.FindType("ReactiveUI.Fody.Helpers", "ReactiveAttribute", helpers) ?? throw new Exception("reactiveAttribute is null"); foreach (var targetType in targetTypes) { foreach (var property in targetType.Properties.Where(x => x.IsDefined(reactiveAttribute)).ToArray()) @@ -174,4 +159,4 @@ public void Execute() } } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs b/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs index 9fbdf8b9d8..8ec185688a 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs @@ -4,6 +4,7 @@ // See the LICENSE file in the project root for full license information. using System; +using System.Collections.Generic; using System.Globalization; using System.Linq.Expressions; using System.Reactive.Concurrency; @@ -183,5 +184,20 @@ public void SmokeTestWinformControls() disp.Dispose(); } + + [Fact] + public void PanelSetMethodBindingConverter_GetAffinityForObjects() + { + var fixture = new PanelSetMethodBindingConverter(); + var test1 = fixture.GetAffinityForObjects(typeof(List), typeof(Control.ControlCollection)); + var test2 = fixture.GetAffinityForObjects(typeof(List), typeof(Control.ControlCollection)); + var test3 = fixture.GetAffinityForObjects(typeof(List