Skip to content

Ignored property does not raise property changed #3695

@MichaelLHerman

Description

@MichaelLHerman

What happened?

If you add a [Ignored] property, it calls OnPropertyChanged (the entry point to raise property changed for computed properties) but does not actually call RaisePropertyChanged. Since RaisePropertyChanged and the event handler are private, its hard to actually call RaisePropertyChanged (can't call it from OnPropertyChanged or you'd get a loop)

Repro steps

Create Ignored property

        [Ignored]
        public int Order 
        { 
            get;
            set;
        }

Generated IL:

    [Ignored]
    public int Order
    {
      get => this.<Order>k__BackingField;
      set
      {
        if (this.<Order>k__BackingField == value)
          return;
        this.<Order>k__BackingField = value;
        this.OnPropertyChanged(nameof (Order));
      }
    }

Version

11.7.0

What Atlas Services are you using?

Local Database only

What type of application is this?

Xamarin

Client OS and version

11.7.0

Code snippets

Required to create a backing property to call RaisePropertyChanged

        private int _order;
        [Ignored]
        public int Order 
        { 
            get => _order;
            set
            {
                _order = value;
                RaisePropertyChanged();
            } 
        }

This surprisingly generates IL that does an extra equality check

    [Ignored]
    [CustomMappingIgnore]
    public int Order
    {
      get => this._order;
      set
      {
        if (this._order == value)
          return;
        this._order = value;
        this.RaisePropertyChanged(nameof (Order));
      }
    }

Stacktrace of the exception/crash you're getting

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions