Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.48 KB

SA1003.md

File metadata and controls

62 lines (46 loc) · 1.48 KB

SA1003

TypeName SA1003SymbolsMustBeSpacedCorrectly
CheckId SA1003
Category Spacing Rules

Cause

The spacing around an operator symbol is incorrect, within a C# code file.

Rule description

A violation of this rule occurs when the spacing around an operator symbol is incorrect.

The following types of operator symbols should be surrounded by a single space on either side: colons, arithmetic operators, assignment operators, conditional operators, logical operators, relational operators, shift operators, and lambda operators. For example:

int x = 4 + y;

In contrast, unary operators should be preceded by a single space, but should never be followed by any space. For example:

bool x = !value;

An exception occurs whenever the symbol is preceded or followed by a parenthesis or bracket, in which case there should be no space between the symbol and the bracket. For example:

if (!value)
{
}

How to fix violations

To fix a violation of this rule, ensure that the spacing around the symbol follows the rule described above.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1003:SymbolsMustBeSpacedCorrectly", Justification = "Reviewed.")]
#pragma warning disable SA1003 // SymbolsMustBeSpacedCorrectly
#pragma warning restore SA1003 // SymbolsMustBeSpacedCorrectly