TypeName | SA1108BlockStatementsMustNotContainEmbeddedComments |
CheckId | SA1108 |
Category | Readability Rules |
A C# statement contains a comment between the declaration of the statement and the opening brace of the statement.
A violation of this rule occurs when the code contains a comment in between the declaration and the opening brace. 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)
{
}
To fix a violation of this rule, move the comment above the statement, within the body of the statement, or remove the comment.
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1108:BlockStatementsMustNotContainEmbeddedComments", Justification = "Reviewed.")]
#pragma warning disable SA1108 // BlockStatementsMustNotContainEmbeddedComments
#pragma warning restore SA1108 // BlockStatementsMustNotContainEmbeddedComments