Skip to content

Conversation

meziantou
Copy link
Owner

No description provided.

@meziantou meziantou requested a review from Copilot July 6, 2025 14:43
Copy link

@Copilot Copilot AI left a 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 compute canBeInheritedOutsideOfAssembly 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

@meziantou meziantou merged commit df9f517 into main Jul 6, 2025
12 checks passed
@meziantou meziantou deleted the ma0053-private-ctor branch July 6, 2025 14:51
This was referenced Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant