Skip to content
ptittof57 edited this page Aug 15, 2015 · 6 revisions
<title>SA1108: BlockStatementsMustNotContainEmbeddedComments</title> <script src="script/helpstudio.js" type="text/javascript"></script> <script src="script/StandardText.js" type="text/jscript"></script>
<script type="text/jscript">WritePageTop(document.title);</script>

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.

How to Suppress Violations

[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1108:BlockStatementsMustNotContainEmbeddedComments", Justification = "Reviewed.")]
Clone this wiki locally