Skip to content

Fix unknown ws handle written as ws="" by text props serializers - #413

Open
johnml1135 wants to merge 4 commits into
sillsdev:masterfrom
johnml1135:fix/unknown-ws-handle
Open

johnml1135 wants to merge 4 commits into
sillsdev:masterfrom
johnml1135:fix/unknown-ws-handle

Conversation

@johnml1135

@johnml1135 johnml1135 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #411

An unknown writing-system handle was saved as ws="", which no reader accepts. A run of text cannot be saved without a ws either (the reader rejects it), and throwing at save would fail every save in the project and lose unsaved edits. So runs get a fallback ws.

Writer

  • Props (StyleRules): an unknown ws/wsBase is omitted, with a Trace warning.
  • A run that needs a ws but has no usable one (unknown handle, none) is written with a fallback: the enclosing <AStr> ws, else the previous run's, else the user ws, with a Trace warning. "Needs a ws" is one shared check (RunNeedsWs) on the text actually written. It covers empty runs, ORC and link runs, and runs led by a stripped control character. Runs starting with a tab/newline still need none.
  • <AStr> with an unknown ws still throws in Core. MultiAccessor.ToXml and MultiUnicodeAccessor.ToXml (<AUni>) skip such alternatives with a Trace warning, and custom String fields no longer use an unknown first-run ws as the <AStr> ws.

Reader

  • Empty ws/wsBase in props and WsProp is dropped.
  • A run with ws="" gets the same fallback, so old records load and re-save. The <AStr> ws is resolved only when needed. Under an <AStr> with no ws the run stays ws-less, since a fallback could overwrite a real alternative.

Tests: write, read, re-save, read for each shape; plus LCM-level MultiString tests. Release, net462 and net8.0, pass.

#410 overlap: against #410 at 484f405, CHANGELOG.md (keep both lines) and TsStringSerializer.cs conflict. In the writer's run-text branch, resolve to writtenText = GetXmlSafeText(runText);. Taking this PR's side compiles but drops #410's unpaired-surrogate fix. #414 conflicts at the same spot, same resolution.

🤖 Generated with Claude Code


This change is Reviewable

johnml1135 and others added 3 commits November 5, 2026 17:11
…lsdev#411)

Writer: omit ws/wsBase props whose handle the factory does not know
(logged with Debug.WriteLine); throw instead of writing a text run or
<AStr> with an unknown ws, since readers require a ws on text runs.
Reader: ignore an empty ws/wsBase/WsProp ws so existing records load.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ng (sillsdev#411)

Writer: a text run (or empty/ORC/link run, judged on the text actually
written) with no usable ws is written with a fallback ws: the enclosing
AStr ws, else the previous run's, else the user ws; a trace warning is
logged. This replaces the throw, which would have failed every save.
Reader: a run with an existing empty ws gets the same fallback so it can
be saved again, except under an AStr with no ws, where inventing one
could overwrite a real alternative. MultiAccessor skips alternatives
keyed by an unknown ws, and custom String fields no longer use an
unknown first-run ws as the AStr ws.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ev#411)

MultiUnicodeAccessor.ToXml threw for an unknown ws, failing the whole
save. Skip and trace it like MultiAccessor.ToXml does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Only a run with an empty ws needs the AStr ws as a fallback. Resolving it
for every AStr could fail, or create a writing system, for records that
load fine without it. Also document why the user-ws fallback may create "en".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

Text props: an unknown writing-system handle is saved as ws="", which no reader can load

1 participant