Commit beb7336
committed
fix(xml): XmlConvert's TimeSpan pair uses the XSD duration form (#2080, SR-AUD-354)
XmlConvert::ToString(TimeSpan) emitted .NET's NATIVE colon form --
"1.00:00:00.0000000" for one day -- and ToTimeSpan parsed it. .NET's are
`new XsdDuration(value).ToString()` and `new XsdDuration(s).ToTimeSpan()`, and
never look at the colon form.
The deferral named three sub-questions with no repository-contained answer. The
reference answers all three.
(1) The year/month factors: XsdDuration ESTIMATES -- 365 days to the year, 30 to
the month -- and says so in as many words. Reproduced rather than improved on: a
"better" estimate would disagree with every .NET-produced value. P12M rounds to
a year, because the algorithm is (years + months/12)*365 + (months%12)*30.
(2) Does the colon form stay accepted: no. The parser requires a leading P.
Accepting both would make the contract "either grammar", which no reference or
schema defines.
(3) The exception: FormatException, always, because XmlConvert.ToTimeSpan wraps
every XsdDuration failure -- including its own OverflowException -- in one.
Two things surprised the first cut and are recorded rather than smoothed over.
"PT.5S" is VALID: .NET's '.' branch is the one component that does not check for
preceding digits, and XML Schema's duSecondFrag admits ('.' fracFrag) -- the
test was wrong, not the parser. And one line of the reference is DEAD:
XsdDuration.TryParse's trailing `if (numDigits != 0)`, which every reaching path
has already made unreachable. The port omits it, and a mutation confirmed that
changes nothing.
ToString and ToTimeSpan round-trip, asserted over eight values including
negatives, zero and a single tick.
Two #1836 tests are rewritten in the new grammar rather than deleted, because
the property they pin -- an out-of-range day count raises rather than wrapping
negative -- is unchanged.
+3 net tests. Five mutations: three caught directly, one re-run after an invalid
first cut, one that led to deleting the dead line.
Gate: 17,265 run, 0 failed, 38 executables -- green. Downstream, measured: zero
XmlConvert sites in either consumer.
SR-AUD-354 -> remediated. Record: docs/Migration-XmlConvertXsdDuration.md.1 parent b9346ee commit beb7336
7 files changed
Lines changed: 437 additions & 47 deletions
File tree
- audit
- docs
- modules/xml
- src/System/Xml
- tests/System/Xml
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments