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 S2743 FN: Static fields of nested class inside generic class #4081

Closed
csaba-sagi-sonarsource opened this issue Feb 19, 2021 · 0 comments · Fixed by #9405
Closed

Fix S2743 FN: Static fields of nested class inside generic class #4081

csaba-sagi-sonarsource opened this issue Feb 19, 2021 · 0 comments · Fixed by #9405
Assignees
Labels
Area: C# C# rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Milestone

Comments

@csaba-sagi-sonarsource
Copy link
Contributor

Description

No issue is raised for static nested class fields that are not shared among instances of different close constructed types. (S2743)

Repro steps

        public class StaticFieldInGenericClass<T>
            where T : class
        {
            public static T tProp { get; set; }

            internal string NestedClassUsage => NestedClass.StringField;

            private static class NestedClass
            {
                public static readonly string StringField = "String"; // FN
            }
        }

Expected behavior

Issues are reported for the fields of the static nested class as they are not shared among instances of different close constructed types.

Actual behavior

No issues are reported.

Known workarounds

None

Related information

C#/VB.NET Plugins version: 8.18

@csaba-sagi-sonarsource csaba-sagi-sonarsource added Type: False Negative Rule is NOT triggered when it should be. Area: C# C# rules related issues. labels Feb 19, 2021
@csaba-sagi-sonarsource csaba-sagi-sonarsource added this to False Negatives in Backlog Feb 19, 2021
@sebastien-marichal sebastien-marichal changed the title S2743 FN: Static fields of nested class inside generic class Fix S2743 FN: Static fields of nested class inside generic class May 29, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 9.27 milestone Jun 5, 2024
@github-actions github-actions bot added this to To do in Best Kanban Jun 5, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from To do to In progress in Best Kanban Jun 5, 2024
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Jun 5, 2024
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Jun 5, 2024
Best Kanban automation moved this from Review approved to Validate Peach Jun 6, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource moved this from Validate Peach to Done in Best Kanban Jun 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. Type: False Negative Rule is NOT triggered when it should be.
Projects
Best Kanban
  
Done
Backlog
  
False Negative
Development

Successfully merging a pull request may close this issue.

3 participants