StyleCop uses the Gets or Sets ...
notation which it enforces with rule SA1623
My question is why, as from what I can see the vast majority of the time it is self explanatory and requires lots of repetition to have these?
/// <summary>
/// Gets or sets the name of the customer
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets whether the record is archived
/// </summary>
public string IsArchive{ get; set; }
It can also make it overly verbose, when you have just 10 lines, each one declaring a property, you end up with 30+ lines to have a summary comment on each!
StyleCop rules are not absolutes but instead guidelines. In general this is a good rule but in some cases yes the properties are simple enough that documentation is probably overkill. For example
class Student {
public string FirstName { get; set; }
public string LastName { get; set; }
}
A comment on these properties really adds no value as are pretty self descriptive.
I'm a big fan of using StyleCop in projects. But that doesn't mean you have to take every single rule it comes with. Disable the ones that don't make sense for your project and embrace the ones that do
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With