Code inspection: Convert property into auto-property with private setter
This inspection reports a property with a trivial backing field whose setter can be represented as a private auto-property setter. This applies when the existing property logic is still simple enough for an auto-property, but external code should not be able to assign to it.
Example
class A
{
int p;
public int P
{
get { return p; }
private set { p = value; }
}
}
class A
{
public int P { get; private set; }
}
Quick-fix
Convert the property to an auto-property and keep the setter private.
30 March 2026