property-summary-matches-accessors
What it does
Section titled “What it does”Reports a property summary that does not start with “Gets”, “Sets” or “Gets or sets” as the accessors that are reachable from outside the type say; for bool properties “Gets a value indicating whether” and the like. The type is read from the declaration (bool, Boolean, System.Boolean). The fix replaces the start of the text and lower-cases what follows, and is unsafe.
Why it matters
Section titled “Why it matters”A summary that says “Gets or sets” for a property that can only be read promises something the caller cannot do. The first words are a contract that tools and readers rely on.
Example
Section titled “Example”...internal class InternalProperties{ /// <summary>The count.</summary> protected internal int Both { get; protected set; }
/// <summary>Gets or sets the count.</summary> protected internal int GoodBoth { get; protected set; }......internal class InternalProperties{ /// <summary>Gets or sets the count.</summary> protected internal int Both { get; protected set; }
/// <summary>Gets or sets the count.</summary> protected internal int GoodBoth { get; protected set; }...Configuration
Section titled “Configuration”csharp: lint: rules: property-summary-matches-accessors: warn # off (default), warn, errorEnabled by the presets: csharp/stylecop.
Suppress one line with sudsy-disable-next-line property-summary-matches-accessors in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| StyleCop | SA1623 |
partial | a property whose type is an alias of System.Boolean (using alias) is not recognized as bool |