Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S1694 FP: Protected abstract methods #9421

Closed
zsolt-kolbay-sonarsource opened this issue Jun 11, 2024 · 1 comment
Closed

Fix S1694 FP: Protected abstract methods #9421

zsolt-kolbay-sonarsource opened this issue Jun 11, 2024 · 1 comment
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@zsolt-kolbay-sonarsource
Copy link
Contributor

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
@Tim-Pohlmann
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

3 participants