Skip to content

NET-1843 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    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