Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S3459 FP: Backing field with ref property #9106

Closed
dotjpg3141 opened this issue Apr 16, 2024 · 1 comment · Fixed by #9383
Closed

Fix S3459 FP: Backing field with ref property #9106

dotjpg3141 opened this issue Apr 16, 2024 · 1 comment · Fixed by #9383
Assignees
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@dotjpg3141
Copy link

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
@CristianAmbrosini
Copy link
Contributor

Hi @dotjpg3141! I confirm this as a FP, I'll add a reproducer in our codebase shortly.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants