Skip to content

Let a generator that cannot ship here register itself - #157

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/peaceful-mayer-oo6l2u
Sep 10, 2026
Merged

Let a generator that cannot ship here register itself#157
matt-edmondson merged 2 commits into
mainfrom
claude/peaceful-mayer-oo6l2u

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Two things, one of which #156 should have carried and narrowly missed.

The generator table is no longer fixed

SchemaGenerator's table of generators was a private dictionary built once, which assumes every generator can live in this project. Not every one can: this library publishes net8.0, and the C++ generator being written next is built on an AST that ships no net8.0 assembly, so it has to live somewhere with a higher framework floor.

Register lets one do that and still be found by the language a schema names. IsRegistered is the other half, so a host that has just registered its own generators can ask whether a schema's language will resolve before running anything, rather than discovering it in a generation result.

Registration replaces rather than duplicates, so a host may override a built-in generator, and a generator naming no language is refused outright — it could never be found again, so an entry under an empty key would only fail later and further away. The table is process-wide and unsynchronised, meant to be filled once while a program starts; the remarks say so.

This commit was pushed to #156's branch a few seconds after that PR merged, so it never made it in. Recovered here rather than rewritten.

One assertion, from #156's Sonar analysis

MSTEST0037 on VectorElementTypeTests.ANumericComponentValidates: comparing a count to zero says less than asserting emptiness, and Assert.AreEqual(0, …) reports "expected 0, was 2" where Assert.IsEmpty names what it found. The message now joins the issues, following the convention the rest of the suite already uses for a validation assertion, so a failure says which rule fired.

The same shape appears throughout the suite and predates #156 — Sonar only reports it on new code. Only the new line is touched; a sweep would be a large diff for no behaviour.

Testing

376 tests pass, 0 warnings, 0 errors. Seven of those are new in GeneratorRegistryTests, covering registration, case-insensitive lookup, replacement, that the built-in generator is still there, and both refusals.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk


Generated by Claude Code

SchemaGenerator's table of generators was a fixed private dictionary, which
assumes every generator can live in this project. Not every one can: this
library publishes net8.0, and the C++ generator is built on an AST that ships
no net8.0 assembly, so it has to live somewhere with a higher framework floor.
Register is what lets it, and still be found by the language a schema names.

IsRegistered is the other half: a host that has just registered its own
generators can ask whether a schema's language will resolve before running
anything, rather than discovering it in a generation result.

Registration replaces rather than duplicates, so a host may override a built-in
generator, and a generator naming no language is refused outright - it could
never be found again, so an entry under an empty key would only fail later and
further away.

The table is process-wide and unsynchronised, meant to be filled once while a
program starts. The remarks say so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk
MSTEST0037: comparing a count to zero says less than asserting emptiness, and
Assert.AreEqual(0, ...) reports "expected 0, was 2" where Assert.IsEmpty names
what it found. The message follows the convention the rest of the suite already
uses for a validation assertion - joining the issues, so a failure says which
rule fired rather than only that one did.

Reported by SonarCloud on #156, which had already merged. The
same shape appears throughout the suite and predates that change; only the new
line is touched here, since a sweep would be a large diff for no behaviour.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AhoPJ5AbxP8QEBNxPQYEPk
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 7ea763e into main Sep 10, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/peaceful-mayer-oo6l2u branch September 10, 2026 12:56
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.

2 participants