Closed marhja closed 1 year ago
Oooh good catch! Thank you for reporting this! 😄
EDIT: actually on second thought, this was by design. The rationale is that OnPropertyChanging
is only raised for cases where an actual property is being set, right before assigning the field. That is not the case for dependent properties. Those are only notified as having changed due to some external event, such as in this case, a dependent property having changed 🤔
OK, I can understand that this is by design, but then the following paragraph should probably be deleted from the doc comment for NotifyPropertyChangedForAttribute, because that was what made me believe OnPropertyChanging() would be called:
If the containing type also implements the INotifyPropertyChanging interface and exposes a method with the same signature as ObservableObject.OnPropertyChanging(string), then this method will be invoked as well by the property setter.
Thinking about this more, I think it makes sense to fix this. I've implemented it, but changed target to 9.0 instead of 8.2.1, as this is arguably a small breaking change, functionally speaking. Will want to validate this more with a preview release 🙂
Describe the bug
OnPropertyChanging is not called for a generated property when using the NotifyPropertyChangedFor attribute.
Steps to reproduce
Using this class:
The following code should cause OnPropertyChanging to be called for property FullName:
Expected behavior
I expected
OnPropertyChanging
to be called also for propertyFulleName
when Name is assigned a new value.IDE and version
VS 2022
IDE version
17.2.12
Nuget packages
Nuget package version(s)
8.2.0
Help us help you
No, just wanted to report this