Skip to content

Add [Mutable] code fix for RG0015-RG0018 warnings#115

Merged
ronnygunawan merged 7 commits intomasterfrom
copilot/fix-records-with-rg0015-warnings
Nov 30, 2025
Merged

Add [Mutable] code fix for RG0015-RG0018 warnings#115
ronnygunawan merged 7 commits intomasterfrom
copilot/fix-records-with-rg0015-warnings

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

  • Analyze the repository structure and understand the analyzer patterns

  • Understand RG0015-RG0018 warnings (records immutability checks)

  • Understand how the [Mutable] attribute works in RG.Annotations

  • Review existing code fix providers for patterns

  • Build and test to verify the current state

  • Create the AddMutableAttributeCodeFixProvider

  • Add tests for the new code fix provider

  • Update README.md documentation

  • Run code review and address issues

  • Run CodeQL security scan - No vulnerabilities found

  • Fix indentation to use consistent 4-space indentation in test strings

  • Fix newline placement - removed extra trailing newline from attribute so Roslyn Formatter handles spacing correctly

  • Preserve original newline trivia between declarations (e.g., blank line between MyClass and RecordName)

  • Fixes New code fix: Add [Mutable] to records with RG0015-0018 warnings #55

Original prompt

This section details on the original issue you should resolve

<issue_title>New code fix: Add [Mutable] to records with RG0015-0018 warnings</issue_title>
<issue_description>Offer this code fix where those warnings appear. The code fix would effectively resolve the warnings</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 30, 2025 01:41
Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Mutable to records with RG0015-0018 warnings Add [Mutable] code fix for RG0015-RG0018 warnings Nov 30, 2025
Copilot AI requested a review from ronnygunawan November 30, 2025 01:49
@ronnygunawan ronnygunawan marked this pull request as ready for review November 30, 2025 03:25
Copy link
Owner

@ronnygunawan ronnygunawan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation

Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 30, 2025

Fix the indentation

Fixed in 935c96b. The test strings now use consistent 4-space indentation throughout (both input and expected output), matching what the Roslyn Formatter produces when applying the code fix.

namespace ConsoleApplication1 {
public class MyClass { }
[Mutable]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks funny. the newline should be before the annotation, not after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a10cca8. Simplified the trivia handling - the attribute now takes the record's original leading trivia without adding an extra trailing newline. This allows the Roslyn Formatter to handle the spacing correctly. The blank line now properly appears before the [Mutable] annotation as the attribute inherits the record's original leading trivia.

… not after

Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>

namespace ConsoleApplication1 {
public class MyClass { }
[Mutable]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should respect the original newline trivia between MyClass and RecordName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 60c80ee. The code fix now properly preserves the original blank line trivia between declarations. When there's a blank line before the record (like between MyClass and RecordName), it will now appear before the [Mutable] attribute as expected.

…table] attribute

Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
@ronnygunawan ronnygunawan merged commit 6c2c868 into master Nov 30, 2025
2 checks passed
@ronnygunawan ronnygunawan deleted the copilot/fix-records-with-rg0015-warnings branch November 30, 2025 15:23
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.

New code fix: Add [Mutable] to records with RG0015-0018 warnings

2 participants