Fix code generation when EntityAssociation is used with string constructor#572
Conversation
📝 WalkthroughWalkthroughThe changes address code generation failures during Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs (1)
34-35: 🧹 Nitpick | 🔵 TrivialOptional: drop redundant
.ToArray()materialization.Now that the locals are
IReadOnlyList<string>, you could materialize once into a list (or keep.ToArray()— either is fine). Not blocking; leaving as-is is acceptable sinceAssociationAttribute.ThisKeyMembersreturnsIEnumerable<string>and must be materialized before the.Count/indexing operations below.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs` around lines 34 - 35, The locals thisKey and otherKey are being materialized with .ToArray() though they are typed as IReadOnlyList<string>; to avoid redundant allocations change the materialization to a single list (e.g., call .ToList() once) or assign the IEnumerable directly if you only need read-only indexing—replace the current associationAttribute.ThisKeyMembers.ToArray() and associationAttribute.OtherKeyMembers.ToArray() usages with a single materialization (.ToList()) or an appropriate IReadOnlyList<string> construction so subsequent Count/indexing uses operate on that single materialized collection (refer to the locals thisKey, otherKey and associationAttribute.ThisKeyMembers/OtherKeyMembers).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs`:
- Around line 34-35: The locals thisKey and otherKey are being materialized with
.ToArray() though they are typed as IReadOnlyList<string>; to avoid redundant
allocations change the materialization to a single list (e.g., call .ToList()
once) or assign the IEnumerable directly if you only need read-only
indexing—replace the current associationAttribute.ThisKeyMembers.ToArray() and
associationAttribute.OtherKeyMembers.ToArray() usages with a single
materialization (.ToList()) or an appropriate IReadOnlyList<string> construction
so subsequent Count/indexing uses operate on that single materialized collection
(refer to the locals thisKey, otherKey and
associationAttribute.ThisKeyMembers/OtherKeyMembers).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 71c28fdb-a31d-4cd8-8cd6-14df3d6e9449
📒 Files selected for processing (2)
src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cssrc/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Cities/CityEntities.cs
|



Fix #571
Summary by CodeRabbit