Skip to content

Исправления и добавления в СписокЗначений#1710

Open
Mr-Rm wants to merge 5 commits into
EvilBeaver:developfrom
Mr-Rm:v2/fix-valuelist
Open

Исправления и добавления в СписокЗначений#1710
Mr-Rm wants to merge 5 commits into
EvilBeaver:developfrom
Mr-Rm:v2/fix-valuelist

Conversation

@Mr-Rm

@Mr-Rm Mr-Rm commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Value lists can now normalize and enforce item types, optionally restricting values to a predefined set.
    • Value type descriptions are improved for clearer display.
  • Bug Fixes

    • Added stronger index bounds validation for value list operations.
    • Read-only indexed updates now return a dedicated, clearer error.
    • Better error reporting when a list item doesn’t belong to the current value list.
  • Tests

    • Expanded automated checks for invalid retrieval/insertion indexes and updated coverage for value-list properties.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ddc58ca-237b-48c9-9436-2a6eec3ecdcd

📥 Commits

Reviewing files that changed from the base of the PR and between 02c147d and 63c558b.

📒 Files selected for processing (2)
  • src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs
  • tests/value-list.os
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs

📝 Walkthrough

Walkthrough

ValueListImpl now supports value-type adjustment and available-value normalization, applies explicit index and ownership validation, and exposes dedicated exception factories. TypeDescription, ValueListItem, and value-list script tests are updated accordingly.

Changes

ValueList behavior

Layer / File(s) Summary
Value normalization and public type support
src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs, src/OneScript.StandardLibrary/Collections/ValueList/ValueListItem.cs, src/OneScript.StandardLibrary/TypeDescriptions/TypeDescription.cs
Created items are adjusted through ListValueType and AvailableValues; ValueListItem construction is restricted to the assembly, and TypeDescription.ToString() renders contained types.
Index validation and error coverage
src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs, tests/value-list.os
Retrieval, insertion, lookup, and move operations use explicit bounds checks and dedicated exceptions; script tests verify invalid Insert and Get errors.
Available-values and type test coverage
tests/value-list.os
Script tests verify ТипЗначения and ДоступныеЗначения behavior with and without a configured type, including conversion and out-of-range handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ValueListImpl
  participant TypeDescription
  participant AvailableValues
  participant ValueListItem
  Caller->>ValueListImpl: Insert(value)
  ValueListImpl->>TypeDescription: AdjustValue(value)
  ValueListImpl->>AvailableValues: FindByValue(adjusted value)
  ValueListImpl->>ValueListItem: create normalized item
  ValueListImpl-->>Caller: updated list
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% 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 clearly related to the main changes in СписокЗначений and is specific enough for history scanning.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs (1)

87-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add defensive null handling for C# callers.

While the OneScript engine passes BslUndefinedValue when a script sets the property to Неопределено, direct C# callers might clear the property by passing null. The current switch throws an InvalidArgumentType exception for null.

Consider treating null identically to BslUndefinedValue.

♻️ Proposed refactor
             set
             {
                 switch (value)
                 {
+                    case null:
                     case BslUndefinedValue:
                         _availableValues = null;
                         break;
 
                     case ValueListImpl vl:
                         _availableValues = vl;
                         break;
 
                     default: throw RuntimeException.InvalidArgumentType();
                 }
             }
🤖 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 `@src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs` around
lines 87 - 101, Update the property setter containing the switch on value to
handle a C# null input the same way as BslUndefinedValue: clear _availableValues
and return without throwing. Preserve the existing ValueListImpl assignment and
InvalidArgumentType behavior for all other values.
🤖 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/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs`:
- Around line 157-170: Update CreateNewListItem so
_availableValues.FindByValue(newValue) is treated as a lookup result: use the
matched ValueListItem.Value when found, and retain or reapply
ListValueType.AdjustValue for a missing result such as BslUndefinedValue. Ensure
the returned ValueListItem.Value is never another ValueListItem.

---

Nitpick comments:
In `@src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs`:
- Around line 87-101: Update the property setter containing the switch on value
to handle a C# null input the same way as BslUndefinedValue: clear
_availableValues and return without throwing. Preserve the existing
ValueListImpl assignment and InvalidArgumentType behavior for all other values.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: af84cea8-c1d8-40b8-ade6-4b86459beef3

📥 Commits

Reviewing files that changed from the base of the PR and between 1c19450 and 02c147d.

📒 Files selected for processing (4)
  • src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs
  • src/OneScript.StandardLibrary/Collections/ValueList/ValueListItem.cs
  • src/OneScript.StandardLibrary/TypeDescriptions/TypeDescription.cs
  • tests/value-list.os

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