Skip to content

Tier 1: error model, validation window & native [CsvKey] dictionary (v2.4.0)#2

Open
zitgatech wants to merge 3 commits into
mainfrom
feature/tier1-error-model-dictionary
Open

Tier 1: error model, validation window & native [CsvKey] dictionary (v2.4.0)#2
zitgatech wants to merge 3 commits into
mainfrom
feature/tier1-error-model-dictionary

Conversation

@zitgatech

Copy link
Copy Markdown
Contributor

Summary

Tier 1 of the roadmap: a consistent error model, a validation report window, and native
Dictionary columns. Bumps the package to 2.4.0. Editor-only; no runtime cost.

1. Collect-all error model

  • New public CsvReaderException + CsvCellError carry (row, column, value, reason).
  • Per-cell data errors are collected across the whole file and thrown together instead of
    aborting on the first bad value — fix a whole CSV in one pass. Invalid enum, non-numeric
    number, bad bool and duplicate [CsvKey] are all data errors.
  • Structural problems (empty CSV, missing column, unknown type, unconfigured assemblies)
    still fail fast. Nothing is written for a file that has data errors.

2. Validation Report window

  • Tools → Csv-Reader → Validation Report lists every data error from the last import batch,
    grouped by file, with an Open CSV shortcut. Focused automatically after a failing import.
  • A bad file no longer blocks the rest of the import batch — every file's errors surface at once.

3. Native Dictionary<K,V> via [CsvKey]

  • Mark the row type's key field with [CsvKey] and make the target field a Dictionary<K,V>;
    the reader builds it directly — no convert-method boilerplate.
  • Duplicate / null keys are reported as data errors. The [CsvKey] type must equal the key type;
    exactly one per row type.
  • Scope is one CSV → one dictionary; the holder must serialize dictionaries (Odin
    SerializedScriptableObject). Merged-folder + Dictionary fails fast with a clear message.

⚠ Behavior change (see CHANGELOG)

  • A bad cell used to throw FormatException/KeyNotFoundException on the first offender.
    It now throws a single CsvReaderException aggregating every bad cell. Code that caught the
    old specific types around a cell should catch CsvReaderException (exposes CellErrors).
    Structural exceptions are unchanged.

Testing

EditMode tests: 41/41 passing (35 previous + 6 new), verified via the Unity Test Runner.
New fixtures: ReaderErrorCollectionTests, ReaderDictionaryTests.

Commits

  1. Collect-all error model, validation window & native [CsvKey] dictionary (core)
  2. EditMode tests for error collection and dictionary build
  3. Docs + bump to 2.4.0

🤖 Generated with Claude Code

zitgatech and others added 3 commits July 3, 2026 18:37
Tier 1 core. Three cohesive changes that share the reader/postprocessor core:

Error model (#19)
- New public CsvReaderException + CsvCellError carrying (row, column, value, reason).
- Per-cell DATA errors are now collected across the whole file and thrown together
  (ParseCell wrapper + BeginCollect/ThrowIfCellErrors), so a whole CSV can be fixed in
  one pass instead of one error per re-import. Structural errors (empty CSV, missing
  column, unknown type, no assemblies) still fail fast. No asset is written on failure.

Validation window (#1)
- CsvValidationReport accumulates a batch; CsvValidationWindow (Tools > Csv-Reader >
  Validation Report) lists errors grouped by file with an Open CSV shortcut and is
  focused automatically after a failing import. A bad file no longer blocks the rest of
  the batch; the postprocessor catches CsvReaderException, reports it, and skips that asset.

Native Dictionary (#6)
- New [CsvKey] attribute; Reader.DeserializeToDictionary + CsvReaderUtils helpers
  (TryGetDictionaryTypes / GetCsvKeyField). A Dictionary<K,V> field is built directly from
  the row type's [CsvKey] field. Duplicate/null keys are data errors. Scope is one CSV to
  one dictionary; merged-folder + Dictionary fails fast with a clear NotSupportedException.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- ReaderErrorCollectionTests: a file with a bad enum and a bad int surfaces both as one
  CsvReaderException (correct 1-based rows + column names), not just the first.
- ReaderDictionaryTests: DeserializeToDictionary builds a [CsvKey]-keyed dictionary;
  duplicate key is a data error; missing [CsvKey] and key-type mismatch fail fast.

41/41 EditMode tests pass (via unity-mcp tests-run).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- README: native Dictionary (`[CsvKey]`) section, `[CsvKey]` attribute row, and a rewritten
  Error handling section (fail-fast structural vs. collected data errors + Validation window).
- CHANGELOG 2.4.0 with a migration note (catch CsvReaderException for bad-cell errors).
- package.json 2.3.0 -> 2.4.0.

Co-Authored-By: Claude Opus 4.8 <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.

1 participant