diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt index 9f4af14a9e..90089dcd68 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt @@ -300,6 +300,10 @@ namespace ReactiveUI where TSender : ReactiveUI.IReactiveObject { } public static void RaisePropertyChanging(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } + public static void SubscribePropertyChangedEvents(this TSender reactiveObject) + where TSender : ReactiveUI.IReactiveObject { } + public static void SubscribePropertyChangingEvents(this TSender reactiveObject) + where TSender : ReactiveUI.IReactiveObject { } } public interface IReactivePropertyChangedEventArgs { @@ -658,8 +662,8 @@ namespace ReactiveUI protected virtual bool PrintMembers(System.Text.StringBuilder builder) { } public System.IDisposable SuppressChangeNotifications() { } public override string ToString() { } - public static bool operator !=(ReactiveUI.ReactiveRecord? r1, ReactiveUI.ReactiveRecord? r2) { } - public static bool operator ==(ReactiveUI.ReactiveRecord? r1, ReactiveUI.ReactiveRecord? r2) { } + public static bool operator !=(ReactiveUI.ReactiveRecord? left, ReactiveUI.ReactiveRecord? right) { } + public static bool operator ==(ReactiveUI.ReactiveRecord? left, ReactiveUI.ReactiveRecord? right) { } } public static class Reflection { @@ -931,4 +935,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt index f0f88b0dab..1c8ae13450 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt @@ -295,6 +295,10 @@ namespace ReactiveUI where TSender : ReactiveUI.IReactiveObject { } public static void RaisePropertyChanging(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } + public static void SubscribePropertyChangedEvents(this TSender reactiveObject) + where TSender : ReactiveUI.IReactiveObject { } + public static void SubscribePropertyChangingEvents(this TSender reactiveObject) + where TSender : ReactiveUI.IReactiveObject { } } public interface IReactivePropertyChangedEventArgs { @@ -653,8 +657,8 @@ namespace ReactiveUI protected virtual bool PrintMembers(System.Text.StringBuilder builder) { } public System.IDisposable SuppressChangeNotifications() { } public override string ToString() { } - public static bool operator !=(ReactiveUI.ReactiveRecord? r1, ReactiveUI.ReactiveRecord? r2) { } - public static bool operator ==(ReactiveUI.ReactiveRecord? r1, ReactiveUI.ReactiveRecord? r2) { } + public static bool operator !=(ReactiveUI.ReactiveRecord? left, ReactiveUI.ReactiveRecord? right) { } + public static bool operator ==(ReactiveUI.ReactiveRecord? left, ReactiveUI.ReactiveRecord? right) { } } public static class Reflection { @@ -926,4 +930,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt index 7a858719b5..eb7f8699cd 100644 --- a/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt +++ b/src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt @@ -293,6 +293,10 @@ namespace ReactiveUI where TSender : ReactiveUI.IReactiveObject { } public static void RaisePropertyChanging(this TSender reactiveObject, [System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null) where TSender : ReactiveUI.IReactiveObject { } + public static void SubscribePropertyChangedEvents(this TSender reactiveObject) + where TSender : ReactiveUI.IReactiveObject { } + public static void SubscribePropertyChangingEvents(this TSender reactiveObject) + where TSender : ReactiveUI.IReactiveObject { } } public interface IReactivePropertyChangedEventArgs { @@ -651,8 +655,8 @@ namespace ReactiveUI protected virtual bool PrintMembers(System.Text.StringBuilder builder) { } public System.IDisposable SuppressChangeNotifications() { } public override string ToString() { } - public static bool operator !=(ReactiveUI.ReactiveRecord? r1, ReactiveUI.ReactiveRecord? r2) { } - public static bool operator ==(ReactiveUI.ReactiveRecord? r1, ReactiveUI.ReactiveRecord? r2) { } + public static bool operator !=(ReactiveUI.ReactiveRecord? left, ReactiveUI.ReactiveRecord? right) { } + public static bool operator ==(ReactiveUI.ReactiveRecord? left, ReactiveUI.ReactiveRecord? right) { } } public static class Reflection { @@ -924,4 +928,4 @@ namespace System.Reactive.Disposables public static T DisposeWith(this T item, System.Reactive.Disposables.CompositeDisposable compositeDisposable) where T : System.IDisposable { } } -} \ No newline at end of file +} diff --git a/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs b/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs index 3b28e4a8be..0815bec3ae 100644 --- a/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs +++ b/src/ReactiveUI.Tests/Platforms/windows-xaml/PropertyBindingTest.cs @@ -114,10 +114,10 @@ public void TypeConvertedTwoWayBindSmokeTest() vm.JustADecimal = 17.2m; var disp1 = fixture.Bind(vm, view, x => x.JustADecimal, x => x.SomeTextBox.Text, (IObservable?)null, null); - Assert.Equal(vm.JustADecimal.ToString(CultureInfo.InvariantCulture), view.SomeTextBox.Text); + Assert.Equal(vm.JustADecimal.ToString(CultureInfo.CurrentCulture), view.SomeTextBox.Text); Assert.Equal(17.2m, vm.JustADecimal); - view.SomeTextBox.Text = 42.3m.ToString(CultureInfo.InvariantCulture); + view.SomeTextBox.Text = 42.3m.ToString(CultureInfo.CurrentCulture); Assert.Equal(42.3m, vm.JustADecimal); // Bad formatting. diff --git a/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs b/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs index 8aed8d1095..2024acdd85 100644 --- a/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs +++ b/src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs @@ -143,7 +143,7 @@ public void CanBindViewModelToWinformControls() var disp2 = view.Bind(vm, x => x.SomeDouble, x => x.Property3.Text); vm.SomeDouble = 123.4; - Assert.Equal(vm.SomeDouble.ToString(CultureInfo.InvariantCulture), view.Property3.Text); + Assert.Equal(vm.SomeDouble.ToString(CultureInfo.CurrentCulture), view.Property3.Text); } /// diff --git a/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs b/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs index 08ae4ff50e..62b2b9e167 100644 --- a/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs +++ b/src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs @@ -83,7 +83,7 @@ protected static void CheckApproval(Assembly assembly, [CallerMemberName]string? } } - Assert.Equal(approvedPublicApi, receivedPublicApi); + Assert.Equal(approvedPublicApi.Trim(), receivedPublicApi); } private static string Filter(string text) diff --git a/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs b/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs index ca33ae1fe5..4cef832fb8 100644 --- a/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs +++ b/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs @@ -170,6 +170,34 @@ public static void RaisePropertyChanging(this TSender reactiveObject, [ } } + /// + /// Use this method for enabling classic PropertyChanging events when you + /// are implementing IReactiveObject manually. + /// + /// The sender type. + /// The instance of IReactiveObject which should propagate property changes. + public static void SubscribePropertyChangingEvents(this TSender reactiveObject) + where TSender : IReactiveObject + { + var s = state.GetValue(reactiveObject, _ => (IExtensionState)new ExtensionState(reactiveObject)); + + s.SubscribePropertyChangingEvents(); + } + + /// + /// Use this method for enabling classic PropertyChanged events when you + /// are implementing IReactiveObject manually. + /// + /// The sender type. + /// The instance of IReactiveObject which should propagate property changes. + public static void SubscribePropertyChangedEvents(this TSender reactiveObject) + where TSender : IReactiveObject + { + var s = state.GetValue(reactiveObject, _ => (IExtensionState)new ExtensionState(reactiveObject)); + + s.SubscribePropertyChangedEvents(); + } + internal static IObservable> GetChangedObservable(this TSender reactiveObject) where TSender : IReactiveObject { @@ -191,14 +219,6 @@ internal static IObservable GetThrownExceptionsObservable(th return s.ThrownExceptions; } - internal static void SubscribePropertyChangingEvents(this TSender reactiveObject) - where TSender : IReactiveObject - { - var s = state.GetValue(reactiveObject, _ => (IExtensionState)new ExtensionState(reactiveObject)); - - s.SubscribePropertyChangingEvents(); - } - internal static void RaisingPropertyChanging(this TSender reactiveObject, string propertyName) where TSender : IReactiveObject { @@ -212,14 +232,6 @@ internal static void RaisingPropertyChanging(this TSender reactiveObjec s.RaisePropertyChanging(propertyName); } - internal static void SubscribePropertyChangedEvents(this TSender reactiveObject) - where TSender : IReactiveObject - { - var s = state.GetValue(reactiveObject, _ => (IExtensionState)new ExtensionState(reactiveObject)); - - s.SubscribePropertyChangedEvents(); - } - internal static void RaisingPropertyChanged(this TSender reactiveObject, string propertyName) where TSender : IReactiveObject {