Skip to content

Data sources: define path resolution, then load and validate the bound data #120

Description

@matt-edmondson

Problem

DataSource (Schema/Models/DataSource.cs) stores a RelativeFilePath File and a ClassName, and nothing in the solution ever opens that file. It is a metadata shell — the second of the two the roadmap calls out (Phase 4).

The immediate blocker is that RelativeFilePath has no anchor. Nothing in the codebase or docs defines what the path is relative to, so a data source path cannot be resolved even in principle. Schema itself has no notion of where it was loaded from — SchemaFile.TryLoad (SchemaEditor) knows the path but doesn't hand it to the model.

Scope

1. Path resolution (prerequisite)

  • Define resolution relative to the .schema.json file's own location and document it in the format docs.
  • Give the core library a way to know that location — e.g. a source-path property populated by the loader, or a resolution API that takes the schema file path as a parameter. Keep SchemaSerializer filesystem-free if that separation is intended; the anchor can be passed in.
  • Validation can then report a data source whose file does not exist.

2. Data loading and validation

Load the JSON a DataSource points at and validate it against the referenced class: required members present, values conform to member types, enum values are members of the referenced enum, container shapes match (vector → array, map → object keyed by the array's Key member). This is the foundation the migration work is checked against.

3. Generated data editors

Extend the Phase 3 generator architecture so a generator can consume a DataSource (class + file binding) and emit a typed editor for that data.

4. Generated migrations

Detect schema changes affecting bound data files — renamed, removed, or retyped members, enum value changes — and generate migration code or scripts that upgrade the data in place. Depends on the .schema.json format version field and on a schema-diff capability.

Items 3 and 4 are substantial in their own right and should become separate issues once 1 and 2 land; this issue tracks the phase and its sequencing.

Acceptance criteria

  • RelativeFilePath resolution for data sources is documented and implemented.
  • Validate() reports a data source pointing at a nonexistent file.
  • Data files can be loaded and validated against their bound class, with a diagnostic per conformance failure.
  • Follow-on issues exist for generated data editors and migrations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions