Skip to content

Fix S1939 FP: Issue is raised when a class derives from another class and declares interface implemention #6823

Open
@mary-georgiou-sonarsource

Description

Description

An FP is raised when a class is implementing a class and an interface - when the interface is not yet implemented by the class.

Repro steps

  class Foo { }

  interface IBar
  {
      int Test();
  }

  class Bar : Foo, IBar { } // Error [CS0535]
  // Noncompliant@-1 {{'Foo' implements 'IBar' so 'IBar' can be removed from the inheritance list.}}

Expected behavior

An issue should not be raised as Foo is not implementing IBar

Known workarounds

Implementing the interface in IBar in Foo stops raising the issue.

Related information

  • C#/VB.NET 8.53

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Area: C#C# rules related issues.Type: False PositiveRule IS triggered when it shouldn't be.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions