BRO1604: Property summary documentation should match accessors¶
A property's summary begins with the words its accessors call for: Gets or sets, Gets or Sets (with an
init accessor: Gets or initializes, Gets or sets or just Gets, and Initializes), followed by a value indicating whether
for a bool. Replaces StyleCop SA1623.
Example¶
Before¶
public class Order
{
/// <summary>The order number.</summary>
public string Number { get; set; }
/// <summary>Gets or sets the total.</summary>
public decimal Total { get; }
/// <summary>Whether the order is paid.</summary>
public bool IsPaid { get; set; }
}
After¶
public class Order
{
/// <summary>Gets or sets the order number.</summary>
public string Number { get; set; }
/// <summary>Gets the total.</summary>
public decimal Total { get; }
/// <summary>Gets or sets a value indicating whether the order is paid.</summary>
public bool IsPaid { get; set; }
}
Why¶
The summary then says at a glance what callers can do with the property, and it matches the .NET documentation.
How the fix works¶
A wrong prefix is replaced, or the right one is added in front, with the next word's first letter lowered
(The order number becomes Gets or sets the order number; an acronym like URL keeps its capitals). For a
bool, a summary that starts with Whether, Indicates whether or Gets whether has that replaced too (only bool,
like StyleCop: a bool? property's Gets whether stays). The words
are only added in front of a noun phrase: a summary that starts with an article (The, A, An) or a lower-case
word. The fix doesn't rephrase anything else.
Which words: Gets or sets for a getter and a setter other code can use, Gets for a getter only (a private or
internal setter doesn't count, see BRO1605; a protected one does), Sets for a setter only (a private
or internal getter doesn't count either: { private get; set; } says Sets, like StyleCop). An init
accessor counts like a setter: Gets or initializes (or Gets or sets, or just Gets) for { get; init; }, Initializes when it's
the only accessor other code can use. Gets or initializes and Initializes are wrong prefixes elsewhere and get
replaced (Gets or initializes the value. on { get; set; } becomes Gets or sets the value.).
This rule reads documentation as XML, which needs <GenerateDocumentationFile>true</GenerateDocumentationFile>.
Not reported¶
- Indexers.
- Summaries that start with an element (
<see cref="..."/>) or whose first words wrap to the next line. - Summaries without one of the prefixes that don't start like a noun phrase, i.e. with anything but an article
(
The,A,An) or a lower-case word:This is the hash,Not used,Device id of the user,If true, the command text is inspected,Returns the name,Is it closed. Words in front of these wouldn't make a sentence (Gets or sets this is the hash), and there's no fix that surely does, so there's no diagnostic either; rephrase them by hand. Also not reported: a lower-case condition or verb (if,when,whenever,unless,while,whether(not on abool, where it's replaced),true,false,returns,specifies,indicates,determines,contains,controls,defines,represents,provides,allows,enables,describes,stores,holds,is,has,can). - A
boolsummary that starts with an article (The tokenizer predicted a multi-word token here.): it's often a clause, and neitherGets or sets the tokenizer predicted ...norGets or sets a value indicating whether the open statemakes a sentence of every one (owner's decision 2026-10-12, issue #132). Summaries that start withWhetherare still fixed.
Compared with StyleCop¶
Same results as StyleCop's master (unreleased), which added init accessors, except that Gets or sets on
{ get; init; } is fine (master wants Gets or initializes; rewriting a common wording, often on attribute properties
that attribute syntax sets, is churn); StyleCop 1.2.0-beta.556 treats
init as if it weren't there (it wants Gets for { get; init; }, and its fix turns Gets or initializes on
{ get; set; } into Gets or sets or initializes). The fixed output differs only for bool summaries that start
with Whether or Indicates whether, where StyleCop keeps both (a value indicating whether whether ...). StyleCop
also reports a bool summary that starts with an article, which StyleBro leaves alone (see Not reported).
StyleCop also reports the summaries that don't start like a noun phrase (see Not reported).