Skip to content

Commit 9918874

Browse files
dmealingclaude
andcommitted
fix(codegen-csharp): FR-021 TryResolve — apply PackageNamespaces to @provided enums
TryResolve carried a `!useProvidedEnumPrepend` guard that skipped the package-level override (PackageNamespaces) for @provided enums, leaving the helper inconsistent with ResolveImpl (whose step 2 is unguarded) and with SharedEnumTypeReference's own documented order (TypeOverrides → PackageNamespaces → Convention → ProvidedEnumNamespace). A provided enum has its own declaring package, distinct from any entity package, so an explicit PackageNamespaces entry for it is a deliberate binding that must win (the FR-019 "namespace maps to the declaring package" contract). Parallel-tree routing stays expressed via Convention.ProvidedEnumPrepend, not by suppressing the explicit override. Greens the 3 reds in the FR-021 WIP (its own TryResolve-returns-null test, which asserts "package-level override always wins even for provided enums", plus the two FR-019 package-binding tests). No test changes — the tests were correct. Codegen 205/0, Conformance 592/0, solution builds clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5ecf80f commit 9918874

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

server/csharp/MetaObjects.Codegen/PackageBindingResolver.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ public static string ResolveForProvidedEnum(
119119
if (config.TypeOverrides.TryGetValue(fqn, out var typeTarget) && !string.IsNullOrEmpty(typeTarget))
120120
return typeTarget;
121121
}
122-
// 2. Package-level override — applies ONLY to the default resolution path.
123-
// @provided enums often live in a parallel namespace tree from entities; a
124-
// PackageNamespaces override (which targets entity placement) must not bleed
125-
// into the @provided enum case.
126-
if (!useProvidedEnumPrepend &&
127-
!string.IsNullOrEmpty(package) &&
122+
// 2. Package-level override — keyed by the metadata package, so it applies to BOTH
123+
// paths: a provided enum has its OWN declaring package (distinct from any entity
124+
// package), and an explicit PackageNamespaces entry for that package is a
125+
// deliberate binding that must win (matching ResolveImpl's unguarded step 2 and
126+
// the FR-019 "namespace maps to the declaring package" contract). Parallel-tree
127+
// routing for provided enums is expressed via Convention.ProvidedEnumPrepend
128+
// (step 3), not by suppressing this explicit override.
129+
if (!string.IsNullOrEmpty(package) &&
128130
config.PackageNamespaces.TryGetValue(package, out var pkgTarget) &&
129131
!string.IsNullOrEmpty(pkgTarget))
130132
{

0 commit comments

Comments
 (0)