TypeName | BlockStatementsMustNotContainEmbeddedComments |
CheckId | SA1108 |
Category | Readability Rules |
Cause
A C# statement contains a comment between the declaration of the statement and the opening curly bracket of the statement.
Rule Description
A violation of this rule occurs when the code contains a comment in between the declaration and the opening curly bracket. For example:
if (x != y)
// Make sure x does not equal y
{
}
The comment can legally be placed above the statement, or within the body of the statement:
// Make sure x does not equal y
if (x != y)
{
}
if (x != y)
{
// Make sure x does not equal y
}
If the comment is being used to comment out a line of code, begin the comment with four forward slashes rather than two:
if (x != y)
////if (x == y)
{
}
How to Fix Violations
To fix a violation of this rule, move the comment above the statement, within the body of the statement, or remove the comment.