Code inspection: Convert property into auto-property
If the get
and set
accessors of a property do nothing but return or set value to a backing field, ReSharper suggests converting this property into an auto-implemented property (also known as auto-property), remove the backing field and replace all its usages with the newly created auto-property.
The inspection will not highlight properties in classes marked with the [Serializable]
attribute, because the serializer may rely on the existing fields.
Here is an example of a quick-fix suggested by this inspection:
Note that this quick-fix invokes the Convert Property to Auto-Property refactoring, which will replace all usages of the backing field solution-wide. In some cases, for example if the property name is used in another context, you may need to resolve conflicts that arise.