From cbf732c60e516c7f27d961740ffaf2af8d5e4aef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 04:41:56 +0000 Subject: [PATCH 1/4] Bump elliptic from 6.5.3 to 6.5.4 in /docs Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.3 to 6.5.4. - [Release notes](https://github.com/indutny/elliptic/releases) - [Commits](https://github.com/indutny/elliptic/compare/v6.5.3...v6.5.4) Signed-off-by: dependabot[bot] --- docs/package-lock.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index b7080448..c7119386 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -4017,24 +4017,24 @@ "dev": true }, "elliptic": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", - "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", "dev": true, "requires": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", + "bn.js": "^4.11.9", + "brorand": "^1.1.0", "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" }, "dependencies": { "bn.js": { - "version": "4.11.9", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", - "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", "dev": true } } From f7832f6cdec424767dedb7cce90cc28e043039cc Mon Sep 17 00:00:00 2001 From: Kazuki Ota Date: Mon, 22 Mar 2021 18:55:51 +0900 Subject: [PATCH 2/4] Fix #248 --- .../Internals/PropertyPathNode.cs | 6 ++ .../Internals/PropertyObservableTest.cs | 61 +++++++++++++------ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/Source/ReactiveProperty.NETStandard/Internals/PropertyPathNode.cs b/Source/ReactiveProperty.NETStandard/Internals/PropertyPathNode.cs index 43bc7c39..8aaf14d9 100644 --- a/Source/ReactiveProperty.NETStandard/Internals/PropertyPathNode.cs +++ b/Source/ReactiveProperty.NETStandard/Internals/PropertyPathNode.cs @@ -21,6 +21,7 @@ public PropertyPathNode(string propertyName) public string PropertyName { get; } public object Source { get; private set; } + private Type PrevSourceType { get; set; } public PropertyPathNode Next { get; private set; } public PropertyPathNode Prev { get; private set; } public void SetCallback(Action callback) @@ -46,6 +47,11 @@ public void UpdateSource(object source) EnsureDispose(); Cleanup(); Source = source; + if (PrevSourceType != Source?.GetType()) + { + _getAccessor = null; + } + PrevSourceType = Source?.GetType(); StartObservePropertyChanged(); } diff --git a/Test/ReactiveProperty.NETStandard.Tests/Internals/PropertyObservableTest.cs b/Test/ReactiveProperty.NETStandard.Tests/Internals/PropertyObservableTest.cs index 606955e3..c14c718a 100644 --- a/Test/ReactiveProperty.NETStandard.Tests/Internals/PropertyObservableTest.cs +++ b/Test/ReactiveProperty.NETStandard.Tests/Internals/PropertyObservableTest.cs @@ -19,28 +19,55 @@ public void ObserveProperty() { Child = new Item { - RefTypeValue = "xxx", - ValueTypeValue = 10, + Value = 10, }, }; var testScheduler = new TestScheduler(); var testObserver = testScheduler.CreateObserver(); - var path = PropertyObservable.CreateFromPropertySelector(item, x => x.Child.ValueTypeValue); + var path = PropertyObservable.CreateFromPropertySelector(item, x => x.Child.Value); path.Subscribe(testObserver); path.GetPropertyPathValue().Is(10); - item.Child.ValueTypeValue = 1; + item.Child.Value = 1; testObserver.Messages.Is(OnNext(0, 1)); item.IsPropertyChangedEmpty.IsFalse(); path.Dispose(); item.IsPropertyChangedEmpty.IsTrue(); - item.Child.ValueTypeValue = 100; + item.Child.Value = 100; testObserver.Messages.Is(OnNext(0, 1)); } - class Item : INotifyPropertyChanged + [TestMethod] + public void ChangeObserveSourcePropertyType() + { + var item = new Item + { + Child = new Item + { + Value = 10, + }, + }; + + var testScheduler = new TestScheduler(); + var testObserver = testScheduler.CreateObserver(); + + var path = PropertyObservable.CreateFromPropertySelector(item, x => x.Child.Value); + path.Subscribe(testObserver); + path.GetPropertyPathValue().Is(10); + item.Child.Value = 1; + testObserver.Messages.Is(OnNext(0, 1)); + + item.Child = new AnotherItem + { + Value = 9999, + }; + path.GetPropertyPathValue().Is(9999); + testObserver.Messages.Is(OnNext(0, 1), OnNext(0, 9999)); + } + + class ItemBase : INotifyPropertyChanged { public bool IsPropertyChangedEmpty => PropertyChanged == null; private void SetProperty(ref T field, T value, [CallerMemberName] string propertyName = null) @@ -54,22 +81,15 @@ private void SetProperty(ref T field, T value, [CallerMemberName] string prop PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - private string _refTypeValue; - public string RefTypeValue - { - get { return _refTypeValue; } - set { SetProperty(ref _refTypeValue, value); } - } - - private int _valueTypeValue; - public int ValueTypeValue + private int _value; + public int Value { - get { return _valueTypeValue; } - set { SetProperty(ref _valueTypeValue, value); } + get { return _value; } + set { SetProperty(ref _value, value); } } - private Item _child; - public Item Child + private ItemBase _child; + public ItemBase Child { get { return _child; } set { SetProperty(ref _child, value); } @@ -77,5 +97,8 @@ public Item Child public event PropertyChangedEventHandler PropertyChanged; } + class Item : ItemBase { } + class AnotherItem: ItemBase { } } + } From 78350ad28fcb51e8d59cae63e039bf71e21c63d5 Mon Sep 17 00:00:00 2001 From: Kazuki Ota Date: Mon, 22 Mar 2021 18:56:09 +0900 Subject: [PATCH 3/4] change member visibility --- .../Internals/PropertyObservable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ReactiveProperty.NETStandard/Internals/PropertyObservable.cs b/Source/ReactiveProperty.NETStandard/Internals/PropertyObservable.cs index 8445f185..3f669f62 100644 --- a/Source/ReactiveProperty.NETStandard/Internals/PropertyObservable.cs +++ b/Source/ReactiveProperty.NETStandard/Internals/PropertyObservable.cs @@ -24,7 +24,7 @@ public TProperty GetPropertyPathValue() public bool SetPropertyPathValue(TProperty value) => RootNode?.SetPropertyPathValue(value) ?? false; public void SetSource(INotifyPropertyChanged source) => RootNode?.UpdateSource(source); - internal void RaisePropertyChanged() => _propertyChangedSource.OnNext(GetPropertyPathValue()); + private void RaisePropertyChanged() => _propertyChangedSource.OnNext(GetPropertyPathValue()); private readonly Subject _propertyChangedSource = new Subject(); From d84bfbfbf513c5fa4a967ba0f79b85b96c13b05a Mon Sep 17 00:00:00 2001 From: Kazuki Ota Date: Mon, 22 Mar 2021 19:12:16 +0900 Subject: [PATCH 4/4] update the version number to 7.8.2 --- Source/SharedProperties.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SharedProperties.csproj b/Source/SharedProperties.csproj index 23801e50..8e0299d6 100644 --- a/Source/SharedProperties.csproj +++ b/Source/SharedProperties.csproj @@ -1,7 +1,7 @@ Reactive.Bindings - 7.8.1 + 7.8.2 neuecc xin9le okazuki https://github.com/runceel/ReactiveProperty rx mvvm async rx-main reactive