Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

Fix #914

The MA0053 rule already analyzes both classes and records (records are TypeKind.Class in Roslyn), but the rule title and documentation only mentioned "class".

Changes

  • Analyzer: Updated rule title and message from "Make class sealed" to "Make class or record sealed"
  • Documentation: Updated MA0053.md to reference both classes and records throughout configuration sections
  • README files: Updated rule descriptions in tables and examples
  • Configuration files: Updated comments in .editorconfig templates
  • Tests: Added comprehensive tests for record types to validate analyzer behavior with records, including inheritance scenarios, interface implementation, and configuration options

The analyzer logic remains unchanged—records were already supported.

Original prompt

The rule MA0053 only mention class. However, record are also supported. Can you rename the rule and update the documentation file (MA0053.md)?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Rename MA0053 rule to include records Update MA0053 to mention both class and record types Nov 2, 2025
Copilot AI requested a review from meziantou November 2, 2025 16:12
Copilot finished work on behalf of meziantou November 2, 2025 16:12
@meziantou
Copy link
Owner

@copilot Can you also validate that the tests validate behavior with record? The file containing the tests is ClassMustBeSealedAnalyzerTests.cs.

Copy link
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot Can you also validate that the tests validate behavior with record? The file containing the tests is ClassMustBeSealedAnalyzerTests.cs.

I've added comprehensive tests for record types to match the coverage for classes. The tests now include:

  • Record_Inherited_Diagnostic - validates records with inheritance are flagged and can be sealed
  • Record_ImplementInterface_Diagnostic - validates records implementing interfaces are flagged
  • Record_Public_NotReported - validates public records are not reported by default
  • Record_Public_WithEditorConfig_Diagnostic - validates public records are reported when configured

These tests mirror the class test scenarios and confirm the analyzer properly handles records. Commit: 2a275f2

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.nuget.org
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Release/net10.0/Meziantou.Analyzer.Test.runtimeconfig.json --depsfile /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Release/net10.0/Meziantou.Analyzer.Test.deps.json /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Release/net10.0/testhost.dll --port 43683 --endpoint 127.0.0.1:043683 --role client --parentprocessid 4349 --datacollectionport 43325 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Release/net10.0/Meziantou.Analyzer.Test.runtimeconfig.json --depsfile /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Release/net10.0/Meziantou.Analyzer.Test.deps.json /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Release/net10.0/testhost.dll --port 33777 --endpoint 127.0.0.1:033777 --role client --parentprocessid 4526 --datacollectionport 44355 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of meziantou November 2, 2025 18:04
@meziantou meziantou marked this pull request as ready for review November 2, 2025 18:35
This was referenced Nov 4, 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.

MA0053: Why are records not included in the check?

2 participants