TypeName | DereferenceAndAccessOfMustBeSpacedCorrectly |
CheckId | SA1023 |
Category | Spacing Rules |
Cause
A dereference symbol or an access-of symbol within a C# element is not spaced correctly.
Rule Description
A violation of this rule occurs when the spacing around a dereference or access-of symbol is not correct.
The spacing around the symbol depends upon whether the symbol is used within a type declaration. If so, the symbol must always be followed by a single space, unless it is the last character on the line, or is followed by an opening square bracket or a parenthesis. In addition, the symbol should not be preceded by whitespace, and should not be the first character on the line. An example of a properly spaced dereference symbol used within a type declaration is:
object* x = null;
When a dereference or access-of symbol is used outside of a type declaration, the opposite rule applies. In this case, the symbol must always be preceded by a single space, unless it is the first character on the line, or is preceded by an opening square bracket or a parenthesis. The symbol should not be followed by whitespace, and should not be the last character on the line. For example:
y = *x;
How to Fix Violations
To fix a violation of this rule, ensure that the spacing around the dereference or address-of symbol follows the rule described above.