Skip to content

Spell generated references from global:: and refuse members named after their type - #331

Merged
matt-edmondson merged 4 commits into
mainfrom
claude/project-thread-5pmmk1-232
Oct 22, 2026
Merged

matt-edmondson merged 4 commits into
mainfrom
claude/project-thread-5pmmk1-232

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Fixes #232

Summary

  • Root-namespace shadowing. A schema class named System, or a generator namespace ending in .System, shadowed the namespace that generated references start with, so the generated C# did not compile. The C# generator now writes all 44 emitted System./ktsu. references from global::.
  • Members named after their declaring type. C# has no spelling for these (CS0542) and C++ has none either, so validation now refuses each case with an Error that names both:
    • a member named after its class,
    • a function named after its interface,
    • a semantic type named Value, which is the name of the member that holds its value.
      The comparison is ordinal, so score inside Score is still accepted.

Tests

  • GeneratedNameCollisionTests generates and compiles a schema with a class named System (and one named ktsu) next to a class holding Vector3, List<string> and DateTime members. It also compiles the same schema under namespace Game.System.
  • Mutation check: with the generator change reverted, the System class test and the Game.System test fail to compile.
  • Validation tests cover the three refusals and the case-only difference that stays accepted.
  • CodeGenerationTests DataRows are updated to the global:: spelling.

The full suite passes except TestValidateSkipsDataFilesWhenAskedTo. That test is red on main too and is fixed by #330.


Generated by Claude Code

Refusing unknown options (#310) and the --no-data flag landed separately, and
validate's list of known options was left empty, so 'validate --no-data' exited
1 with the usage text and TestValidateSkipsDataFilesWhenAskedTo fails on main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9FBXHS37WoAF87LDY2ZVV
…d after their type

A schema class or generator namespace called System (or ktsu) shadowed the root namespace
every generated reference starts with, so the generated C# did not compile. Every emitted
System./ktsu. reference is now written from global::.

A member named after its class, a function named after its interface, and a semantic type
named Value (the member holding its value) have no spelling in C# (CS0542) or C++, so
validation now refuses each with an error naming both.

Fixes #232

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9FBXHS37WoAF87LDY2ZVV
@matt-edmondson matt-edmondson self-assigned this Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

The failing test here was TestValidateSkipsDataFilesWhenAskedTo, which is red on main too, not something this PR changed. I merged the fix from #330 into this branch so CI can go green; it will drop out of the diff once #330 merges.


Generated by Claude Code

The registry is an unsynchronised dictionary meant to be filled once at
start-up, and these tests register into it concurrently under method-level
parallelism. A lost write during a resize failed CI on Windows with a
generator registered a line earlier reported as unknown.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9FBXHS37WoAF87LDY2ZVV
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 28e1252 into main Oct 22, 2026
16 checks passed
@matt-edmondson
matt-edmondson deleted the claude/project-thread-5pmmk1-232 branch October 22, 2026 13:19
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.

Generated C# doesn't compile when a class is named System (CS0426 on System.Numerics/Collections), or when a member shares its class's name (CS0542)

2 participants