A common pattern for a property is to have a private field that holds the value for the property. In these cases the "backing" field should have the same base name as the property. For example the Visible property could have a "backing" field with one of the following names visible, _visible or m_visible.

It is fairly difficult to determine the "backing" field for a property. The approach I've taken is to find all the fields that are read in the property getter and all that are set in the property setter. I only look at the fields that are defined in the same type. If there are fields from searching the getter and setter then I limit down to fields that are in the setter as well as the getter.

This rule will probably cause a lot of false positives so I wouldn't run it all the time.

Last edited Oct 7, 2007 at 5:37 PM by JeffLeBert, version 2


No comments yet.