Skip to content

Fix S2737 FP: Raised when exception filter is used #8199

@jlaanstra

Description

@jlaanstra

Description

S2737 is raised in the following circumstance:

try
{
}
catch (Exception ex) when (LogException(ex))
{
    throw;
}

In this case LogException always returns false and therefore the catch should always be skipped but just in case the LogException function has a bug we place throw there.

Repro steps

See Description.

Expected behavior

No warnings for catch statement with exception filter.

Actual behavior

S2737 is raised for catch with exception filter.

Known workarounds

Suppression.

Related information

  • C#/VB.NET Plugins version
  • Visual Studio version
  • MSBuild / dotnet version
  • SonarScanner for .NET version (if used)
  • Operating System

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions