Skip to content

fix(csharp): resolve 1.3.0 upgrade blockers from C# estate triage - #682

Merged
dmealing merged 4 commits into
mainfrom
fm/mo-130-csharp-triage
Dec 1, 2026
Merged

dmealing merged 4 commits into
mainfrom
fm/mo-130-csharp-triage

Conversation

@dmealing

@dmealing dmealing commented Dec 1, 2026

Copy link
Copy Markdown
Member

What Changed

  • C# writer: Piece.Args writes parameter and argument lists with no trailing comma, and CsWriter.Braced("") writes a lone { for an anonymous block. Covered by new cs-list-args-no-trailing-comma and cs-braced-anonymous-block writer-conformance cases, plus updated WriterConformanceTests. Piece.List keeps its trailing comma.
  • C# codegen: DbContextGenerator no longer emits the <Context>IdentityStartMigrations UseIdentityStartMigrations() shim in <Context>DesignTimeServices.g.cs. Matching golden file and IdentityStartDialectTests/EfModelGapsTests updated.
  • TypeScript view codegen (extract-view-spec.ts): an enum literal compared against an @intValueMap or @stringValueMap field is written as the stored value, including through computed operands (coalesce, nullif, greatest, least, case results). Covered by new enum-literal-in-computed-expr.test.ts.
  • CHANGELOG "Upgrading" notes for 1.3.0: C# package layout and package namespaces are opt-in (from 1.2.4 candidates), the four vocabulary packs a hand-composed registry must add, the Postgres view relation qualification change with a SET LOCAL search_path suggestion, the EF Core index-name truncation RenameIndex case, and removal of UseIdentityStartMigrations(). Fixed-section entries added for the three bug fixes. docs/, spec/code-writer.md and the writer-conformance README updated to match.
Validation

Risk Assessment

✅ Low: The changes are narrow (view enum-literal encoding, two C# writer fixes, removal of a no-op shim, upgrade docs), and the four fixes from the last round match the current code with no material defect found; I ran no tests.

Testing

Baseline configured command passed at this commit; no source changed this turn, so not re-run. Ran TS enum-literal focused test (12 pass) and C# codegen tests incl. writer conformance (42 pass). Both unit-level, not live CLI runs, so no scenario marked live. CHANGELOG corrections and DesignTimeServices shim removal not driven.

  • Live validation: ⚠️ inconclusive - 0 of 5 scenarios driven live against the product
Scenario Result Live Evidence
TS int-mapped enum literal emitted as mapped integer (focused emitter test) ⏸️ untested no Prior payload shows only a focused unit test of the emitter (bun test, 12 pass), not a live product run. Live CLI drive needed to mark pass.
C# Braced("") writes lone brace (writer conformance) ⏸️ untested no Prior payload shows only unit-level writer conformance (dotnet test, 42 pass), not a live run. Live drive of the generator needed to mark pass.
C# list parameters emit no trailing comma (writer conformance) ⏸️ untested no Prior payload shows only unit-level writer conformance (dotnet test, 42 pass), not a live run. Live drive of the generator needed to mark pass.
1.3.0 regeneration keeps flat layout unless opted in; upgrade note documents it ⏸️ untested no Needs disposable 1.2.4-rc project regenerated with 1.3.0 CLI; not run this turn.
DesignTimeServices no longer emits identity-start shim ⏸️ untested no Needs dotnet ef scaffold on sample model; not run.
  • Outcome: ⚠️ 1 warning across 1 run (6m22s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ server/typescript/packages/codegen-ts/src/projection/extract-view-spec.ts:933 - The enum literal is encoded only when the other operand is a bare {field}, so item 5's failure is still reachable through a compound operand. Example: {op: eq, left: {fn: coalesce, args: [{field: status}, {field: status}]}, right: {value: &#34;Unknown&#34;}} over an @intValueMap enum. By the code, it loads: coalesce infers enum, eq is legal for enum, and literalComparisonProblem skips a non-field operand. The view then emits COALESCE(...) = &#39;Unknown&#39; against integer columns. A @stringValueMap enum silently compares the member name instead of the stored string. The same gap applies to either comparison side (lines 1011-1012) and to a coalesce used as a simple CASE operand (line 972). It also applies to other operands that return an enum (nullif, greatest, least, or a case whose results are enum fields). The CHECK emitter already handles coalesce: storedFieldOf in migrate-ts/src/check-expression.ts:115. Apply the same stored-field resolution here, covering the other enum-returning nodes too, and add a coalesce case to the new test.
  • ℹ️ server/typescript/packages/codegen-ts/src/projection/extract-view-spec.ts:933 - subAgainst calls fieldOf(other) before checking that x is a string literal, and again for every simple CASE arm. lookup is not side-effect free. For a dotted path ending in a derived origin.first field, each call re-runs inlineEntityDerived, which reserves a new alias through shortAliasFor. So a computed expression comparing such a path, even with no enum involved, can get different subquery alias names than before. That changes the view body and can cause an unneeded view replacement. Return sub(x, temporal) first when x is not { value: &lt;string&gt; }. For comparisons, reuse the already resolved lf/rf; for CASE, resolve the operand field once.
  • ℹ️ CHANGELOG.md:95 - The hand-composed registry upgrade note is inaccurate in two ways. First, it says all four packs were split out of core. At v1.2.0 and v1.2.3 only reporting and requirements vocabulary could have been in a 1.2 provider list. metaobjects-rules and metaobjects-view-expressions are new in 1.3.0 (the view-expressions provider header says so). Second, it says any model using their vocabulary fails with an unknown type or subtype. Attributes such as @union, @unionall, @Grain and @grainOrdinal are not types: an omitted pack gives ERR_UNKNOWN_ATTR only under a strict load, and C# MetaDataLoader defaults to strict=false. Separate the packs moved out of core from the new ones, and limit the load-failure statement to types and subtypes, stating the strict-load condition for attributes.
  • ℹ️ server/typescript/packages/codegen-ts/test/projection/enum-literal-in-computed-expr.test.ts:34 - The test is titled ne, gt and a literal on the left are mapped too, but it never exercises gt; it covers only ne and a left-side literal with eq. Remove gt from the title.
  • ℹ️ server/csharp/MetaObjects.Codegen/Writer/CodeWriter.cs:49 - Fixed the Piece.List XML doc. It gave f(a, b) and &lt;A, B&gt; as examples, but a broken List takes a trailing comma, which is the item 6 mistake. The comment now points to Piece.Args for argument, parameter and type lists. Comment only.

🔧 Fix applied.
1 info still open:

  • ℹ️ server/csharp/MetaObjects.Codegen/Writer/CodeWriter.cs:49 - Fixed the Piece.List XML doc. It gave f(a, b) and &lt;A, B&gt; as examples, but a broken List takes a trailing comma, which is the item 6 mistake. The comment now points to Piece.Args for argument, parameter and type lists. Comment only.
⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (0 of 5 scenarios were driven live against the product); untested: TS int-mapped enum literal emitted as mapped integer (focused emitter test), C# Braced("") writes lone brace (writer conformance), C# list parameters emit no trailing comma (writer conformance), 1.3.0 regeneration keeps flat layout unless opted in; upgrade note documents it, DesignTimeServices no longer emits identity-start shim
  • Live validation: ⚠️ inconclusive - 0 of 5 scenarios driven live against the product
Scenario Result Live Evidence
TS int-mapped enum literal emitted as mapped integer (focused emitter test) ⏸️ untested no Prior payload shows only a focused unit test of the emitter (bun test, 12 pass), not a live product run. Live CLI drive needed to mark pass.
C# Braced("") writes lone brace (writer conformance) ⏸️ untested no Prior payload shows only unit-level writer conformance (dotnet test, 42 pass), not a live run. Live drive of the generator needed to mark pass.
C# list parameters emit no trailing comma (writer conformance) ⏸️ untested no Prior payload shows only unit-level writer conformance (dotnet test, 42 pass), not a live run. Live drive of the generator needed to mark pass.
1.3.0 regeneration keeps flat layout unless opted in; upgrade note documents it ⏸️ untested no Needs disposable 1.2.4-rc project regenerated with 1.3.0 CLI; not run this turn.
DesignTimeServices no longer emits identity-start shim ⏸️ untested no Needs dotnet ef scaffold on sample model; not run.
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun test packages/codegen-ts/test/projection/enum-literal-in-computed-expr.test.ts in server/typescript (12 pass)
  • dotnet test --filter FullyQualifiedName~WriterConformance in server/csharp (MetaObjects.Codegen.Tests: 42 pass)
⚠️ **Document** - 1 info
  • ℹ️ spec/decisions/ADR-0063-generators-own-layout.md:172 - ADR-0063 (spec/decisions/ADR-0063-generators-own-layout.md, lines ~172 and ~186) still states C# lays out 'a trailing comma in broken lists' without the new parameter/argument-list exception. ADRs are decision records; the current contract is in spec/code-writer.md (Piece.Args). Left unchanged. Decide whether to add an ADR amendment.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

- C# writer: Piece.Args, a parameter or argument list that breaks with no
  trailing comma (C# refuses one there); Braced("") writes a lone { for an
  anonymous block instead of a blank line. Two csharp writer-conformance cases.
- TypeScript view lowering: an enum literal compared with an @intValueMap or
  @stringValueMap enum in an origin.computed expression is written as the
  stored value, not the member name.
- C#: stop generating the UseIdentityStartMigrations [Obsolete] no-op shim
  kept through the 1.2.4 candidates.
- CHANGELOG upgrade list: the C# layout and package-namespace opt-in for
  projects coming from a 1.2.4 candidate, the four vocabulary packs a
  hand-composed registry must add, Postgres view schema qualification and
  search_path, EF index names over 63 bytes, the removed shim. Agent schema
  page docs state which tables it lists.
@dmealing
dmealing merged commit 0ac97a1 into main Dec 1, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-130-csharp-triage branch December 1, 2026 00:31
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.

1 participant