Skip to content

✨ handle choice groups that require at least one element#48

Merged
igotinfected merged 2 commits into
mainfrom
feature/required-choices
May 4, 2026
Merged

✨ handle choice groups that require at least one element#48
igotinfected merged 2 commits into
mainfrom
feature/required-choices

Conversation

@igotinfected
Copy link
Copy Markdown
Member

@igotinfected igotinfected commented May 4, 2026

Updated our custom xml schema generator to handle choice groups that require at least one value (i.e. are not optional).

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated package dependencies to version 99.0.11-local
  • Tests

    • Enhanced test utilities for choice group attribute validation
    • Added comprehensive test coverage for choice group attributes, including required vs optional specifications, nested group relationships, and cardinality constraints across multiple XML structure scenarios

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@igotinfected has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 23 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: feff3900-ee6b-4944-983e-7dcbb38849ab

📥 Commits

Reviewing files that changed from the base of the PR and between a7e317f and 95e03f5.

📒 Files selected for processing (3)
  • packages/XmlSchemaClassGenerator-beta.99.0.11-local.nupkg
  • packages/XmlSchemaClassGenerator.Analyzer.99.0.11-local.nupkg
  • src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs
📝 Walkthrough

Walkthrough

The PR updates two XmlSchemaClassGenerator package versions from 99.0.10-local to 99.0.11-local in the central package directory and extends choice group attribute test utilities with validation test cases.

Changes

Dependency and Test Enhancements

Layer / File(s) Summary
Package Version Update
src/Directory.Packages.props
XmlSchemaClassGenerator-beta and XmlSchemaClassGenerator.Analyzer versions bumped from 99.0.10-local to 99.0.11-local.
Test Utility Enhancements
src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs
Added GetChoiceGroupAttributes<T> method to return all XmlChoiceGroupAttribute instances for a property; refactored GetChoiceGroupAttribute<T> to use GetCustomAttributes().FirstOrDefault() pattern.
Test Coverage
src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs
Updated Should_have_multiple_distinct_choice_groups_on_control_action_structure to collect multiple attributes via SelectMany; added three new tests validating required vs optional choice group requirements for PT secondary reasons, arm/group cardinality, and nested service delivery choice membership behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A bump from ten to eleven takes flight,
New helpers gather attributes just right,
Choice groups nested deep, required or free,
Tests validate the schema spree! ✨

🚥 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 is directly related to the main objective of the pull request—handling choice groups that require at least one element—as evidenced by the new test cases validating choice-group requirements.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/required-choices

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 0/1 reviews remaining, refill in 19 minutes and 23 seconds.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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)
src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs (1)

183-194: ⚡ Quick win

Assert the full distinct choice-group set.

>= 2 only proves there is more than one group; it won’t catch a regression that drops one of the expected ControlActionStructure groups. If the schema shape is stable, this can be a much stronger regression check.

📏 Suggested fix
-        choiceGroupIds.Count.Should().BeGreaterThanOrEqualTo(2);
+        choiceGroupIds.Should().HaveCount(5);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs` around
lines 183 - 194, Replace the weak assertion in
Should_have_multiple_distinct_choice_groups_on_control_action_structure with a
precise check of the full distinct set: compute choiceGroupIds from
typeof(ControlActionStructure).GetProperties() as you already do, then assert
that the result equals the expected set (or expected count) of group IDs for
ControlActionStructure (e.g., Assert that
choiceGroupIds.SequenceEqual(expectedList) or choiceGroupIds.Count ==
expectedCount), using the existing variable names choiceGroupIds and
ControlActionStructure to locate the test and prevent regressions if a group is
removed or renamed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs`:
- Around line 16-19: The helper GetChoiceGroupAttribute<T>(string propertyName)
currently uses FirstOrDefault() which will hide cases where a property has more
than one XmlChoiceGroupAttribute; change it to enforce a single result (e.g.,
use SingleOrDefault() or enumerate
.GetCustomAttributes<XmlChoiceGroupAttribute>() and throw an informative
exception if Count > 1) so duplicate annotations fail fast and surface generator
regressions; keep the method signature and use
typeof(T).GetProperty(propertyName) to locate the property and then validate the
attribute collection before returning the single attribute or null.
- Around line 250-280: The test
Should_keep_outer_and_inner_memberships_for_nested_service_delivery_choice
currently asserts IsRequired for production, estimated and situationExchange but
omits included; update the final assertion to include the included collection so
the requiredness of the outer-member (included) is also verified (e.g., combine
included with production, estimated and situationExchange before the AllSatisfy
check).

---

Nitpick comments:
In `@src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs`:
- Around line 183-194: Replace the weak assertion in
Should_have_multiple_distinct_choice_groups_on_control_action_structure with a
precise check of the full distinct set: compute choiceGroupIds from
typeof(ControlActionStructure).GetProperties() as you already do, then assert
that the result equals the expected set (or expected count) of group IDs for
ControlActionStructure (e.g., Assert that
choiceGroupIds.SequenceEqual(expectedList) or choiceGroupIds.Count ==
expectedCount), using the existing variable names choiceGroupIds and
ControlActionStructure to locate the test and prevent regressions if a group is
removed or renamed.
🪄 Autofix (Beta)

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

Run ID: bc757461-f58f-49f1-aad6-64ccf1301f50

📥 Commits

Reviewing files that changed from the base of the PR and between 8afed16 and a7e317f.

📒 Files selected for processing (6)
  • packages/XmlSchemaClassGenerator-beta.99.0.10-local.nupkg
  • packages/XmlSchemaClassGenerator-beta.99.0.11-local.nupkg
  • packages/XmlSchemaClassGenerator.Analyzer.99.0.10-local.nupkg
  • packages/XmlSchemaClassGenerator.Analyzer.99.0.11-local.nupkg
  • src/Directory.Packages.props
  • src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs

Comment thread src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs Outdated
Comment thread src/siri/Spillgebees.SIRI.Models.Tests/ChoiceGroupAttributeTests.cs
@igotinfected igotinfected merged commit c2a241d into main May 4, 2026
3 checks passed
@igotinfected igotinfected deleted the feature/required-choices branch May 4, 2026 03:47
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.

1 participant