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.
Projects
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!

@CristianAmbrosini CristianAmbrosini added Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be. labels Apr 17, 2024
@github-actions github-actions bot added this to Review in progress in Best Kanban Jun 4, 2024
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Jun 4, 2024
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Jun 4, 2024
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Jun 4, 2024
Best Kanban automation moved this from Review approved to Validate Peach Jun 4, 2024
@CristianAmbrosini CristianAmbrosini moved this from Validate Peach to Done in Best Kanban Jun 5, 2024
@Tim-Pohlmann Tim-Pohlmann added this to the 9.27 milestone Jun 7, 2024
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
Best Kanban
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants