Skip to content

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

Closed
Mr-Rm wants to merge 2 commits into
EvilBeaver:developfrom
Mr-Rm:v2/fix-1707
Closed

fix #1707: совместимость и обработка ошибок в ЗаписатьТипДокумента +тесты#1708
Mr-Rm wants to merge 2 commits 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 inputs, normalizing optional parameters, and enforcing required conditions for system identifiers.
    • Enhanced error handling to provide clearer, more consistent exceptions for invalid argument values and incorrect write order.
  • Tests
    • Added new acceptance tests for XML document type output, covering both valid 4- and 3-parameter variants and negative scenarios (missing system identifier and write-order errors).

@coderabbitai

coderabbitai Bot commented Jul 7, 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: 98817b07-0cd8-45e1-be38-b1c6d7233687

📥 Commits

Reviewing files that changed from the base of the PR and between 4c99323 and 082c0ea.

📒 Files selected for processing (2)
  • src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs
  • tests/xmlwrite.os
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/xmlwrite.os
  • src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs

📝 Walkthrough

Walkthrough

XmlWriterImpl.WriteDocumentType now validates its inputs, routes to the appropriate write overload, and converts writer exceptions into runtime exceptions using new factory methods. tests/xmlwrite.os adds four exported acceptance tests for successful and failing WriteDocumentType calls.

Changes

WriteDocumentType refactor and tests

Layer / File(s) Summary
WriteDocumentType validation, exception translation and factories
src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs
WriteDocumentType validates the name argument, normalizes optional arguments, converts writer exceptions into runtime exceptions, and adds factory methods for the new error messages.
WriteDocumentType tests
tests/xmlwrite.os
Registers four new test cases and adds exported procedures covering successful 4-parameter and 3-parameter writes plus two negative cases for missing system id and invalid call order.

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

Possibly related PRs

  • EvilBeaver/OneScript#1583: This earlier PR also touches XmlWriterImpl.WriteDocumentType through WriteCurrent, so its call path overlaps with the refactor here.

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 The title clearly matches the main change: compatibility and error handling improvements in ЗаписатьТипДокумента with tests.
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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs (1)

526-540: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider narrowing factory method visibility.

WrongOrderException() and NoSystemIdException() are public static but only appear to be used internally by WriteDocumentType. No [ContextMethod] attribute exposes them to scripts, and no other file in the provided context references them. Making them private static would reduce the public API surface without any behavior change.

♻️ Proposed visibility change
-        public static RuntimeException WrongOrderException()
+        private static RuntimeException WrongOrderException()
         {
             return new RuntimeException
                 ("Ошибочный порядок записи XML",
                  "Wrong order of XML record");
         }

-        public static RuntimeException NoSystemIdException()
+        private static RuntimeException NoSystemIdException()
         {
             return new RuntimeException
                 ("Отсутствует системный идентификатор",
                 "System ID missing");
         }
🤖 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/Xml/XmlWriterImpl.cs` around lines 526 - 540,
The two factory helpers used only by XmlWriterImpl.WriteDocumentType are more
visible than necessary: WrongOrderException() and NoSystemIdException() are
declared public static even though they are internal implementation details.
Change their visibility to private static in XmlWriterImpl so the public API
surface is reduced without affecting behavior, and keep their use confined to
WriteDocumentType.
🤖 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/Xml/XmlWriterImpl.cs`:
- Around line 332-335: Add a test for the remaining ArgumentException path in
WriteDocType by covering an invalid DOCTYPE name in xmlwrite.os. Extend the
existing XmlWriterImpl/XmlWriter WriteDocType coverage to verify that passing a
bad name triggers RuntimeException.InvalidNthArgumentValue(1), alongside the
current valid, missing system-id, and wrong-order cases.

---

Nitpick comments:
In `@src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs`:
- Around line 526-540: The two factory helpers used only by
XmlWriterImpl.WriteDocumentType are more visible than necessary:
WrongOrderException() and NoSystemIdException() are declared public static even
though they are internal implementation details. Change their visibility to
private static in XmlWriterImpl so the public API surface is reduced without
affecting behavior, and keep their use confined to WriteDocumentType.
🪄 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: 18deac6a-4405-4aed-86d6-d0bb3984d250

📥 Commits

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

📒 Files selected for processing (2)
  • src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs
  • tests/xmlwrite.os

Comment thread src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs Outdated
@Mr-Rm Mr-Rm closed this Jul 7, 2026
@Mr-Rm Mr-Rm deleted the v2/fix-1707 branch July 7, 2026 13:34
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