TypeName | SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes |
CheckId | SA1626 |
Category | Documentation Rules |
The C# code contains a single-line comment which begins with three forward slashes in a row.
A violation of this rule occurs when the code contains a single-line comment which begins with three slashes. Comments beginning with three slashes are reserved for Xml documentation headers. Single-line comments should begin with only two slashes. When commenting out lines of code, it is advisable to begin the comment with four slashes to differentiate it from normal comments. For example:
/// <summary>
/// Joins a first name and a last name together into a single string.
/// </summary>
/// <param name="firstName">Part of the name.</param>
/// <param name="lastName">Part of the name.</param>
/// <returns>The joined names.</returns>
public string JoinNames(string firstName, string lastName)
{
*A legal comment beginning with two slashes:*
// Join the names together.
string fullName = firstName + " " + lastName;
*An illegal comment beginning with three slashes:*
/// Trim the name.
fullName = fullName.Trim();
*A line of commented-out code beginning with four slashes:*
////fullName = asfd;
return fullName;
}
To fix a violation of this rule, remove a slash from the beginning of the comment so that it begins with only two slashes.
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1626:SingleLineCommentsMustNotUseDocumentationStyleSlashes", Justification = "Reviewed.")]
#pragma warning disable SA1626 // SingleLineCommentsMustNotUseDocumentationStyleSlashes
#pragma warning restore SA1626 // SingleLineCommentsMustNotUseDocumentationStyleSlashes