All rules
IDE0360Language rules (expression-level preferences)
Simplify property accessor
Simplify property accessor
Microsoft docsDescription
This rule flags places where a property accessor that directly accesses the field keyword (C# 13+) can be simplified. When a property accessor only returns field or assigns a value to field, it can be simplified to a simple auto-accessor.
Example
// Code with violations.
public int Prop
{
get { return field; }
set { field = (value > 0) ? value : throw new ArgumentException(); }
}
// Fixed code.
public int Prop
{
get;
set { field = (value > 0) ? value : throw new ArgumentException(); }
}Configurable options
Vote for the value each option should take in the generated .editorconfig.
csharp_style_prefer_simple_property_accessors default:
trueYour vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0