-
Notifications
You must be signed in to change notification settings - Fork 22
SA1005
</head>
TypeName |
SingleLineCommentsMustBeginWithSingleSpace |
CheckId |
SA1005 |
Category |
Spacing Rules |
A single-line comment within a C# code file does not begin with a single space.
A violation of this rule occurs when a single-line comment does not begin with a single space. For example:
private void Method1()
{
//A single-line comment.
// A single-line comment.
}
The comments should begin with a single space after the leading forward slashes:
private void Method1()
{
// A single-line comment.
// A single-line comment.
}
An exception to this rule occurs when the comment is being used to comment out a line of code. In this case, the space can be omitted if the comment begins with four forward slashes to indicate out-commented code. For example:
private void Method1()
{
////int x = 2;
////return x;
}
To fix a violation of this rule, ensure that the comment begins with a single space. If the comment is being used to comment out a line of code, ensure that the comment begins with four forward slashes, in which case the leading space can be omitted.
[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1005:SingleLineCommentsMustBeginWithSingleSpace", Justification = "Reviewed.")]
- - SA0102 - Clean Install
- - Download
- - Documentation Rules - Layout Rules - Maintainability Rules - Naming Rules - Ordering Rules - Readability Rules - Spacing Rules - Suppressions
- - Adding a custom StyleCop settings page - Adding custom rule settings - Authoring a custom styleCop rule - Authoring rules metadata - Custom CSharp Language Service - Custom MSBuild Integration - Hosting StyleCop in a Custom Environment - Installing a Custom Rule - Integrating StyleCop Into Build Environments - Integrating StyleCop into MSBuild - Writing Custom Rules for StyleCop