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

New Rule Idea: locked field should not be public nor internal nor protected internal #6804

Open
antonioaversa opened this issue Feb 27, 2023 · 0 comments
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Rule Idea Idea for a rule that has NOT been specified.

Comments

@antonioaversa
Copy link
Contributor

What

When a lock statement is on a field, the field should not be

  • public
  • internal
  • protected internal

How

  • The new rule would cover the part of S2445 left out from the implementation during review.
  • This proposal extends the scope of "S2445 leftover" to visibility modifiers other than private: private protected, protected are also considered acceptable, because exposing fields to derived classes, in the same assembly or not, could be a valid approach when the synchronization should happen between methods of the base classes and methods of the derived class.
  • file accessibility should be considered as acceptable for locking, because of the fairly limited scope.

Background

@antonioaversa antonioaversa added Area: C# C# rules related issues. Type: Rule Idea Idea for a rule that has NOT been specified. labels Feb 27, 2023
@pavel-mikula-sonarsource pavel-mikula-sonarsource added the Area: VB.NET VB.NET rules related issues. label Feb 27, 2023
@cristian-ambrosini-sonarsource cristian-ambrosini-sonarsource changed the title New rule: locked field should not be public nor internal nor protected internal New Rule Idea: locked field should not be public nor internal nor protected internal Nov 17, 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: Rule Idea Idea for a rule that has NOT been specified.
Projects
None yet
Development

No branches or pull requests

2 participants