Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does StyleCop SA1623 Incorrectly Trigger When the Method has an Attribute?

Tags:

c#

stylecop

I am triggering several instances of SA1623: PropertySummaryDocumentationMustMatchAccessors in my code where I have a property similar to this:

    /// <summary>
    /// Gets or Sets the location to check for files.
    /// </summary>
    [Required]
    public string SourceDirectory { get; set; }

This is code used in a MSBuild Custom Task Library and the Attribute in question is Microsoft.Build.Framework.RequiredAttribute if that has any meaning.

I am using StyleCop 4.7.14.0 with no modifications to the default rules. A quick search of StackOverflow, Google, and the Project's Open Issue logs and documentation shows no mention of this quirk, am I doing something wrong is is this a bug?

Thank you.

like image 535
aolszowka Avatar asked Dec 05 '25 22:12

aolszowka


2 Answers

I had a real headache with this type of error and it was not intuitive to know what they really meant:

Severity Code Description Project File Line Suppression State Error SA1623 : CSharp.Documentation : The property's documentation summary text must begin with: Gets or sets a value indicating whether

I was getting that and when looking at my code I had it well written, I started my summary with " Get or sets ...", but still kept getting the error

After almost going nuts, I realized this was showing for 2 Boolean properties, and what they were telling me is that for Boolean properties I should actually write the whole sentence literally starting with "Gets or sets a value indicating whether..." and the whatever my property does.

For example:

/// <summary> /// 
/// Gets or sets a value indicating whether the product is active. 
/// </summary> 
public boolean Active { get; set; }

I hope this saves time to others.

like image 59
Oscar Avatar answered Dec 07 '25 11:12

Oscar


As Per Erv Walter's comment above the StyleCop rule is cAsE sEnSiTive and must be exactly as shown:

/// <summary>
/// Gets or sets the location to check for files.
/// </summary>

Note the lower case on the sets

like image 23
aolszowka Avatar answered Dec 07 '25 10:12

aolszowka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!