You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Members that differ only by word boundaries (PlayerID / PlayerId, fooBar / foo_bar) pass validation, then map to the same snake_case name, so the generated C++ header does not compile #261
CppGeneratorOptions.MemberNaming defaults to CppMemberNaming.SnakeCase (Schema.Cpp/CppGeneratorOptions.cs:132). CppNaming.Member (Schema.Cpp/CppNaming.cs:26) runs every member, function and parameter name through SnakeCase (CppNaming.cs:55-106). That conversion is many-to-one:
PlayerID and PlayerId both become player_id
fooBar and foo_bar both become foo_bar
Validation only rejects names that are exactly equal (Schema/Models/Schema.Validation.cs:95, where ReportDuplicates groups ordinally). The same holds for function names and parameter names (Schema.Validation.cs around lines 620 and 641). Nothing checks whether two spelled names collide: neither validation nor CppFileBuilder (around lines 222, 240 and 252) does. The generator therefore writes two declarations with the same name.
Failure scenario
Verified with the published ktsu.Schema.Cpp 1.36.11 and g++.
Take a class Player with members PlayerID: Int and PlayerId: Long. Schema.Validate() reports nothing about the names, and CppCodeGenerator.Generate emits:
g++ -std=c++20 then fails with error: redeclaration of 'int64_t game::Player::player_id'.
The C# output for the same schema compiles, so the error appears only in the C++ consumer, and it points at generated code. The reflection table from CppReflectionBuilder (around line 202) names the field the same way, so it is ambiguous as well.
Suggested fix / acceptance criteria
When generating, refuse a class whose members map to the same C++ name, with CppGenerationException/TargetCannotExpress naming both schema names and the shared spelling. Apply the same check to interface functions and to the parameters of one function.
Alternatively, add a target-independent validation rule that rejects member names that are equal after folding case and underscores.
Add a test with PlayerID/PlayerId and another with fooBar/foo_bar. Each should be refused with a clear message rather than producing a header that does not compile.
Priority: Low. It takes two member names that differ only by case or underscores. The failure is loud (a C++ compile error), not silent, though the error points at generated code instead of at the schema.
Area / suggested assignment: C++ generator or validation. Schema.Cpp/CppNaming.cs and CppFileBuilder, or a target-independent rule in Schema/Models/Schema.Validation.cs that folds case and underscores.
Activity
matt-edmondson commentedon Oct 7, 2026
Triage
Schema.Cpp/CppNaming.csandCppFileBuilder, or a target-independent rule inSchema/Models/Schema.Validation.csthat folds case and underscores.System(CS0426 on System.Numerics/Collections), or when a member shares its class's name (CS0542) #232 (a member sharing its class's name). A single "names equal after normalisation" validation pass might cover Element names that differ only in case pass validation, then overwrite each other's generated files on Windows and macOS #258 and this issue together. The only open Schema PR, Bump the ktsu group with 17 updates #260, is a dependency bump.Generated by Claude Code