Repository navigation
Skip keys that clash with generated C# class members - #1315
jsskeen-utah wants to merge 2 commits into
Conversation
A key such as LOAD becomes a property named Load, which clashes with the generated static Load() method, and GET_TYPE clashes with the inherited object.GetType(). The generated module then fails to compile, so none of its keys load. These keys now go through the same omitted-keys path as reserved words and are listed in the generated file's header.
There was a problem hiding this comment.
Important
The collision filter misses the enclosing class name, leaving another case that produces uncompilable C#.
Approach: Reusing the omitted-key path is appropriate, but the name check needs to include the effective class name.
Reviewed changes Reviewed the C# collision exclusions, regression test, and release note.
- Member exclusions: Properties matching generated helpers or inherited
System.Objectmembers are omitted and listed in the header. - Regression coverage: The new test checks
LOADandGET_TYPE; all 141 type-generation tests pass, and compiler probes confirm the listed exclusions work. - Release note: Documents omitted keys and the compilation fix.
gpt-6.1-sol | 𝕏
A key such as ENV becomes a property named Env, which is the same name as the default class Env, and APP_ENV does the same for class=AppEnv. C# rejects a member with its enclosing type's name (CS0542). The class name is now resolved before fields are partitioned, so those keys take the omitted-key path too.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the enclosing-class collision fix since the previous review.
- Resolved class names first: Validated the effective class name before filtering and omitted properties matching it.
- Added regression coverage: Covered
ENVwith defaultEnvandAPP_ENVwith customAppEnv, preserving other properties and omitted-key headers.
All 142 type-generation tests passed. Both generated classes compiled and loaded successfully, retaining omitted sensitive keys in SensitiveKeys.
gpt-6.1-sol | 𝕏

Fixes #1313.
Summary
The C# generator now leaves out keys whose PascalCase names clash with members of the generated class. The clashing names are:
Load,SensitiveKeys,DecryptBlobSystem.Object:Equals,GetHashCode,GetType,ToString,MemberwiseClone,FinalizeCS0542). For example,ENVwith the defaultEnv, orAPP_ENVwithclass=AppEnv.These keys go through the same omitted-keys path as reserved words. The generated file's header lists them, and the rest of the class still compiles.
Behavior change
Before this PR, a schema with one of these keys produced a class that didn't compile, so none of its keys could be loaded through the generated module. Now the class compiles without the clashing keys. Those keys are still injected as environment variables.
Evidence
LOADfails withCS0102,GET_TYPEwithCS0108, andENVinclass EnvwithCS0542.Add-Typein each environment below. The class still hasLoad(), and only the non-clashing keys become properties.packages/varlock/src/env-graph/test/type-generationpass (142), includingcsharp.test.tscases for the object and generated members and for the class-name case.Loadpresent, onlyDbHostas a propertyLoadpresent, onlyDbHostas a propertyThe class-name case (
ENVinclass Env, andAPP_ENVinclass AppEnv) was compiled on Linux and on both Windows .NET runtimes.Merge Danger
Door: two-way. The change only affects schemas that contain one of the listed names.
Blast radius: C# users who have a key with one of these names. Their generated class changes from non-compiling to compiling without that key.
Follow-up
The omitted-keys note says "not valid identifiers", which isn't accurate for these keys. Fixing the wording would change the shared note for other emitters, so I've left it for a separate change.