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 S2368 FN: constructors #8083

Closed
antonioaversa opened this issue Sep 26, 2023 · 0 comments · Fixed by #8220
Closed

Fix S2368 FN: constructors #8083

antonioaversa opened this issue Sep 26, 2023 · 0 comments · Fixed by #8220
Assignees
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Milestone

Comments

@antonioaversa
Copy link
Contributor

antonioaversa commented Sep 26, 2023

Public constructors are publicly exposed for use, and as such, S2368 should apply to them too.

public class Constructors
{
    public class AClass
    {
        public AClass(int[][] a) { } // FN
    }
}

Primary constructors should also be supported:

public class PrimaryConstructors
{
    public class C1(int[][] a);          // FN, the ctor is publicly exposed
    public class C2(int[,] a);           // FN
    public class C3(params int[] a);     // Compliant, params of int
    public class C4(params int[][][] a); // FN, params of int[][]
    public class C5(int i);              // Compliant, not a multi-dimensional array
}

Related issues:

@antonioaversa antonioaversa added Type: False Negative Rule is NOT triggered when it should be. Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. labels Sep 26, 2023
antonioaversa added a commit that referenced this issue Sep 27, 2023
antonioaversa added a commit that referenced this issue Sep 27, 2023
@andrei-epure-sonarsource andrei-epure-sonarsource added this to the 9.13 milestone Oct 31, 2023
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. Area: VB.NET VB.NET rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Projects
None yet
4 participants