Correct handling of Named Arguments - #300
Conversation
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Coverage Report for CI Build 30370347066Coverage remained the same at 83.852%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This pull request fixes the mismatch described in #297 by ensuring [TargetType] values supplied via named attribute arguments (init-only validator properties) are resolved like member references (e.g., nameof(Password) → instance.Password) rather than emitted as string literals.
Changes:
- Update generator argument handling to pass the actual initializer property symbol into argument-value construction so
[TargetType]detection works for named arguments. - Add a new generator test covering
nameof(...)used in a named attribute argument for a[TargetType]init-only property. - Add/record the verified snapshot showing the generated code now passes the referenced member value (and preserves the comparison name metadata).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Immediate.Validations.Tests/GeneratorTests/ValidatorArgumentTests.cs | Adds a regression test for nameof inside a named attribute argument targeting an init-only [TargetType] property. |
| tests/Immediate.Validations.Tests/GeneratorTests/Snapshots/ValidatorArgumentTests.NameOfInNamedArgument#IV...ValidateClass.g.verified.cs | Captures the expected generated output verifying comparison: instance.Password (not "Password"). |
| src/Immediate.Validations.Generators/ValidateTargetTransformer.cs | Fixes named-argument handling by passing the initializer property symbol into BuildArgumentValue, enabling [TargetType] nameof resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #297