Skip to content

fix #1707: совместимость и обработка ошибок в ЗаписатьТипДокумента#1709

Open
Mr-Rm wants to merge 1 commit into
EvilBeaver:developfrom
Mr-Rm:v2/fix-1707
Open

fix #1707: совместимость и обработка ошибок в ЗаписатьТипДокумента#1709
Mr-Rm wants to merge 1 commit into
EvilBeaver:developfrom
Mr-Rm:v2/fix-1707

Conversation

@Mr-Rm

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

Copy link
Copy Markdown
Collaborator

Осталось отличие - нет пробела между " и [

Summary by CodeRabbit

  • Bug Fixes

    • Improved XML document type writing by validating input more strictly and handling missing or invalid values more consistently.
    • Added clearer error messages when document type data is incomplete or when XML writing is performed in the wrong order.
  • Tests

    • Expanded XML writing tests to cover additional success cases and error scenarios.
    • Added checks for invalid names, missing system identifiers, and incorrect write order.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

WriteDocumentType in XmlWriterImpl.cs adds argument validation, normalizes optional parameters, and remaps writer exceptions to new RuntimeException factory methods (WrongOrderException, NoSystemIdException). Corresponding test cases and procedures are added in xmlwrite.os to verify success and error scenarios.

Changes

XML DocType Validation

Layer / File(s) Summary
Validation logic and exception factories
src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs
WriteDocumentType validates name for whitespace, normalizes empty-string optional args to null, throws NoSystemIdException for missing system id, and remaps ArgumentException/InvalidOperationException to RuntimeException.InvalidNthArgumentValue(1)/WrongOrderException; new static factory methods WrongOrderException() and NoSystemIdException() are added.
Test coverage for new validation paths
tests/xmlwrite.os
Five new test identifiers and exported procedures validate 3/4-parameter success cases and error scenarios (missing system id, wrong call order, invalid name argument) for ЗаписатьТипДокумента.

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

Suggested reviewers: EvilBeaver

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly matches the main change: improving compatibility and error handling in ЗаписатьТипДокумента.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

🧹 Nitpick comments (1)
tests/xmlwrite.os (1)

834-886: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider extracting the repeated try/catch/assert pattern.

The three error tests (_4ПараметраСОшибкой, _ОшибкаПослеНачала, _ОшибкаИмени) share an identical try/catch/Найти/ПроверитьИстину structure, differing only in the setup call and expected substring. A small helper taking a setup procedure/parameters and expected substring would reduce duplication.

🤖 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/xmlwrite.os` around lines 834 - 886, The three error tests in
ТестДолжен_ПроверитьЗаписьТипаДокумента_* repeat the same try/catch, Найти, and
ПроверитьИстину flow, so extract that pattern into a small helper. Add a
reusable test helper that accepts the setup action for ЗаписьXML and the
expected error substring, then have
ТестДолжен_ПроверитьЗаписьТипаДокумента_4ПараметраСОшибкой,
ТестДолжен_ПроверитьЗаписьТипаДокумента_ОшибкаПослеНачала, and
ТестДолжен_ПроверитьЗаписьТипаДокумента_ОшибкаИмени call it with only their
differing setup and expectation.
🤖 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.

Nitpick comments:
In `@tests/xmlwrite.os`:
- Around line 834-886: The three error tests in
ТестДолжен_ПроверитьЗаписьТипаДокумента_* repeat the same try/catch, Найти, and
ПроверитьИстину flow, so extract that pattern into a small helper. Add a
reusable test helper that accepts the setup action for ЗаписьXML and the
expected error substring, then have
ТестДолжен_ПроверитьЗаписьТипаДокумента_4ПараметраСОшибкой,
ТестДолжен_ПроверитьЗаписьТипаДокумента_ОшибкаПослеНачала, and
ТестДолжен_ПроверитьЗаписьТипаДокумента_ОшибкаИмени call it with only their
differing setup and expectation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48f02c09-3b1f-43ea-82e9-5e7b810764ba

📥 Commits

Reviewing files that changed from the base of the PR and between 7c565c2 and a4bfb48.

📒 Files selected for processing (2)
  • src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs
  • tests/xmlwrite.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