-
-
Notifications
You must be signed in to change notification settings - Fork 58
MA0053 takes ctor visibility into account to determine if a class should be sealed #815
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
The PR enhances rule MA0053 to seal classes only if they can be inherited outside the assembly by checking constructor visibility and adds corresponding tests.
- Adds Theory tests for private, internal, and public/protected constructors in
ClassMustBeSealedAnalyzerTests.cs
- Updates
IsPotentialSealed
to computecanBeInheritedOutsideOfAssembly
based on constructor visibilities
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tests/Meziantou.Analyzer.Test/Rules/ClassMustBeSealedAnalyzerTests.cs | Added tests for classes with varying constructor visibility |
src/Meziantou.Analyzer/Rules/ClassMustBeSealedAnalyzer.cs | Refined sealing logic to consider constructor visibility |
Comments suppressed due to low confidence (1)
tests/Meziantou.Analyzer.Test/Rules/ClassMustBeSealedAnalyzerTests.cs:283
- [nitpick] The
ClassWithPublicCtor
test does not assert a diagnostic for a public constructor case. Surround the class name with[|
and|]
to indicate the expected diagnostic position.
public class Sample
No description provided.