fix #1705: проверка приемника данных; возврат строки из Закрыть#1706
fix #1705: проверка приемника данных; возврат строки из Закрыть#1706Mr-Rm wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
XmlWriterImpl null-safety and Close() refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
|
Добрый день!
В период с 29.06.2026 по 05.07.2026 включительно, буду находиться в отпуске.
Почта просматриваться не будет.
И.о. руководителя ОВСИС Иванова Ю.Ф.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs (2)
313-326: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
WriteDocumentTypehas the same omitted-argument bug.The branch conditions here also assume omitted optional strings are
null. In script calls they arrive as"", so a shorter call can take the wrongWriteDocType(...)branch and pass the DTD parts in the wrong slots. This needs the same fix asWriteAttribute: stop using optional concretestringparameters when omission changes behavior.Based on learnings, omitted concrete
stringparameters from scripts arrive as"", notnull, so these null checks do not reliably encode arity.🤖 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 313 - 326, WriteDocumentType in XmlWriterImpl has the same omitted-argument handling bug as WriteAttribute, because it branches on nullable string parameters even though omitted script arguments arrive as empty strings. Update the method signature/dispatch so it determines the intended arity without relying on null checks, and make sure the WriteDocType call maps the DTD parts into the correct slots for 1-, 2-, 3-, and 4-argument calls.Source: Learnings
85-95: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
WriteAttributestill misdetects omitted script arguments.
value == nullonly works for direct C# callers. From OneScript, omitting the thirdstringargument passes"", so a two-argument script call will go through the namespace overload and write the wrong attribute. Use a non-stringsentinel (IValue/BslValue) or split the overloads so empty string stays a valid value.Based on learnings, omitted concrete
stringparameters from scripts arrive as"", notnull, so null-based overload detection is unsafe here.🤖 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 85 - 95, The WriteAttribute method in XmlWriterImpl still relies on value == null to detect whether the third argument was omitted, but OneScript passes omitted string arguments as empty strings. Update WriteAttribute so it distinguishes omission from an explicit empty string using a non-string sentinel (such as IValue/BslValue) or by splitting the overloads, and keep the namespace overload path only for the truly omitted case while preserving empty string as a valid attribute value.Source: Learnings
🤖 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 54-59: `CheckIfOpen()` is not being used consistently across the
public write surface, and `WriteNamespaceMapping()` can still hit `_writer` when
the writer is closed. Update `XmlWriterImpl.WriteNamespaceMapping()` to guard
with `CheckIfOpen()` the same way other write entry points do, and make sure it
raises `NotOpenException()` before any `_writer` access so the public API fails
consistently.
---
Outside diff comments:
In `@src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cs`:
- Around line 313-326: WriteDocumentType in XmlWriterImpl has the same
omitted-argument handling bug as WriteAttribute, because it branches on nullable
string parameters even though omitted script arguments arrive as empty strings.
Update the method signature/dispatch so it determines the intended arity without
relying on null checks, and make sure the WriteDocType call maps the DTD parts
into the correct slots for 1-, 2-, 3-, and 4-argument calls.
- Around line 85-95: The WriteAttribute method in XmlWriterImpl still relies on
value == null to detect whether the third argument was omitted, but OneScript
passes omitted string arguments as empty strings. Update WriteAttribute so it
distinguishes omission from an explicit empty string using a non-string sentinel
(such as IValue/BslValue) or by splitting the overloads, and keep the namespace
overload path only for the truly omitted case while preserving empty string as a
valid attribute value.
🪄 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: 4340bfac-cdbf-4471-84d4-d0aa45759bac
📒 Files selected for processing (2)
src/OneScript.StandardLibrary/Xml/XmlWriterImpl.cstests/xmlwrite.os
Summary by CodeRabbit
Закрыть()behavior to be null-safe and consistently return an empty string when there’s no output (string vs. file modes handled correctly).Закрыть()on a newly created writer returns an empty string and the expected string return type.Закрыть()is called after opening a file.