Skip to content

Fix S4275 FP: when field in property is set through a method #5259

Open
@mary-georgiou-sonarsource

Description

Description

FP is raised by S4275 when the field in a property is set through a method.
sonar-dotnet version: 8.33

Repro steps

C#:

private int[] attributes;
public int[] Attributes
{
    set { value.CopyTo(attributes, 0); } // Noncompliant - FP
}

VB.NET:

Private attributes_ As Integer()
Public WriteOnly Property Attributes As Integer()
    Set(ByVal value As Integer()) ' Noncompliant - FP
        value.CopyTo(attributes_, 0)
    End Set
End Property

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.Area: VB.NETVB.NET 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