Skip to content

Fix S3459 FP: Backing field with ref property #9106

@dotjpg3141

Description

@dotjpg3141

Description

False Positive of S3459 for backing field with ref property.

Repro steps

public class MyClass
{
    private int _foo;

    public ref int Foo => ref _foo;
}

Expected behavior

No warning

Actual behavior

warning S3459: Remove unassigned field '_foo', or set its value. (https://rules.sonarsource.com/csharp/RSPEC-3459)

Known workarounds

Supress this warning manually

Related information

  • C#/VB.NET Plugins version: SonarAnalyzer.CSharp 9.23.2.88755
  • Visual Studio version 17.9.2
  • MSBuild / dotnet version: dotnet 8.0.200
  • SonarScanner for .NET version (if used)
  • Operating System: Windows 10

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions