SonarSource/sonar-dotnet

Fix S1694 FP: Protected abstract methods

Closed this issue · 1 comments

Description

The rule shouldn't raise for abstract classes that have protected abstract members, because that's not reproducible with an interface (at least not in the .NET Framework or below C# 8.0).

Repro steps

public abstract class BaseClass
{
   protected abstract void SomeMethod();  // Noncompliant - FP
}

Expected behavior

The rule should ignore these abstract classes and not raise a warning.

Actual behavior

A warning is raised for the abstract class.

Related information

  • C#/VB.NET Plugins version: 9.27
  • Visual Studio version: Visual Studio 2022 (17.10)
  • MSBuild / dotnet version: .NET Framework 4.8
  • Operating System: Windows 10

As discussed with @zsolt-kolbay-sonarsource, I am closing this ticket because there are no real-world use cases for having protected abstract methods without non-abstract methods in the same class.