-
One of the primary reasons I've been switching to this source generator was to get away from having a high dependence on PostSharp's To explain this better: [Notify]
bool _changeableProperty;
public bool DependentProperty1 => this.ChangeableProperty;
public bool DependentProperty2 => this.DependentProperty1; While I get the expected code being emitted of Somewhat related is that properties from parent classes also don't have a notification chain. To explain that one better too: partial class ParentClass
{
[Notify]
bool _changeableProperty;
}
partial class ChildClass : ParentClass
{
public bool ChildProperty => this.ChangeableProperty;
} There will be nothing in the Now I'm not sure if this is something that can be solved within a source generator or not or if this would be some limitation of the whole thing. Basically I wanted to see if these situations are something that the generator can handle automatically, or if there was some way around it (even if it involves adding some extra attributes to do so). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
No event is raised for I don't follow how you're expecting DependentProperty1 to be changed itself though, since it's read-only? I considered supporting automatic inheritance. It gets a bit annoying though: the parent can't assume knowledge of the child property to notify (it might have multiple children), so the best I could come up with was making OnPropertyChanged virtual, overriding it in the child, and switching on the property name passed to see if it's one of the parent's properties. Except that doesn't necessarily work I guess, as the child could be shadowing a parent property, so you won't know whether a name refers to the parent or child version. Other complicating factors are the base class being in another assembly, the base class not being generated by PropertyChanged.SourceGenerator (maybe even raising events directly from property setters), and the user overriding OnPropertyChanged themselves in the child class in order to do something. I think it's an easier problem with a weaver, as you can do things like subscribing to the parent's PropertyChanged event on the ctor, which gives you a nice stable interface to work with. Or you can add additional hidden methods without the user getting annoyed that you're cluttering their class with junk. It's solvable currently with the AlsoNotify attribute, and the README does list this as a limitation. If you've got some good ideas for how to actually implement this, let's have a discussion. When I last looked at it, it was a lot of effort for something which no-one had asked for! |
Beta Was this translation helpful? Give feedback.
-
This has been released as v1.0.2 |
Beta Was this translation helpful? Give feedback.
This has been released as v1.0.2