Skip to main content

RCS1259: Remove empty syntax

Properties​

PropertyValue
Default SeverityInfo
Minimum language version-

Summary​

This analyzer reports unnecessary syntax that can be safely removed such as:

  • empty destructor
  • empty else clause
  • empty finally clause
  • empty namespace declaration
  • empty object initializer
  • empty #region
  • empty statement

Examples​

Example #1​

diagnostic.cs
if (x)
{
Foo();
}
else
{
}
fix.cs
if (x)
{
Foo();
}

Example #2​

diagnostic.cs
var sb = new StringBuilder() { };
fix.cs
var sb = new StringBuilder();

Applies to​