feat(skd): nilValue marker для параметров с xsi:nil="true"

Параметры со скалярным типом (decimal/string/dateTime) и <value xsi:nil="true"/>
теперь сохраняют значение nil через object form {nilValue:true}. Раньше compile
эмитил типизированный default (xs:decimal>0, xs:string/>, xs:dateTime>0001-01-01)
вместо nil — мismatch на bit-perfect round-trip.

sample30: −22 строки (2034 → 2012).
This commit is contained in:
Nick Shirokov
2026-05-23 17:51:35 +03:00
parent f75c71064c
commit 48e2b6bd44
3 changed files with 23 additions and 3 deletions
@@ -1,4 +1,4 @@
# skd-compile v1.72 — Compile 1C DCS from JSON
# skd-compile v1.73 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$DefinitionFile,
@@ -1273,6 +1273,9 @@ function Emit-SingleParam {
if (Test-EmptyValue $parsed.value) {
if (-not $vla) { X "`t`t<value xsi:nil=`"true`"/>" }
}
} elseif ($parsed.nilValue -eq $true) {
# Принудительный xsi:nil даже когда тип известен (для bit-perfect round-trip).
if (-not $vla) { X "`t`t<value xsi:nil=`"true`"/>" }
} else {
Emit-ParamValue -type $parsed.type -val $parsed.value -indent "`t`t" -valueListAllowed $vla
}
@@ -1379,6 +1382,7 @@ function Emit-Parameters {
if ($p.valueListAllowed -eq $true) { $parsed.valueListAllowed = $true }
if ($p.hidden -eq $true) { $parsed.hidden = $true }
if ($p.autoDates -eq $true) { $parsed.autoDates = $true }
if ($p.nilValue -eq $true) { $parsed.nilValue = $true }
}
# @autoDates implies use=Always + denyIncompleteValues=true by default
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# skd-compile v1.72 — Compile 1C DCS from JSON
# skd-compile v1.73 — Compile 1C DCS from JSON
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import json
@@ -1086,6 +1086,10 @@ def emit_single_param(lines, p, parsed):
if is_empty_value(parsed.get('value')):
if not vla:
lines.append('\t\t<value xsi:nil="true"/>')
elif parsed.get('nilValue') is True:
# Принудительный xsi:nil даже когда тип известен (для bit-perfect round-trip).
if not vla:
lines.append('\t\t<value xsi:nil="true"/>')
else:
emit_param_value(lines, p_type, parsed.get('value'), '\t\t', vla)
@@ -1192,6 +1196,8 @@ def emit_parameters(lines, defn):
parsed['hidden'] = True
if p.get('autoDates') is True:
parsed['autoDates'] = True
if p.get('nilValue') is True:
parsed['nilValue'] = True
# @autoDates implies use=Always + denyIncompleteValues=true by default
# (derived &НачалоПериода/&КонецПериода need a populated period).