Skip to content
ptittof57 edited this page Aug 15, 2015 · 4 revisions
<title>SA1023: DereferenceAndAccessOfMustBeSpacedCorrectly</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

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, a parenthesis or a symbol of the same type i.e. an equals. The symbol should not be followed by whitespace, and should not be thelast 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.

How to Suppress Violations

[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1023:DereferenceAndAccessOfMustBeSpacedCorrectly", Justification = "Reviewed.")]
    </div>
      
</div>
Clone this wiki locally