Skip to content

Optionally generate partial method or call method optionally when using ObservablePropertyAttribute #1178

@Kation

Description

@Kation

Overview

It's not possible to generate a virtual OnPropertyChanged method right now.
On changing/changed method of property generated as partial.
I want to override changing/changed method by subclass.

API breakdown

None.

Usage example

[ObservableProperty(GenerateOnChanging = false, GenerateOnChanged = false, CallOnChanging = false, CallOnChanged = false)]
private partial string _fieldA;

[ObservableProperty(GenerateOnChanged = false)]
private partial string _fieldB;

protected virtual void OnFieldBChanged(string? oldValue, string newValue) { }
protected virtual void OnFieldBChanged(string value) { }

Breaking change?

No

Alternatives

[ObservableProperty]
private partial string _field;

partial void OnFieldChanged(string value) 
{
    OnFieldChanged2(value);
}

protected virtual void OnFieldChanged2(string value) { }

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request 📬A request for new changes to improve functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions