[ObservableProperty] with OnPropertyChanged
partial(s) which update additional properties mask nullability analysis - CS8618
#939
Labels
analyzer 👓
A new analyzer being implemented or updated
feature request 📬
A request for new changes to improve functionality
mvvm-toolkit 🧰
Issues/PRs for the MVVM Toolkit
Describe the bug
Seems like extended scenario/case from #645? Where one property modified in the constructor will update one or more other properties through the
On'Property'Changed
(or similar partial method callbacks).Not entirely sure but feel like this should work (in theory). Let me share by example:
So, in my constructor, I set
Position
(This seems to be what #645 fixed), but in this case, that will also call myOnPositionChanged
method, which then setsCoordinates
. So, it explicitly won't be null in any case here, but that's not seen by the compiler...I tried decorating my
OnPositionChanged
method with[MemberNotNull(nameof(Coordinates))]
, but that didn't help... unless I also just recalled the OnPositionChanged method in the constructor (see commented code above in the example). But then that's still calling the OnPositionChanged method twice...Regression
No response
Steps to reproduce
Expected behavior
No compiler warning, ideally without additional changes.
Acceptable if I have to annotate the OnChanged partial method myself for this scenario, I guess? I'm still wrapping my mind around how these annotations work a bit... 😋
Screenshots
No response
IDE and version
VS 2022
IDE version
17.11.1
Nuget packages
Nuget package version(s)
8.3.0
Additional context
Is this analysis that the MVVM source generator has to do extra for this type of scenario or is there something else in .NET that can help with this? I don't think partial properties changes anything here with this scenario in the future either?
Ah, also just saw #846, so not sure if there was some regression from #645 as well?
Help us help you
Yes, but only if others can assist
The text was updated successfully, but these errors were encountered: