Skip to content

Improve [Validate] codefixer behavior - #309

Merged
viceroypenguin merged 4 commits into
mainfrom
code-fixer
Aug 12, 2026
Merged

Improve [Validate] codefixer behavior#309
viceroypenguin merged 4 commits into
mainfrom
code-fixer

Conversation

@viceroypenguin

@viceroypenguin viceroypenguin commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved formatting and import handling when adding the [Validate] attribute.
    • Preserved XML documentation, existing attributes, and declaration formatting when applying the code fix.
    • Added cancellation support for more responsive code-fix operations.
  • Tests

    • Added coverage for records with no attributes, existing attributes, XML documentation, and combined documentation and attributes.
    • Verified that [Validate] is inserted correctly without altering existing declarations.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@viceroypenguin, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 08e8331b-0692-4526-8dde-2e8fcb6bc443

📥 Commits

Reviewing files that changed from the base of the PR and between 228c257 and 77fbc4d.

📒 Files selected for processing (1)
  • src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ad2d2359-b3db-45d2-8ffd-8a18cdc663ad

📥 Commits

Reviewing files that changed from the base of the PR and between 9c5c7ba and 228c257.

📒 Files selected for processing (2)
  • src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs
  • tests/Immediate.Validations.Tests/CodeFixTests/AddValidateAttributeCodefixProviderTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs

📝 Walkthrough

Walkthrough

The code fix now inserts [Validate] asynchronously. It resolves the attribute symbol, preserves declaration trivia, and applies formatting and import simplification. Tests cover records with existing attributes and XML documentation.

Changes

Validate attribute code fix

Layer / File(s) Summary
Attribute insertion and validation
src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs, tests/Immediate.Validations.Tests/CodeFixTests/AddValidateAttributeCodefixProviderTests.cs
The code fix resolves ValidateAttribute, preserves existing attributes and XML documentation, adds simplifier and formatter annotations, and returns the updated document asynchronously. Tests cover unannotated records, existing attributes, XML documentation, and combined cases.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change to the [Validate] code fixer behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch code-fixer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/Immediate.Validations.Tests/CodeFixTests/AddValidateAttributeCodefixProviderTests.cs (1)

36-64: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for import insertion.

Both code-fix fixtures place the target in Immediate.Validations.Shared. The new attribute is therefore already in scope. These tests can pass even when the Simplifier.AddImportsAnnotation path fails to add using Immediate.Validations.Shared;. Add a fixture in another namespace without that using directive and assert that the import is inserted. (learn.microsoft.com)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tests/Immediate.Validations.Tests/CodeFixTests/AddValidateAttributeCodefixProviderTests.cs`
around lines 36 - 64, Add a code-fix test alongside
AddValidateAttributeWorksCorrectlyWithXmlDocs using a different namespace and no
existing Immediate.Validations.Shared import, then assert the transformed output
inserts using Immediate.Validations.Shared; while adding [Validate]. Keep the
existing in-scope fixtures unchanged and exercise the
Simplifier.AddImportsAnnotation path through the new fixture.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs`:
- Line 6: Remove the unused Microsoft.CodeAnalysis.CSharp using directive from
AddValidateAttributeCodefixProvider, while retaining the
Microsoft.CodeAnalysis.CSharp.Syntax import required by the file.
- Around line 54-68: The attribute list created in the type-declaration
transformation should be inserted before existing attributes, not appended.
Update the `WithAttributeLists` call in the codefix provider to use `Insert(0,
...)`, preserving XML documentation ahead of all attribute sections, and add a
regression test covering a type with existing attributes and documentation.

---

Nitpick comments:
In
`@tests/Immediate.Validations.Tests/CodeFixTests/AddValidateAttributeCodefixProviderTests.cs`:
- Around line 36-64: Add a code-fix test alongside
AddValidateAttributeWorksCorrectlyWithXmlDocs using a different namespace and no
existing Immediate.Validations.Shared import, then assert the transformed output
inserts using Immediate.Validations.Shared; while adding [Validate]. Keep the
existing in-scope fixtures unchanged and exercise the
Simplifier.AddImportsAnnotation path through the new fixture.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ee1df63-836c-4f3c-90f9-6af672379ea4

📥 Commits

Reviewing files that changed from the base of the PR and between 55baca5 and 9c5c7ba.

📒 Files selected for processing (2)
  • src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs
  • tests/Immediate.Validations.Tests/CodeFixTests/AddValidateAttributeCodefixProviderTests.cs

Comment thread src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs Outdated
@coveralls

coveralls commented Aug 12, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 31621615623

Warning

No base build found for commit 9074d31 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 84.08%

Details

  • Patch coverage: 1 uncovered change across 1 file (48 of 49 lines covered, 97.96%).

Uncovered Changes

File Changed Covered %
src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs 49 48 97.96%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 2255
Covered Lines: 1896
Line Coverage: 84.08%
Coverage Strength: 3.36 hits per line

💛 - Coveralls

@viceroypenguin

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@viceroypenguin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 228c257b46

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs Outdated
Comment thread src/Immediate.Validations.CodeFixes/AddValidateAttributeCodefixProvider.cs Outdated
@viceroypenguin
viceroypenguin enabled auto-merge (squash) August 12, 2026 17:14
@viceroypenguin
viceroypenguin merged commit 59c8da0 into main Aug 12, 2026
3 checks passed
@viceroypenguin
viceroypenguin deleted the code-fixer branch August 12, 2026 17:18
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.

2 participants