StyleChecker
SpaceBeforeSemicolon
Summary
A semicolon must not be preceded by a white space.
Default severity
Warning
Description
In general, semicolons are not preceded by a space.
Note that this analyzer and the NoSpaceAfterSemicolon analyzer are intended
to be used together and replace SA1002 with them, allowing us to write an
infinite for
loop with for (;;)
.
Code fix
The code fix provides an option eliminating spaces before the semicolon.
Example
Diagnostic
public void Method()
{
var n = 10 ;
Console.WriteLine() /**/ ;
for (var k = 0 ; k < n ; ++k)
{
}
for ( ; ;)
{
return
;
}
}
Code fix
public void Method()
{
var n = 10;
Console.WriteLine() /**/;
for (var k = 0; k < n; ++k)
{
}
for (;;)
{
return;
}
}