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 S1854 FP: Raises when variable is reassigned in a using body after it has been already assigned in using statement. #9473

Closed
mary-georgiou-sonarsource opened this issue Jun 26, 2024 · 0 comments
Assignees
Labels
Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@mary-georgiou-sonarsource
Copy link
Contributor

mary-georgiou-sonarsource commented Jun 26, 2024

S1854 FP

void Repro(IDisposable data)
{
    using (data = Something()) // Noncompliant
    {
        data = Something();   // Noncompliant FP
    }

    if (data != null)
    {
        Console.WriteLine("Hello");
    }
    IDisposable Something() => null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
None yet
Development

No branches or pull requests

1 participant