Setter calls getter instead of private field


I have decompiled sources of one of my properties and saw the following code:
    if (this.Name == value)
    this._name = value;
It calls this.Name instead of this._name (like it described on main page). So getter is called before setter is finished and it produces a bug in my system.


AlexIdsa wrote Mar 29, 2013 at 3:23 PM

Ok, I understood why it works this way. But it would be nice to rework main page samples accordingly

LexLavnikov wrote Mar 30, 2013 at 8:10 PM

Normally, it works the way it is described in intro.

However, if getter logic is complex enough for heuristics to determine the field, property getter is used instead.

I believe, in your case getter was not simple get { return _name; }

LexLavnikov wrote Mar 30, 2013 at 8:18 PM

Normally, everything works as described in intro. In some cases when getter is complex enough for KoM heuristics to determine the field, the propery getter is used.

I believe that your getter was not simple { return _name; }