-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for notifying cascading calculated properties #857
Comments
I like your proposition and would like to suggest an alternative way of annotation that would of course also cascade automatically. It would probably be easier to maintain the annotations if an attribute could be set on the dependent property because the dependency is directly visible. Also, when changing the expression, you would not have to make changes elsewhere. Something like: [NotificationDependsOn(nameof(SpeakerNotesAuto), nameof(SpeakerNotesTeleop), nameof(SpeakerNotesAmplifiedTeleop))]
public int TotalSpeakerNotes => SpeakerNotesAuto + SpeakerNotesTeleop + SpeakerNotesAmplifiedTeleop; In simple cases (when all the properties are directly visible in the expression), the dependencies could also be determined automatically by analyzing the syntax tree: [NotificationDependsOnAuto]
public int TotalSpeakerNotes => SpeakerNotesAuto + SpeakerNotesTeleop + SpeakerNotesAmplifiedTeleop; |
Overview
I have a particularly complex scoring UI that I'm trying to model which has a number of inputs (in the 15-20 input range per side, and there are 2 sides in each match). These inputs then cascade into a dozen outputs from the match, all of which I would like to display in the UI. Further, these outputs often influence each other. As a concrete example:
These calculations are easier to display to the user broken up, rather than just "here's the final value". For example, we display both the number of total game pieces scored across all components, as well as the final score. However, because each of these inputs can have multiple cascading impacts (scoring in a single location impacts total number of items scored, which impacts total number of points), I have to do a lot of
NotifyPropertyChangedFor
duplication across all of these inputs. I would prefer to annotate the calculated properties with what they themselves will cause to change; then all I have to do is annotate the inputs with the outputs they directly impact, and let secondary impacts be sorted out through a graph walk by the source generator.API breakdown
No new APIs are necessary. Just add
AttributeTargets.Property
toNotifyPropertyChangedFor
, and update the source generator to understand that it should explore allNotifyPropertyChangedFor
properties for cascaded properties.Usage example
A very simplified example. Note that this sample is missing several inputs to the calculated properties I'm showing.
Breaking change?
No
Alternatives
Currently, I just have to duplicate these
NotifyPropertyChangedFor
across all the inputs. It's a lot of duplication, and is very fragile. I don't want to maintain it 🙂.Additional context
No response
Help us help you
No, just wanted to propose this
The text was updated successfully, but these errors were encountered: