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 S1144 FP: Ignore unused Deconstruct methods #3842

Closed
andrei-epure-sonarsource opened this issue Dec 15, 2020 · 1 comment · Fixed by #9470
Closed

Fix S1144 FP: Ignore unused Deconstruct methods #3842

andrei-epure-sonarsource opened this issue Dec 15, 2020 · 1 comment · Fixed by #9470
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@andrei-epure-sonarsource
Copy link
Contributor

This is a follow-up of #2478

    public class ReproIssue2478
    {
        public void SomeMethod()
        {
            ForSwitchArm x = null;
            var result = (x) switch
            {
                null => 1,
                // normally, when deconstructing in a switch, we don't actually know the type
                (object x1, object x2) => 2
            };
            var y = new ForIsPattern();
            if (y is (string a, string b)) { }
        }

        private sealed class ForSwitchArm
        {
            public void Deconstruct(out object a, out object b) { a = b = null; } // Noncompliant FP
        }

        private sealed class ForIsPattern
        {
            public void Deconstruct(out string a, out string b) { a = b = null; } // Noncompliant FP
        }
    }
@andrei-epure-sonarsource andrei-epure-sonarsource added Type: False Positive Rule IS triggered when it shouldn't be. Area: C#8 labels Dec 15, 2020
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title S1144 FP with implicit Deconstruct in pattern matching S1144 FP: with implicit Deconstruct in pattern matching Oct 14, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Area: C# C# rules related issues. and removed Area: C#8 labels Feb 19, 2024
@Tim-Pohlmann
Copy link
Contributor

I think we should just add an exception to not raise on deconstructors at all.

@sebastien-marichal sebastien-marichal added the Sprint: Hardening Fix FPs/FNs/improvements label Jun 24, 2024
@sebastien-marichal sebastien-marichal self-assigned this Jun 24, 2024
@sebastien-marichal sebastien-marichal changed the title S1144 FP: with implicit Deconstruct in pattern matching Fix S1144 FP: Ignore unused Deconstruct methods Jun 26, 2024
@sebastien-marichal sebastien-marichal linked a pull request Jun 26, 2024 that will close this issue
@sebastien-marichal sebastien-marichal added this to the 9.29 milestone Jul 10, 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. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants