SonarSource / SonarSource/sonar-dotnet

NET-1869 Fix S4275 FP: when field in property is set through a method

Open
#5,259 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

False Positive
Dominant language
C#
Stars
918
Forks
244
PR merge metrics
No merged PRs in 30d

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the S4275 finding with the supplied C# and VB.NET property-setter examples, then trace the S4275 analyzer entry point in sonar-dotnet. Done means these setters no longer report a finding while the rule continues to detect genuine issues.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.