Skip to content

Fix S1144 FN: Unused private getters and private setters #6724

@zsolt-kolbay-sonarsource

Description

Description

S1144 does not highlight unused private getters or setters when they are inside a public property.

Repro steps

public class PropertyAccess
{
    public int PrivateGetter { private get; set; } // FN - unused private getter
    public int PrivateSetter { get; private set; } // FN - unused private setter

    public int ExpressionBodiedPropertyWithPrivateGetter { private get => 1; set => _ = value; } // FN - unused private getter
    public int ExpressionBodiedPropertyWithPrivateSetter { get => 1; private set => _ = value; } // FN - unused private setter
}

Expected behavior

An issue should be raised for the unused getter or setter.

Actual behavior

No issue is raised.

Known workarounds

None.

Related information

  • C#/VB.NET Plugins version: 8.52
  • Visual Studio version: 2022 17.4.4
  • Operating System: Windows 10 Pro (10.0.19045)

Metadata

Metadata

Labels

False NegativeRule is NOT triggered when it should be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions