canton7 / PropertyChanged.SourceGenerator

Powerful INotifyPropertyChanged / INotifyPropertyChanging Source Generator, which generates INPC boilerplate for you as part of your build. Supports features such as automatic and manual dependencies between properties, notifications when specific properties change, and more.
MIT License
131 stars 14 forks source link

did not work on nested class #2

Closed Cologler closed 2 years ago

Cologler commented 2 years ago

To Reproduce

src.cs:

partial class TopClass
{
    partial class NestedClass
    {
        [Notify] private string _field;
    }
}

generated:

partial class NestedClass : global::System.ComponentModel.INotifyPropertyChanged
{
    public event global::System.ComponentModel.PropertyChangedEventHandler? PropertyChanged;
    public string Field
    {
        get => this._field;
        set
        {
            if (!global::System.Collections.Generic.EqualityComparer<string>.Default.Equals(value, this._field))
            {
                this._field = value;
                this.OnPropertyChanged(global::PropertyChanged.SourceGenerator.Internal.PropertyChangedEventArgsCache.Field);
            }
        }
    }
    protected virtual void OnPropertyChanged(global::System.ComponentModel.PropertyChangedEventArgs eventArgs)
    {
        this.PropertyChanged?.Invoke(this, eventArgs);
    }
}