diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d13c205..4e8d425 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -91,10 +91,12 @@ jobs: # The API pages are read from published assemblies, which carry the XML docs and every dependency DocFX needs # to resolve a signature. The packages are the ones site/docfx.json names, so the two cannot disagree. + # A package with a net11.0 asset beside net10.0 is published for net10.0: a publish names one target + # (NETSDK1129), and net10.0 is the surface every target has (decision 120, rule 2). - name: Publish the run-time packages run: | for assembly in $(jq -r '.metadata[].src[].files[]' site/docfx.json); do - dotnet publish "src/${assembly%.dll}" -c Release -o site/obj/pub + dotnet publish "src/${assembly%.dll}" -c Release -f net10.0 -o site/obj/pub done - name: Build the site, warnings as errors diff --git a/AGENTS.md b/AGENTS.md index 873acf1..c93b30d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,8 +19,9 @@ decision with its evidence, and a design note per area. This file is the canonical agent guide. There is no CLAUDE.md, on purpose. ## Stack -.NET 10 · C# 14 · Metalama 2026.1 (compile-time generation; no 2027.0-only API such as -`[Durable]`) · Roslyn analyzers (netstandard2.0) · EF Core 10 · Microsoft.AspNetCore.OpenApi 10 +.NET 10 and 11 (SDK 11) · C# 14 · Metalama 2027.0, a preview until it is stable (compile-time generation; +[decision 130](design/adr/0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md)) · Roslyn +analyzers (netstandard2.0) · EF Core 10 and 11 · Microsoft.AspNetCore.OpenApi 10 and 11 ## Packages | Package | Role | @@ -85,7 +86,7 @@ session's own checkout ([decision 105](design/adr/0105-every-tool-is-built-in-th A tool built from other sources refuses to run and names the command that rebuilds it, `dotnet build tools/ -c Release`. -The SDK is pinned in `global.json` (10.0.4xx band, `latestPatch`). Tests run on Microsoft Testing +The SDK is pinned in `global.json` (11.0.1xx band, `latestPatch`). Tests run on Microsoft Testing Platform (xunit.v3 4.x), so `dotnet test` takes `--solution`/`--project`, and TRX output is `--report-xunit-trx`. The build treats warnings as errors, including CS1591 on shipping projects, and runs the CMTK analyzers on the shipping projects' own code (`src/Directory.Build.targets`), so a library diff --git a/CHANGELOG.md b/CHANGELOG.md index 583c1e8..eb97109 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ A version's heading reads `## — Unreleased` until the release is pre the release date. The release workflow refuses a tag whose section still says `Unreleased`, and the section is the GitHub release's notes. -## 2.4.0 — Unreleased +## 2.4.0-preview.1 — Unreleased ### Added @@ -20,6 +20,9 @@ section is the GitHub release's notes. ### Changed +- Generators: the package requires Metalama 2027.0, a preview until Metalama releases it (`2027.0.9-preview`), where 2.3.x requires 2026.1.30. So 2.4.0 is a preview until then, and isn't for production. A project that references `Metalama.Framework` 2026.1 itself fails to restore with NU1605: raise that reference, or stay on 2.3.x. +- EF Core: the package has a `net11.0` asset that requires `Microsoft.EntityFrameworkCore.Relational` 11.0.0, where `net10.0` still requires 10.0.12. A `net11.0` project that references EF Core 10 itself fails to restore with NU1605: raise that reference, or stay on 2.3.x with EF Core 10. On EF Core 11, SQL Server's HiLo isn't chosen for a key over `ulong` until you clear the generator factory on it ([Keys](https://github.com/CaffeinatedCoder/CodoMetis.TypeKit/blob/main/src/CodoMetis.TypeKit.EntityFrameworkCore/README.md#keys)). +- ASP.NET Core: the package has a `net11.0` asset that requires `Microsoft.AspNetCore.OpenApi` 11.0.0, where `net10.0` still requires 10.0.12. A `net11.0` project that references the 10 line itself fails to restore with NU1605: raise that reference, or stay on 2.3.x with the 10 line. - Packages: the public surface is checked against 2.3.1's, so nothing 2.3.1 ships is removed or changed in 2.4.0. - Analyzers: CMTK0005 now also warns at `CollectionsMarshal.SetCount(ids, count)` on a `List`, which makes room for `count` items without putting one there, as `new OrderId[count]` does; a constant count of zero isn't reported. In a build that treats warnings as errors, that can report code that built before ([CMTK0005](https://github.com/CaffeinatedCoder/CodoMetis.TypeKit/blob/main/src/CodoMetis.TypeKit.Analyzers/README.md#cmtk0005)). @@ -27,6 +30,8 @@ section is the GitHub release's notes. ### Fixed +- EF Core: on EF Core 11 the package threw `MissingMethodException` for the first value object EF mapped, because EF Core 11 removed a constructor it called. The `net11.0` asset is built against EF Core 11, and there a default key over `ulong` gets its temporary value in a `--nativeaot` compiled model and with `ValueObjectConverter` named by hand too ([#285](https://github.com/CaffeinatedCoder/CodoMetis.TypeKit/issues/285)). +- ASP.NET Core: with `Microsoft.AspNetCore.OpenApi` 11 the OpenAPI document answered 500, a `MissingMethodException` from the fault responses, because `Microsoft.OpenApi` 3 changed the type of a response's content. The `net11.0` asset is built against it ([#286](https://github.com/CaffeinatedCoder/CodoMetis.TypeKit/issues/286)). - Generators: an overload that differs from a generated member only by a nullable value type, such as a base record's `TryFrom(int?)` over an `int` or a closed set's `Parse(string, bool?)`, a base record's method named as a generated property, such as `MinValue()`, and an overload of a private entry point are kept beside the generated member, where the build failed with CMTK1011 ([Write your own members](https://github.com/CaffeinatedCoder/CodoMetis.TypeKit/blob/main/src/CodoMetis.TypeKit.Generators/README.md#write-your-own-members)). - EF Core: a query that uses an arithmetic or bitwise operator a value object declares by hand, `&&` and `||` included, throws, naming the value object, where the database ran its own arithmetic and skipped the operator; a query filter fails when the model is built ([Queries](https://github.com/CaffeinatedCoder/CodoMetis.TypeKit/blob/main/src/CodoMetis.TypeKit.EntityFrameworkCore/README.md#queries)). diff --git a/Directory.Build.props b/Directory.Build.props index 69c73cc..6c39a48 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 2.4.0 + 2.4.0-preview.1 CaffeinatedCoder Copyright (c) 2026 CaffeinatedCoder MIT diff --git a/Directory.Packages.props b/Directory.Packages.props index 699da86..48031b7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,8 +7,8 @@ one is a release decision, not a dependency update. --> - - + + + + + + + + + + + + + + + + + diff --git a/design/adr/0129-metalama-2027-0-moves-into-2-4-0.md b/design/adr/0129-metalama-2027-0-moves-into-2-4-0.md new file mode 100644 index 0000000..426bbe1 --- /dev/null +++ b/design/adr/0129-metalama-2027-0-moves-into-2-4-0.md @@ -0,0 +1,77 @@ +# 0129. Metalama 2027.0 moves into 2.4.0, so a consumer with only the .NET 11 SDK builds + +Date: 2026-10-31 +Status: accepted + +Context: 2026-10-31, issue #280; replaces the timing in +[decision 120](0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md)'s Metalama paragraph ("2.3 and 2.4 +stay on 2026.1, and 2.5.0 moves both targets to 2027.0"). Decision 120 named the cost of holding 2026.1 on SDK 11 as +LAMA0617, "a warning, falling back to the SDK 10 Razor compiler". The RC3 spike (`spikes/Sdk11Rc3Metalama`, +[KB-060](../knowledge/KB-060-metalama-2026-1-on-the-net-11-sdk.md)) found that the fallback exists only when an SDK 10 +is installed beside SDK 11: without one, a web project with the Generators package fails with LAMA0625 (#275). The +maintainer decided, in these words: "I want a 2.4.0 that compiles at every .NET11-consumer, even when he has only +.NET 11 SDK installed. If this doesn't work with Metalama 2026, then we need to take a straight decision", and +accepted the proposal below the same day. + +## Decision + +**The Generators package moves to Metalama 2027.0 in 2.4.0, for the `net10.0` and `net11.0` assets alike.** Every +other rule of decision 120 stands: one Metalama version for every target, the floor raise documented under its +first rule, and the five conditions of its Metalama paragraph, which are now 2.4.0's. Where decision 120 says 2.5.0 +of the move, read 2.4.0, and where it says the 2.4.x line, read 2.3.x. + +**2.4.0 is tagged only on a stable Metalama 2027.0.** A stable package does not depend on a prerelease (NU5104, +an error under this repository's warnings as errors), so 2.4.0's date is Metalama's: 2027.0 is planned for +2027-01-01 in Metalama's internal documents (#173), with no public date on 2026-10-31. A fix a consumer needs before +then ships as a 2.3.x patch. + +**One condition is added: a build with only SDK 11 installed.** CI and the consumer smoke test get a lane whose +.NET installation holds SDK 11 and nothing else, with a web consumer (`Microsoft.NET.Sdk.Web`) on the packages, +because that is the case Metalama 2026.1 fails and the one a machine with SDK 10 beside it never shows. It runs on +the general availability SDK before the tag (#281). + +**2.3.x is the line below the ceiling.** A project that needs Metalama 2026 stays on 2.3.x. On a machine with only +SDK 11, its web projects need SDK 10 installed beside SDK 11, or a direct `Metalama.Framework` 2027 reference beside +the 2.3.x packages, which weaves (KB-060, decision 120); #275 says so, and 2.4.0's changelog names both. + +Refused: + +- **Staying on 2026.1 in 2.4.0 and documenting SDK 10 beside SDK 11.** It fails the requirement, on `net10.0` as on + `net11.0`: the Razor compiler is the SDK's, whatever the target (KB-060). +- **A 2.4.0 without `net11.0`, on 2026.1.** The same: a `net10.0` web project fails on SDK 11 alone. +- **A 2.4.0 on 2027.0-preview.** A stable package on a prerelease dependency (above). +- **Waiting for a 2026.1 patch that supports SDK 11's Roslyn.** Not in this repository's hands, and 2026.1.31 + (compiler 2026.1.21) still fails. + +## Evidence + +[KB-060](../knowledge/KB-060-metalama-2026-1-on-the-net-11-sdk.md), measured 2026-10-31 on macOS arm64 with the +published 2.3.1 packages: + +| Web project | Metalama 2026.1 | Metalama 2027.0.5-preview | +|---|---|---| +| SDK 11 RC3 alone, `net11.0` | LAMA0625 (2026.1.31 too) | builds | +| SDK 11 RC3 alone, `net10.0` | LAMA0625 | builds | +| SDK 11 RC1 alone | LAMA0625 | builds | +| SDK 11 RC3 with SDK 10.0.403 beside it | builds, LAMA0617 twice | builds | +| SDK 10.0.403, `net10.0` | builds | builds | + +A console project builds on 2026.1 in every case, so the failure is the web SDK's Razor compiler, which needs Roslyn +5.11 (RC1) or 5.12 (RC3) where Metalama 2026.1 bundles 5.9. With 2027, one project on `net10.0;net11.0` and no +`LangVersion` compiles `net10.0` at C# 14.0 and `net11.0` at 15.0, the value object is generated on both, and a union +under `#if NET11_0_OR_GREATER` or in a file removed from `net10.0` builds on both targets. This machine has a Metalama +license entry for 2027.0, so these runs say nothing about a build without one; decision 120's clean-container run of +2027.0.4-preview did, and the CI condition stays. + +## Consequences + +- The roadmap's Metalama item moves to 2.4.0. #173 (the move), #272 (a union over value objects in a woven project) + and #223 (what the generators do with a union or a `closed` class) move from the 2.5.0 epic to the 2.4.0 epic: + the release that makes a woven project compile those shapes defines what they do, since a value object over a union + that compiles with no defined answer is the silent failure this repository refuses. 2.5.0 keeps what 2027.0 offers + beyond that: AspectTesting on xunit.v3 (#220), the aspect-author analyzers (#221), type facets (#222) and the + platform requirement (#224). +- Decision 120's rule 2 sentence "until 2.5.0 a union member reaches the consumers without the Generators package" + ends at 2.4.0: from 2.4.0 a woven `net11.0` project compiles at C# 15, so #209 and #210 reach every consumer. +- #275 closes when 2.4.0 ships on 2027.0; #281 is the lane. +- Decision 120's status and index row name this record. diff --git a/design/adr/0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md b/design/adr/0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md new file mode 100644 index 0000000..a38faaa --- /dev/null +++ b/design/adr/0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md @@ -0,0 +1,62 @@ +# 0130. 2.4.0 is published as `2.4.0-preview.N` on the current Metalama 2027 preview, until Metalama 2027.0 is stable + +Date: 2026-11-28 +Status: accepted + +Context: 2026-11-28, issue #284; amends [decision 129](0129-metalama-2027-0-moves-into-2-4-0.md), which tags 2.4.0 +only on a stable Metalama 2027.0 and refused "a 2.4.0 on 2027.0-preview" because a stable package does not depend +on a prerelease. .NET 11 has been generally available since 2026-11-10 and Metalama 2027.0 is still a preview +(`2027.0.9-preview` on 2026-11-28, the stable planned for 2027-01-01). Until it ships, nothing on `release/2.4.0` +reaches a consumer, and two shipped packages fail on the 11 line (#285, #286). The maintainer decided on +2026-11-11 that 2.4.0 is published as previews meanwhile (#284), and on 2026-11-28, in these words: "Base all 2.4.0 +versions and their previews on current Metalama 2027, keep 2.4.0 preview until Metalama releases GA". + +## Decision + +**Every 2.4.0 version is built on the current Metalama 2027 preview, and is itself a preview until Metalama 2027.0 +is stable.** `Directory.Packages.props` names the newest `2027.0.N-preview` the suite and the smoke test ran on, and +`Version` is `2.4.0-preview.N`. A prerelease package may depend on a prerelease: NU5104 is about stable packages +only, and it is what fails the pack if `Version` is set to `2.4.0` too early (measured below). + +**Decision 129's rule for the stable tag is unchanged.** `v2.4.0` is tagged only on a stable Metalama 2027.0, and +its five conditions hold for that tag. + +**A new Metalama preview is taken by a change of its own.** It moves the pin, runs the suite and the smoke test on +it, and names what the new compiler asked for. A TypeKit preview is published on a Metalama preview only after +that. + +**One changelog section per published version.** `CHANGELOG.md` has a `## 2.4.0-preview.N` section for each +preview, which is its release notes as for any version. The `## 2.4.0` section, written when the stable is +prepared, holds everything since 2.3.1, so a consumer of stable versions reads one section. + +**What a preview promises is written where it is installed from.** The Generators README and each preview's +release notes say that it depends on a Metalama preview and is not for production, and that 2.3.x is the stable +line until `v2.4.0`. + +**Conditions before `2.4.0-preview.1` is published** (issue #284, unchanged): a build with no Metalama licence +passes in CI on the Metalama preview; the lane with only SDK 11 installed builds a web consumer (#281); each +target is run, not assumed (#208); the release workflow has a prerelease path that publishes what CI packed +(#247). If a Metalama preview needs a licence or stops working at a date, the record of that preview says so and +the README names it, or no preview is published. + +## Evidence + +Measured 2026-11-28 on macOS arm64, SDK 10.0.404, `release/2.4.0` at 020e48c: + +- With `Metalama.Framework` 2027.0.9-preview (compiler 2027.0.6-preview) the solution builds after one kind of + change: LAMA0891, a static member of a compile-time type that is not immutable, on two lookup tables of the + aspects, which became `ImmutableArray`. The `[Durable]` attribute #173 expected on the value placeholder is not + asked for: the build passes under warnings as errors without it. +- The suite: 36119 passed of 37480, 1252 skipped. All 109 failures were the pack of the Generators package under + `Version` 2.4.0: "NU5104: A stable release of a package should not have a prerelease dependency". +- With `Version` 2.4.0-preview.1 and the changelog section renamed to it, the conventions pass (2089), the pack + and package validation against 2.3.1 included. + +Not measured here: a build with no Metalama licence (this machine holds one; CI has none), the IDEs, and the +consumer matrix of decision 120. + +## Consequences + +- #173 is done on the preview and stays open for the stable: its conditions are the tag's. +- The first publish is `2.4.0-preview.1`, which is also the first with two targets (#208). +- [The roadmap](../roadmap.md)'s Metalama item names this record beside decision 129. diff --git a/design/adr/0131-the-sdk-pin-moves-to-11-0-1xx.md b/design/adr/0131-the-sdk-pin-moves-to-11-0-1xx.md new file mode 100644 index 0000000..41ec58b --- /dev/null +++ b/design/adr/0131-the-sdk-pin-moves-to-11-0-1xx.md @@ -0,0 +1,50 @@ +# 0131. `global.json` pins the .NET 11 SDK, band 11.0.1xx + +Date: 2026-11-28 +Status: accepted + +Context: 2026-11-28, issues #170 and #208. [Decision 120](0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md) +says the SDK comes first: a `net11.0` target needs SDK 11, which changes the compiler under the `net10.0` assets +too, so "the pin moves by a record of its own, after the SDK is generally available". SDK 11.0.100 has been +generally available since 2026-11-10. `global.json` pinned 10.0.402 with `latestPatch`, because a different Roslyn +band can change what Metalama and the analyzers emit. + +## Decision + +**`global.json` pins SDK 11.0.100 with `rollForward: latestPatch` and no prereleases**, as it pinned 10.0.402: +patches inside the 11.0.1xx band are taken, another band is not. + +**It moves after the Generators package is on Metalama 2027**, never before. On Metalama 2026.1.30 the repository +does not build on SDK 11.0.100 (below). In a project woven by Metalama the SDK does not choose the compiler, +Metalama's does, so the pin is this repository's own build and the packages Metalama does not touch. + +**Every fact pinned to the SDK band is run again on the new band.** `docs-query check` reports each +`sdk 10.0.4xx` pin as `fact-behind`. A fact with a test in `test/CodoMetis.TypeKit.Facts` is verified by that test +passing on the new band, and its pin and date then move. The facts measure the `net10.0` run, as before; a +`net11.0` run of the facts project is #208's. + +## Evidence + +Measured 2026-11-28 on macOS arm64, with SDK 10.0.404 and 9.0.321 in the same installation: + +| `release/2.4.0` at 020e48c | SDK 10.0.404 | SDK 11.0.100 | +|---|---|---| +| Metalama 2026.1.30 | builds (CI, 2026-10-31) | fails: CS8034 in `CodoMetis.TypeKit.Generators`, Metalama's compiler 2026.1.20 cannot load the `Microsoft.CodeAnalysis.NetAnalyzers` 10.0.401 it substitutes for the SDK's ("incorrect format", "The data is invalid"), an error under warnings as errors | +| Metalama 2027.0.9-preview | builds; 36119 passed, 109 failed on NU5104 alone ([decision 130](0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md)) | builds from scratch with no warning; 36227 passed of 37480, 1252 skipped, 1 failed: `docs-query check`, on the 19 facts pinned to `sdk 10.0.4xx` | + +The CS8034 is not in every woven project: a single console project with the 2.3.1 packages on Metalama 2026.1.30 +builds on SDK 11.0.100 without it, while the repository's Generators project and a two-project consumer show it. +What decides it was not found, and with Metalama 2027 it does not occur. + +The 19 facts' tests are in the 36227: they passed on SDK 11.0.100, so their pins move to `sdk 11.0.1xx` with this +date. + +Not measured: Linux and Windows on SDK 11 (CI does, on the pull request), the packed `net10.0` assets compared +byte for byte with those of SDK 10 (#170), and an installation with SDK 11 alone (#281). + +## Consequences + +- CI takes the SDK from `global.json`, so every job that reads it moves with this change. The release workflow's + publish job installs `10.0.x` only to push packages, and is left as it is. +- A contributor needs SDK 11.0.1xx. `CONTRIBUTING.md` already says "the SDK that `global.json` names". +- #170's first measurement is this record; its other rows stay open. diff --git a/design/adr/0132-on-ef-core-11-a-ulong-or-char-key-s-temporary-value-is-a-factory-on-the-property.md b/design/adr/0132-on-ef-core-11-a-ulong-or-char-key-s-temporary-value-is-a-factory-on-the-property.md new file mode 100644 index 0000000..8843034 --- /dev/null +++ b/design/adr/0132-on-ef-core-11-a-ulong-or-char-key-s-temporary-value-is-a-factory-on-the-property.md @@ -0,0 +1,83 @@ +# 0132. On EF Core 11, the temporary value of a key over `ulong` or `char` is a generator factory on the property + +Date: 2026-11-28 +Status: accepted + +Context: 2026-11-28, issue #285; [EF Core](../ef-core.md). On EF Core 11, +[decision 114](0114-a-value-object-s-temporary-number-is-its-wrapped-type-s.md)'s route is gone. Decision 114 carried a value +generator factory in the `ConverterMappingHints` of the converter `UseTypeKit()` composes, which `CoreTypeMapping` +took into the value object's mapping, and noted that the property was `[Obsolete]` in EF Core 10: "A later EF that +removes it fails the tests that hold this, not silently." EF Core 11.0.0 removed the constructor parameter, the +`ValueGeneratorFactory` of the hints and of `CoreTypeMapping`, and the selector's read of it +(`ValueGeneratorSelector.Find`, compared at `v10.0.12` and `v11.0.0`). The published 2.3.1 package, compiled +against EF Core 10, throws `MissingMethodException` on EF Core 11 for the first value object mapped (#285). + +Without a replacement, EF Core 11 chooses a generated value object's temporary number by the converter's provider +type (`ValueGeneratorSelector.TryCreate`, then `TemporaryNumberValueGeneratorFactory.Create`). That is right +wherever the column is of the wrapped type, and wrong in the two cases decision 114 names: a key over `ulong` +where the column is a `decimal` gets a negative temporary `decimal`, which throws `OverflowException` converted +back, and a key over `char` configured on add gets a character of a GUID string on SQL Server. + +## Decision + +**On the `net11.0` asset, a value object over `ulong` or `char` that EF generates on add gets +`WrappedTypeValueGeneratorFactory` on the property**, set by `ValueObjectValueGeneratorConvention` at the +convention's level, as a value object over a `Guid` or a `string` already does. The generator +asks the provider, at the first value, for the generator of a key of the wrapped type in a model of its own, and +converts its values. So the temporary values are the plain key's, by construction. + +- A number keeps the factory beside a default or computed SQL value, where a `Guid` or a `string` is left to EF: + a plain `ulong` key gets a temporary number there too, and a TPC key's sequence is such a default. +- The other numbers get no factory. EF's choice by the provider type is the plain key's wherever the column is + of the wrapped type, and a factory on the property would come before HiLo for every one of them. +- **The `net10.0` asset is unchanged**: the hints, as decision 114 has them. The two assets differ in the three + ways below, because EF differs, which decision 120's second rule ("a shared member behaves the same on both") + does not reach: no member of this package changes. + +**What differs on EF Core 11, measured:** + +1. **SQL Server's HiLo is not chosen for a key over `ulong`**, where EF Core 10 chooses it. SQL Server's selector + takes a factory on the property before HiLo (`SqlServerValueGeneratorSelector.TrySelect`), and EF Core 11 + leaves no place after it. The key gets a temporary value, and `SaveChanges` then fails on the column, which + has no identity: loud, at the first insert. The way out is one line, which a test holds: + `Property(e => e.Id).Metadata.SetValueGeneratorFactory((Type?)null)`, after which HiLo is chosen. A key over + `ulong` with HiLo is refused by PostgreSQL's provider, plain or value object, so SQL Server is the one case. +2. **A `--nativeaot` compiled model gives a default `ulong` key its temporary value**, where it throws + `OverflowException` on EF Core 10: a compiled model names a factory type, and could not write the delegate in + the hints. +3. **So does a key whose converter the application names by hand** + (`HasConversion>()`), for the same reason: the factory is the + property's, whatever converter its mapping is built on. + +Refused: + +- **No replacement, and the `ulong` case documented as throwing.** It is decision 63's state, which decision 114 + left: a default key that throws at `Add` on two providers, against one configuration, HiLo on SQL Server over + `ulong`, that fails at `SaveChanges` and has a one-line way out. +- **Reading the provider's HiLo annotation to leave such a key alone.** It names a provider's annotation, and + discovery here is never by name. +- **Replacing or decorating `IValueGeneratorSelector`.** `UseTypeKit()` replaces nothing, and two packages that + replace one EF service cannot be installed together. +- **Seeding EF's value generator cache.** It would come after HiLo, as the hints did, and rests on the cache's key + and lifetime, which are EF's own. + +## Evidence + +EF Core 11.0.0, Npgsql 11.0.0 and SQL Server's provider 11.0.0, `net11.0`, macOS arm64, 2026-11-28. No database is +opened for the generator tests, as in decision 114. + +- With the hints compiled out and nothing in their place, 18 tests fail on `net11.0`: `KeyGenerationTests` (4, + `OverflowException` at `Add` on SQL Server and PostgreSQL, compiled model included), `KeyGenerationVariantTests` + (3: `ulong` on both providers, `char` on SQL Server), `SqlServerKeyVariantTests` (11 key shapes over `ulong`). +- With the factory, all of them pass, and three tests changed their answer, which are the three differences above. + With the factory withheld beside a default SQL value, the two TPC shapes of `SqlServerKeyVariantTests` still + throw. +- `KeyGenerationTests` holds each difference per target: HiLo pinned as not chosen on `net11.0` and chosen once + the factory is cleared, the Native AOT compiled model and the converter named by hand as temporary values on + `net11.0` and as throwing on `net10.0`. The key-generation classes pass on both targets (1226). + +## Consequences + +- [The EF Core note](../ef-core.md) and the package README say what differs on EF Core 11, and the changelog's + "Changed" names the HiLo case with its way out. +- Decision 114 stands for the `net10.0` asset. When `net10.0` is dropped (3.0.0), this is the only route. diff --git a/design/adr/README.md b/design/adr/README.md index 713fed2..ec89654 100644 --- a/design/adr/README.md +++ b/design/adr/README.md @@ -120,13 +120,13 @@ per area ([design](../plan.md)) link to the records they rest on. | [0111](0111-a-mapping-can-withhold-the-fault-name.md) | A mapping withholds a member's name with `FaultResponse.WithoutFaultName()`: its problem has no `fault`, no `rule` and no member description as its detail; `IFaultFeature.NameWithheld` tells the host; a response whose every fault withholds its name is described as naming none; the same-name warning counts only members that write their name | 2026-10-28 | accepted | | [0112](0112-the-prober-gives-way-to-valueranges-oracle-kit.md) | The prober, its corpus, its seeds, the CI replay and the release gate are retired for CodoMetis.ValueRanges' oracle kit under `test/oracles/`: claims quoted verbatim and held by named tests, every public member claimed or waived, oracles as ordinary test classes each with a seed CI checks applies, candidates, and a hand-written axes file; `tools/Oracles seeds` builds one project and runs one class per seed | 2026-10-28 | accepted | | [0113](0113-ci-runs-the-lanes-a-change-can-affect.md) | CI runs the lanes a change can affect: each changed path selects Linux, Windows and the pack by its class in `tools/CiLanes` (Windows for the analyzers, the generators, tests and tools; the pack for the packages), a path no class names selects all three, a prose-only change runs only the test projects that read prose (`test/Prose.slnf`), and only a pull request into `main`, a push to `main`, the nightly and the release run macOS; a gate job, `CI`, over every job is the required check; a convention test refuses non-portable file names; `release.yml` calls the build workflow before it verifies | 2026-10-29 | accepted; amended by [0127](0127-a-change-to-tools-or-tests-runs-the-test-projects-it-reaches.md) | -| [0114](0114-a-value-object-s-temporary-number-is-its-wrapped-type-s.md) | A value object over a number gets the temporary values a property of its wrapped type gets, from a factory in its converter's mapping hints, which EF consults after a generator on the property and after HiLo: a default `ulong` key no longer throws at `Add`, and a `char` key configured on add gets a temporary `char` on SQL Server; under `--nativeaot` the factory is lost and a default `ulong` key still throws | 2026-10-29 | accepted | +| [0114](0114-a-value-object-s-temporary-number-is-its-wrapped-type-s.md) | A value object over a number gets the temporary values a property of its wrapped type gets, from a factory in its converter's mapping hints, which EF consults after a generator on the property and after HiLo: a default `ulong` key no longer throws at `Add`, and a `char` key configured on add gets a temporary `char` on SQL Server; under `--nativeaot` the factory is lost and a default `ulong` key still throws | 2026-10-29 | accepted; refined by [0132](0132-on-ef-core-11-a-ulong-or-char-key-s-temporary-value-is-a-factory-on-the-property.md) | | [0115](0115-value-objects-can-be-inlined-everywhere.md) | `AddTypeKit(typeKit => typeKit.InlineValueObjects = true)` writes every value object in place, by its wrapped type's schema, in every position and version, with no component of its own; off by default, the document unchanged; closed sets and wrapped enums keep their components; an inlined value object claims no name (decision 55) and shares no schema between its JSON positions and its parameters (decision 106) | 2026-10-29 | accepted | | [0116](0116-the-docs-site-is-docfx-built-from-main.md) | The docs site is DocFX, published to GitHub Pages from `main` alone: the guides, the READMEs, the changelog and the API pages of the run-time packages, from the files as they are; a link to a file that is not a page becomes a GitHub address at the built commit; a pull request touching a page builds it with warnings as errors; `site/**` is prose; DocFX 2.81.0 lists the members of C# 14 extension blocks as extension methods | 2026-10-29 | accepted | | [0117](0117-a-seed-is-caught-against-a-passing-baseline.md) | `oracles seeds` credits a seed only when its oracle passes without it, in a baseline run with the same build and filter, and fails with it in a test of its own; a run that never reached the tests (a fixture xunit could not set up, an error counted outside any test, a crashed host, no TRX, every test skipped) or a failing baseline is `ERROR`, exit 4, never `CAUGHT` | 2026-10-29 | accepted | | [0118](0118-an-error-may-learn-a-form-only-new-api-can-write.md) | An Error may report, in a minor version, a form that only an API new in that version can write, since no build that worked before contains it: CMTK0003's dropped assertion of `CodoMetis.TypeKit.Testing` on a `Task` or `ValueTask` in 2.3.0, its `ConfigureAwait`, `WaitAsync` and branch forms (#152) included, known by the package's assembly; the forms freeze at the tag; refines decision 34; one exception the maintainer took into 2.3.0, a dropped `Task.WhenAny` of tasks of results (#159) | 2026-10-29 | accepted; widened by [0119](0119-a-gap-found-before-the-tag-ships-in-that-release.md) | | [0119](0119-a-gap-found-before-the-tag-ships-in-that-release.md) | A form an Error misses, found before its version is tagged, is reported in that version when it loses what the rule protects in every build, though code built on the previous minor can contain it: 2.3.0's CMTK0003 on a `Task.WhenAny` of results (#159), `Wait()` on a branch (#160), an array in `Task.WaitAll`/`WaitAny` (#161), a dropped `Task.WhenEach` (#162), and a `WhenAny` of held tasks silent; the rule stops at the tag, after which decision 34 holds; refines 34 and 118 | 2026-10-29 | accepted | -| [0120](0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md) | A `net11.0` target joins a 2.x minor when a feature needs it, and a dependency floor may rise in a minor, on every target or on `net11.0` alone, if it is documented (the Semantic Versioning FAQ calls a dependency update with an unchanged public API compatible; a project that references the dependency lower gets NU1605, measured on SDK 11 RC1, so the changelog names the floor, who it reaches and both ways out, and the smoke test shows it); a union new on `net11.0` is an addition and may join a 2.x minor (a `LangVersion` 14 consumer who matches on it gets CS9327, and on Metalama 2026.1 CS8652, measured); Metalama is one version for every target and TypeKit follows the maintained Metalama year in a minor: 2.3 and 2.4 stay on 2026.1 and 2.5.0 moves both targets to 2027.0 once stable (a direct 2026.1 reference gets NU1605 and stays on 2.4.x; a woven `net11.0` project goes from C# 14 to 15; conditions: a license-free CI and clean-container build, the ceiling and the 2.4.x line documented); the SDK 11 spike comes first (#170); 3.0.0 stays the `net10.0` drop and a change of an existing contract, timed to .NET 12 LTS, and .NET 11 is no reason for a major; refines decision 44 | 2026-10-29 | accepted | +| [0120](0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md) | A `net11.0` target joins a 2.x minor when a feature needs it, and a dependency floor may rise in a minor, on every target or on `net11.0` alone, if it is documented (the Semantic Versioning FAQ calls a dependency update with an unchanged public API compatible; a project that references the dependency lower gets NU1605, measured on SDK 11 RC1, so the changelog names the floor, who it reaches and both ways out, and the smoke test shows it); a union new on `net11.0` is an addition and may join a 2.x minor (a `LangVersion` 14 consumer who matches on it gets CS9327, and on Metalama 2026.1 CS8652, measured); Metalama is one version for every target and TypeKit follows the maintained Metalama year in a minor: 2.3 and 2.4 stay on 2026.1 and 2.5.0 moves both targets to 2027.0 once stable (a direct 2026.1 reference gets NU1605 and stays on 2.4.x; a woven `net11.0` project goes from C# 14 to 15; conditions: a license-free CI and clean-container build, the ceiling and the 2.4.x line documented); the SDK 11 spike comes first (#170); 3.0.0 stays the `net10.0` drop and a change of an existing contract, timed to .NET 12 LTS, and .NET 11 is no reason for a major; refines decision 44 | 2026-10-29 | accepted; its Metalama timing superseded by [0129](0129-metalama-2027-0-moves-into-2-4-0.md) | | [0121](0121-a-generated-member-is-refused-wherever-the-value-object-reaches-it.md) | CMTK1011, and CMTK1008 for comparison, refuse a generated member written by hand wherever a value object or closed set reaches it: on it, in a base record, public or explicit, or as an interface's explicit implementation, in any assembly, found by the interface mapping since Metalama lists no private member of another assembly's type; a base record's `Create` beside the value object's own (#195) and a seam a base record declares (#194) too; `IConvertible`, `IValueObject<,>`, `IValueObjectMaterializer<,>`, `IPlainValueObject<,>` and a set's `IParsable` declared through an interface or by a base record are CMTK1011 where the aspect crashed (#192); a closed set's base class counts as a base record does, its `sealed` `ToString()` the seam and one not sealed refused (#205); an interface's `==` and .NET's own `INumberBase` bridges are not refused; an exception to 34 taken in the patch 2.3.1 (#191, #192, #194, #195, #197, #205) | 2026-10-30 | accepted; refined by [0128](0128-one-signature-identity-and-a-mark-on-every-generated-member.md) | | [0122](0122-arithmetic-operators-are-opt-in-and-a-hand-written-one-is-a-seam.md) | A plain value object gets the arithmetic operators (`+`, `-`, `*`, `/`, `%`, unary `-` and `+`, and their `checked` forms) of the operator interfaces it declares, where the wrapped type implements the same interface with the value object replaced by itself; each calls the wrapped type's through `GeneratedArithmetic`, a constrained generic call with its context stated; never by default and never on a validated value object, which keeps CS0535; a hand-written operator for the same operands, or an explicit implementation of the interface, its own or a base record's, is a seam, kept with its `checked` form, so 2.3 code builds unchanged; refines decision 28 | 2026-10-30 | accepted; refined by [0123](0123-a-hand-written-operator-is-refused-in-a-query.md) and [0124](0124-an-operator-in-a-query-is-the-wrapped-type-s-arithmetic.md) | | [0123](0123-a-hand-written-operator-is-refused-in-a-query.md) | An arithmetic, bitwise or shift operator a value object declares by hand is refused in an EF Core query, naming the value object and `.Value`, by an interceptor and, for query filters, when the model is built; the generated ones carry `[TranslatedAsWrappedArithmetic]`, which is what tells them apart; a conversion operator is left to EF; refines decision 122 | 2026-10-30 | accepted | @@ -135,3 +135,7 @@ per area ([design](../plan.md)) link to the records they rest on. | [0126](0126-parallel-work-runs-in-worktrunk-worktrees-beside-the-repository.md) | Parallel work runs in worktrunk worktrees at `../CodoMetis.TypeKit-worktrees/`, set per machine in worktrunk's user config; worktrunk's default branch is the open `release/`, set per clone, so `wt switch -c`, the plugin's agent worktrees, `wt remove` and `wt step prune` base on it; the Bash guard refuses `wt merge` and `wt step squash`, `rebase` and `push`, since work lands by a PR and a merge commit (decision 94); nothing is copied into a new worktree, which builds the solution cold in 27 s; `.claude/worktrees/` joins `.gitignore`; [design/worktrees.md](../worktrees.md) is the runbook | 2026-10-31 | accepted | | [0127](0127-a-change-to-tools-or-tests-runs-the-test-projects-it-reaches.md) | A change whose paths are prose, the ignore list or inside solution projects under `tools/` and `test/` runs the projects it reaches (`suite=reach`, written as `test/Reach.slnf`): a project reaches its directory, what its items and imports name and what its references reach, and a run-time read by path is declared with `` (the conventions the root, the oracle tests `test/`), which `TestReachTests` holds against MSBuild's evaluation and the sources' literals; anything else, or anything unreadable, runs the whole solution; `.gitignore` is Linux alone; the gate refuses a reached suite with no projects, the pack or macOS; amends decision 113 | 2026-10-31 | accepted | | [0128](0128-one-signature-identity-and-a-mark-on-every-generated-member.md) | Every check of a hand-written member asks one identity, C#'s: a method of the generated one's name, arity, parameter types without nullable annotations (`Nullable` its own type) and by-reference-ness, or another kind of member of its name (in a base too, but a base's method beside a generated property), visible from the value object; the named generated members are entries the aspects introduce through, which name, check and mark them, and the check, the CMTK1005/CMTK1021 names and the refused interfaces read the same entries; every generated member carries `[GeneratedMember(typeof(Contract), "Member")]` from the base package, but the overrides Metalama writes over a record's implicit members, which take no attribute; refines decisions 28 and 121 | 2026-10-31 | accepted | +| [0129](0129-metalama-2027-0-moves-into-2-4-0.md) | The Generators package moves to Metalama 2027.0 in 2.4.0, for both targets, so a consumer with only the .NET 11 SDK builds (on 2026.1 a web project fails there with LAMA0625, on `net10.0` as on `net11.0`, KB-060); 2.4.0 is tagged only on a stable 2027.0; a CI and smoke-test lane with only SDK 11 installed and a web consumer joins decision 120's conditions (#281); 2.3.x is the line below the ceiling; #173, #272 and #223 move to 2.4.0; staying on 2026.1, a 2.4.0 without `net11.0` and a 2.4.0 on the preview were refused; replaces decision 120's Metalama timing | 2026-10-31 | accepted; amended by [0130](0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md) | +| [0130](0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md) | Every 2.4.0 version is built on the current Metalama 2027 preview and is published as `2.4.0-preview.N` until Metalama 2027.0 is stable; `v2.4.0` is still tagged only on a stable 2027.0, a new Metalama preview is taken by a change of its own, and each preview has its changelog section. Amends decision 129 | 2026-11-28 | accepted | +| [0131](0131-the-sdk-pin-moves-to-11-0-1xx.md) | `global.json` pins SDK 11.0.100 with `latestPatch`, after the Generators package is on Metalama 2027 (on 2026.1.30 the repository fails there with CS8034), and every fact pinned to the SDK band is run again on the new one | 2026-11-28 | accepted | +| [0132](0132-on-ef-core-11-a-ulong-or-char-key-s-temporary-value-is-a-factory-on-the-property.md) | On EF Core 11, which removed the factory a type mapping took from its converter's hints (decision 114), a value object over `ulong` or `char` generated on add gets `WrappedTypeValueGeneratorFactory` on the property; SQL Server's HiLo then is not chosen for a `ulong` key unless the application clears the factory, and a Native AOT compiled model and a converter named by hand get the temporary value they lacked | 2026-11-28 | accepted | diff --git a/design/aspects.md b/design/aspects.md index 075ce16..1fad7a8 100644 --- a/design/aspects.md +++ b/design/aspects.md @@ -350,9 +350,10 @@ build off: 0 in 200. Enumerating, which takes the collection's lock: 0 in 600, and 4 in 150 again with it reverted. The race has no deterministic test, so `CodeModelLookupTests` (conventions) fails on any such lookup in `.Generators`. -- **Metalama 2026.1.** Aspect state uses `IDurableRef`, which exists in 2026.1. `[Durable]` on the - `_value` template placeholder is 2027.0-only and stays out until the upgrade ([decision 4](adr/0004-metalama-2026-1-x-latest-stable.md)). Build - each aspect on 2026.1 as it lands, and use no 2027.0-only API. +- **Metalama 2027.0**, a preview until it is stable ([decision 130](adr/0130-2-4-0-is-published-as-previews-on-the-current-metalama-2027-preview.md)). + Aspect state uses `IDurableRef`. A static member of an aspect is immutable (`ImmutableArray`, never an array): + the 2027 compiler refuses any other with LAMA0891, since it is shared by every target and compilation. `[Durable]` + on the `_value` template placeholder is not asked for by 2027.0.9-preview and stays out. - **`AspectOrder`** lives in `CodoMetis.TypeKit.Generators`: `ClosedSetAspect` first, then `ValueObjectAspect`, which leaves the state the other value-object aspects read ([decision 60](adr/0060-value-object-over-closed-set-generated-in-full.md)). The closed-set aspect reads diff --git a/design/knowledge/KB-001-openapi-2-nullable-body-drops-pattern.md b/design/knowledge/KB-001-openapi-2-nullable-body-drops-pattern.md index 347d764..7d68ec7 100644 --- a/design/knowledge/KB-001-openapi-2-nullable-body-drops-pattern.md +++ b/design/knowledge/KB-001-openapi-2-nullable-body-drops-pattern.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-16 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: the document Microsoft.AspNetCore.OpenApi writes for an MVC [FromBody] int and int?, and a minimal-API [FromBody] enum?, under OpenApiSpecVersion.OpenApi2_0 and OpenApi3_1, measured in a host without TypeKit turned-on: the probe finding G1, dismissed as no TypeKit bug (tools/probe/corpus/dismissed.jsonl), and the probe harness comparing a nullable value object with the nullable wrapped type test: test/CodoMetis.TypeKit.Facts/KB001.cs diff --git a/design/knowledge/KB-002-api-explorer-lists-a-controller-only-when-visible.md b/design/knowledge/KB-002-api-explorer-lists-a-controller-only-when-visible.md index 4f00476..d8a9210 100644 --- a/design/knowledge/KB-002-api-explorer-lists-a-controller-only-when-visible.md +++ b/design/knowledge/KB-002-api-explorer-lists-a-controller-only-when-visible.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: the paths of the document Microsoft.AspNetCore.OpenApi writes for four MVC controllers, measured in a host without TypeKit turned-on: docs/aspnet-core.md (which controllers are in the document) and the probe axis value controller-without-ApiController-visible (55c4068) test: test/CodoMetis.TypeKit.Facts/KB002.cs diff --git a/design/knowledge/KB-003-typedescriptor-described-before-registered.md b/design/knowledge/KB-003-typedescriptor-described-before-registered.md index 48c5153..869af21 100644 --- a/design/knowledge/KB-003-typedescriptor-described-before-registered.md +++ b/design/knowledge/KB-003-typedescriptor-described-before-registered.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.ComponentModel.TypeDescriptor in the .NET 10 runtime, measured with a type carrying a TypeConverterAttribute turned-on: the fix 1ee02fc (a value object over a NodaTime type parses after MVC described the type), GeneratedParsing's fallback and design/aspects.md test: test/CodoMetis.TypeKit.Facts/KB003.cs diff --git a/design/knowledge/KB-004-windows-refuses-a-replace-over-a-held-file.md b/design/knowledge/KB-004-windows-refuses-a-replace-over-a-held-file.md index f3e7f4f..350b057 100644 --- a/design/knowledge/KB-004-windows-refuses-a-replace-over-a-held-file.md +++ b/design/knowledge/KB-004-windows-refuses-a-replace-over-a-held-file.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: File.Move over a file another FileStream holds open with FileShare.ReadWrite and FileShare.Delete, on GitHub's windows-latest runner (runs 38732628888 and 38734437033 failed on it, 38736660731 passed with the file moved aside) and on macOS turned-on: decision 92 (how every tool replaces a file) and the fix 617db19 (tools/Shared/SharedFile.cs) test: test/CodoMetis.TypeKit.Facts/KB004.cs diff --git a/design/knowledge/KB-005-launch-costs-of-the-tool-forms.md b/design/knowledge/KB-005-launch-costs-of-the-tool-forms.md index a3e7f1e..a057fa1 100644 --- a/design/knowledge/KB-005-launch-costs-of-the-tool-forms.md +++ b/design/knowledge/KB-005-launch-costs-of-the-tool-forms.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: warm runs of a trivial console tool on macOS (arm64) with SDK 10.0.402, timed per launch form, and the Bash guard as Claude Code runs it, measured 2026-10-15 turned-on: decision 92 (a tool run often is a tool project run as its built dll, never dotnet run) test: none, a timing that a shared CI runner measures too noisily to assert diff --git a/design/knowledge/KB-006-nested-serializer-call-restarts-reference-ids.md b/design/knowledge/KB-006-nested-serializer-call-restarts-reference-ids.md index 819b87f..1813990 100644 --- a/design/knowledge/KB-006-nested-serializer-call-restarts-reference-ids.md +++ b/design/knowledge/KB-006-nested-serializer-call-restarts-reference-ids.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.Text.Json in the .NET 10 runtime under ReferenceHandler.Preserve, measured with a converter that writes its value through JsonSerializer.Serialize(writer, value, options) turned-on: decision 76 (a value object refuses preserved references inside its wrapped value) test: test/CodoMetis.TypeKit.Facts/KB006.cs diff --git a/design/knowledge/KB-007-a-resolver-s-contract-wins-over-the-options-converters.md b/design/knowledge/KB-007-a-resolver-s-contract-wins-over-the-options-converters.md index 561c813..45ef4e7 100644 --- a/design/knowledge/KB-007-a-resolver-s-contract-wins-over-the-options-converters.md +++ b/design/knowledge/KB-007-a-resolver-s-contract-wins-over-the-options-converters.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.Text.Json in the .NET 10 runtime, measured with a resolver inserted first in TypeInfoResolverChain and a conflicting converter in JsonSerializerOptions.Converters turned-on: decision 83 (a description asks the contract's converter first) test: test/CodoMetis.TypeKit.Facts/KB007.cs diff --git a/design/knowledge/KB-008-the-nullable-adapter-is-the-serializer-s-own.md b/design/knowledge/KB-008-the-nullable-adapter-is-the-serializer-s-own.md index 257c8d1..91523cf 100644 --- a/design/knowledge/KB-008-the-nullable-adapter-is-the-serializer-s-own.md +++ b/design/knowledge/KB-008-the-nullable-adapter-is-the-serializer-s-own.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.Text.Json in the .NET 10 runtime, the converter of a decimal? contract from the reflection resolver and from JsonMetadataServices.GetNullableConverter, inspected and measured turned-on: decisions 83 and 86 (a nullable's converter is seen through only where it is the serializer's adapter, told by its assembly) test: test/CodoMetis.TypeKit.Facts/KB008.cs diff --git a/design/knowledge/KB-009-a-modifier-s-converter-wins-over-the-attribute.md b/design/knowledge/KB-009-a-modifier-s-converter-wins-over-the-attribute.md index 233aa67..51530c8 100644 --- a/design/knowledge/KB-009-a-modifier-s-converter-wins-over-the-attribute.md +++ b/design/knowledge/KB-009-a-modifier-s-converter-wins-over-the-attribute.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.Text.Json in the .NET 10 runtime, measured with a DefaultJsonTypeInfoResolver modifier setting JsonPropertyInfo.CustomConverter on a property that carries [JsonConverter] turned-on: decision 86 (a property's attribute is asked only where its converter is the adapter) test: test/CodoMetis.TypeKit.Facts/KB009.cs diff --git a/design/knowledge/KB-023-a-converter-cannot-describe-its-schema.md b/design/knowledge/KB-023-a-converter-cannot-describe-its-schema.md index 005aa5a..b86efa4 100644 --- a/design/knowledge/KB-023-a-converter-cannot-describe-its-schema.md +++ b/design/knowledge/KB-023-a-converter-cannot-describe-its-schema.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-15 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.Text.Json and Microsoft.AspNetCore.OpenApi in .NET 10, measured with a property written by a converter of one's own, and the issues dotnet/runtime#105769 and dotnet/aspnetcore#63051 as of 2026-10-14 turned-on: decision 71 (converters say what they write) and "A gap none of them fills" in docs/comparison.md test: test/CodoMetis.TypeKit.Facts/KB023.cs diff --git a/design/knowledge/KB-025-the-coverage-collector-rewrites-assemblies-on-disk.md b/design/knowledge/KB-025-the-coverage-collector-rewrites-assemblies-on-disk.md index 5d6833a..b628e77 100644 --- a/design/knowledge/KB-025-the-coverage-collector-rewrites-assemblies-on-disk.md +++ b/design/knowledge/KB-025-the-coverage-collector-rewrites-assemblies-on-disk.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-16 +verified: 2026-11-28 pins: - external Microsoft.Testing.Extensions.CodeCoverage 18.12.0 - - sdk 10.0.4xx + - sdk 11.0.1xx source: the probe replay on macOS (arm64), 43 probes run four and sixteen at a time from one output directory with --coverage, the kept logs of the failed hosts, and the collector's runsettings as the Microsoft.Testing.Platform repository documents them, measured 2026-10-16 turned-on: decision 101 (a replay that records a footprint runs one host at a time; parallel runs record none) test: none, a race between processes that no single test can hold; the replay's --parallel runs with and without a footprint are the measurement diff --git a/design/knowledge/KB-026-openapi-2-nullable-component-property-loses-its-reference.md b/design/knowledge/KB-026-openapi-2-nullable-component-property-loses-its-reference.md index c7319fb..3309ad9 100644 --- a/design/knowledge/KB-026-openapi-2-nullable-component-property-loses-its-reference.md +++ b/design/knowledge/KB-026-openapi-2-nullable-component-property-loses-its-reference.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-16 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: the document Microsoft.AspNetCore.OpenApi writes for an MVC [FromBody] record with a property of a record struct and one of its Nullable, under OpenApiSpecVersion.OpenApi2_0 and OpenApi3_1, measured in a host without TypeKit turned-on: row 38 of C21OpenapiSchemaParityProbe (claim C21-openapi-schema-parity), where a nullable value-object property that is a component had no type under OpenAPI 2.0 test: test/CodoMetis.TypeKit.Facts/KB026.cs diff --git a/design/knowledge/KB-027-an-enum-component-is-its-first-use.md b/design/knowledge/KB-027-an-enum-component-is-its-first-use.md index ecc6939..c339bdd 100644 --- a/design/knowledge/KB-027-an-enum-component-is-its-first-use.md +++ b/design/knowledge/KB-027-an-enum-component-is-its-first-use.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-16 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: the document Microsoft.AspNetCore.OpenApi writes for minimal API header parameters of two enums written by name (JsonStringEnumConverter), each used once nullable and once not, in opposite orders, under OpenApiSpecVersion.OpenApi3_1 and OpenApi3_0, measured in a host without TypeKit turned-on: row 285 of C21OpenapiSchemaParityProbe (claim C21-openapi-schema-parity, finding F3), where the wrapped E? header's enum listed null through E's component and the value object's did not test: test/CodoMetis.TypeKit.Facts/KB027.cs diff --git a/design/knowledge/KB-037-mvc-under-max-validation-depth-1-runs-an-unbound-action.md b/design/knowledge/KB-037-mvc-under-max-validation-depth-1-runs-an-unbound-action.md index e21341d..f2d1032 100644 --- a/design/knowledge/KB-037-mvc-under-max-validation-depth-1-runs-an-unbound-action.md +++ b/design/knowledge/KB-037-mvc-under-max-validation-depth-1-runs-an-unbound-action.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-17 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: measured in a host without TypeKit (Microsoft.AspNetCore.App 10.0 of the pinned SDK, an [ApiController] with an int parameter per binding source); the API reference of MvcOptions.MaxValidationDepth says only that "ValidationVisitor will throw if traversing an object exceeds the maximum allowed validation depth" and that "The default value is 32", nothing of binding errors turned-on: 28 rows of BaseProbe (claim C07-fault-responses-blanket) under mvc.MaxValidationDepth=1, where a validated value object answered a value its Create refuses with 200 holding its default (WS2 step 4 triage) test: test/CodoMetis.TypeKit.Facts/KB037.cs diff --git a/design/knowledge/KB-038-a-byte-array-is-a-base64-string.md b/design/knowledge/KB-038-a-byte-array-is-a-base64-string.md index c9ccdf2..32405c8 100644 --- a/design/knowledge/KB-038-a-byte-array-is-a-base64-string.md +++ b/design/knowledge/KB-038-a-byte-array-is-a-base64-string.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-17 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: the System.Array section of Supported types in System.Text.Json (learn.microsoft.com, dotnet/docs supported-types.md), which says "`byte[]` is handled specially and serializes as a base64 string, not a JSON array."; measured with System.Text.Json of the pinned SDK turned-on: row 83 of BaseProbe (claim C07-fault-responses-blanket), where an array of value objects over byte was written [7] and the wrapped twin, a byte[], "Bw=="; docs/json.md "The wrapped type's JSON" and the not-promised entry a-byte-array-is-base64 of claim L01-json-bytes test: test/CodoMetis.TypeKit.Facts/KB038.cs diff --git a/design/knowledge/KB-040-a-converter-is-charged-a-level-of-max-depth.md b/design/knowledge/KB-040-a-converter-is-charged-a-level-of-max-depth.md index df4e787..71c6523 100644 --- a/design/knowledge/KB-040-a-converter-is-charged-a-level-of-max-depth.md +++ b/design/knowledge/KB-040-a-converter-is-charged-a-level-of-max-depth.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-17 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: measured with System.Text.Json of the pinned SDK, a list of int nested in objects, written once by the serializer's own converter and once by a converter of the application's; the API reference of JsonSerializerOptions.MaxDepth says only that it is "the maximum depth allowed when serializing or deserializing JSON", nothing of converters turned-on: the rows of BaseProbe, C10-preserve-guard, L01-json-bytes and L04-round-trip under json.MaxDepth=3 where a value object, which its converter writes, was refused at a depth its wrapped twin was written at; until WS2's three-sided differential these were told by the refusal's message (note stj-maxdepth), now by side (1), a converter of the application's for the wrapped type without TypeKit test: test/CodoMetis.TypeKit.Facts/KB040.cs diff --git a/design/knowledge/KB-041-mvc-cannot-write-its-400-under-a-context-without-validation-problem-details.md b/design/knowledge/KB-041-mvc-cannot-write-its-400-under-a-context-without-validation-problem-details.md index a83170b..379f92e 100644 --- a/design/knowledge/KB-041-mvc-cannot-write-its-400-under-a-context-without-validation-problem-details.md +++ b/design/knowledge/KB-041-mvc-cannot-write-its-400-under-a-context-without-validation-problem-details.md @@ -1,7 +1,7 @@ --- -verified: 2026-10-17 +verified: 2026-11-28 pins: - - sdk 10.0.4xx + - sdk 11.0.1xx source: measured in a host without TypeKit (Microsoft.AspNetCore.App 10.0 of the pinned SDK, an [ApiController] with an int route parameter, MVC's JSON options given a source-generated context listing int alone); ASP.NET Core's web API documentation, "Automatic HTTP 400 responses", names ValidationProblemDetails as the default type of that response turned-on: rows 286 and 309 of BaseProbe (claim C07-fault-responses-blanket) under json.TypeInfoResolver=source-generated-context, where a value Create refuses answered 500 instead of MVC's 400; until WS2's three-sided differential told by the exception's words (note mvc-400-unwritable-under-source-gen), now by side (1), the wrapped twin sent a text it cannot read on a host without TypeKit test: test/CodoMetis.TypeKit.Facts/KB041.cs diff --git a/design/knowledge/KB-042-a-char-schema-is-refused-under-write-as-string.md b/design/knowledge/KB-042-a-char-schema-is-refused-under-write-as-string.md index f04120f..697dab7 100644 --- a/design/knowledge/KB-042-a-char-schema-is-refused-under-write-as-string.md +++ b/design/knowledge/KB-042-a-char-schema-is-refused-under-write-as-string.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-18 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: the document Microsoft.AspNetCore.OpenApi writes for a minimal API whose body holds a char, and one whose body holds an int, under JsonNumberHandling.WriteAsString and the default number handling, measured in a host without TypeKit; ASP.NET Core 10's OpenApiSchemaService builds each schema with System.Text.Json's JsonSchemaExporter under the host's options and reads the node back as its own OpenApiJsonSchema, and a char's schema is the exporter's minLength and maxLength of 1 turned-on: row 408 of C21OpenapiSchemaParityProbe (claim C21-openapi-schema-parity), under json.NumberHandling=WriteAsString with json.MaxDepth=3, where AddTypeKit() refused the document with this JsonException, asking for the char a value object wraps, and ASP.NET alone with MaxDepth's InvalidOperationException, met first at another endpoint test: test/CodoMetis.TypeKit.Facts/KB042.cs diff --git a/design/knowledge/KB-057-a-nullable-contract-has-an-element-type-and-reads-null-as-null.md b/design/knowledge/KB-057-a-nullable-contract-has-an-element-type-and-reads-null-as-null.md index d8baeb1..7eb99e1 100644 --- a/design/knowledge/KB-057-a-nullable-contract-has-an-element-type-and-reads-null-as-null.md +++ b/design/knowledge/KB-057-a-nullable-contract-has-an-element-type-and-reads-null-as-null.md @@ -1,8 +1,8 @@ --- -verified: 2026-10-31 +verified: 2026-11-28 pins: - Microsoft.AspNetCore.OpenApi 10.0.12 - - sdk 10.0.4xx + - sdk 11.0.1xx source: System.Text.Json in the .NET 10 runtime, the contract of a Nullable from the reflection resolver and a JSON null read into T? as a property, an element and the root, over a T whose converter handles null, measured; and the schemas Microsoft.AspNetCore.OpenApi hands its schema transformers below a Nullable>, measured in PatchSchemaTests turned-on: the fix of issue 232 (pull request 237), where a nullable patch is described as its argument admitting null but not as a merge-patch field, the container check reads the kind before the element type, and the argument's elements below a nullable patch are skipped test: test/CodoMetis.TypeKit.Facts/KB057.cs diff --git a/design/knowledge/KB-061-asp-net-core-11-writes-an-operation-s-statuses-ascending.md b/design/knowledge/KB-061-asp-net-core-11-writes-an-operation-s-statuses-ascending.md new file mode 100644 index 0000000..2d100a7 --- /dev/null +++ b/design/knowledge/KB-061-asp-net-core-11-writes-an-operation-s-statuses-ascending.md @@ -0,0 +1,19 @@ +--- +verified: 2026-11-28 +pins: + - external ASP.NET-Core 11.0.0 + - external ASP.NET-Core 10.0.15 +source: a host without TypeKit, AddOpenApi() and MapGet("/plain").Produces(200).Produces(409).Produces(404).Produces(202), its document read on net10.0 (runtime 10.0.15, Microsoft.AspNetCore.OpenApi 10.0.12) and on net11.0 (runtime 11.0.0, Microsoft.AspNetCore.OpenApi 11.0.0), macOS arm64 +turned-on: ComposedFaultResponseTests, whose operation without a fault response kept the order its statuses were declared in, and issue 214 +test: none, the facts project runs on net10.0 until it has a net11.0 run (issue 208); ComposedFaultResponseTests compares the operation with the same host without TypeKit on both targets +--- + +# KB-061. ASP.NET Core 11 writes an operation's response statuses in ascending order + +An operation that declares 200, 409, 404 and 202, in that order, is written with the responses `200, 409, 404, 202` by +ASP.NET Core 10 and `200, 202, 404, 409` by ASP.NET Core 11. + +So on ASP.NET Core 11 an operation TypeKit adds no fault response to is ascending as well, like the ones it sorts. +The test's comparison with a host without TypeKit holds on both. + +Not measured: a range such as `4XX` and `default` among them, and an MVC action. diff --git a/design/knowledge/KB-062-asp-net-core-11-answers-a-refused-minimal-api-body-with-a-validation-problem.md b/design/knowledge/KB-062-asp-net-core-11-answers-a-refused-minimal-api-body-with-a-validation-problem.md new file mode 100644 index 0000000..9ba1ef1 --- /dev/null +++ b/design/knowledge/KB-062-asp-net-core-11-answers-a-refused-minimal-api-body-with-a-validation-problem.md @@ -0,0 +1,25 @@ +--- +verified: 2026-11-28 +pins: + - external ASP.NET-Core 11.0.0 + - external ASP.NET-Core 10.0.15 +source: a host without TypeKit, MapPost("/body", (Holder holder) => holder) over a record with a DayOfWeek property written by name, posted {"day":"Noday"}, with and without AddProblemDetails() and AddValidation(), on net10.0 (runtime 10.0.15) and net11.0 (runtime 11.0.0), macOS arm64 +turned-on: HostConfigurationTests and FaultSetValueBindingTests, the AspNetCore README's "Binding" section, and issue 214 +test: none, the facts project runs on net10.0 until it has a net11.0 run (issue 208); HostConfigurationTests holds the answer for a value object on both targets +--- + +# KB-062. With `AddProblemDetails()`, ASP.NET Core 11 answers a JSON body a minimal API could not read with a validation problem that carries the converter's message + +| Host | ASP.NET Core 10 | ASP.NET Core 11 | +|---|---|---| +| no problem details | `400`, empty | `400`, empty | +| `AddProblemDetails()` | `400`, empty | `400`, a validation problem: `"title":"One or more validation errors occurred."` and `"errors":{"$.day":["The JSON value could not be converted to System.DayOfWeek. Path: $.day \| LineNumber: 0 \| BytePositionInLine: 14."]}` | +| `AddValidation()` alone | `400`, empty | `400`, empty | + +The message under the path is the `JsonException`'s. For a validated value object that is the generated converter's, +which names the value object and the rule and never the input, so on ASP.NET Core 11 a client of a minimal API reads +the rule's name, as a client of an MVC action already did. `UseStatusCodePages()` changes nothing there: the response +has its body already. + +Not measured: `AddProblemDetails()` beside `AddValidation()` gave an empty 400 in the plain host, which was not +looked into, and a host on source-generated JSON. diff --git a/design/knowledge/KB-063-asp-net-core-11-s-openapi-json-context-answers-for-decimal.md b/design/knowledge/KB-063-asp-net-core-11-s-openapi-json-context-answers-for-decimal.md new file mode 100644 index 0000000..ad55c09 --- /dev/null +++ b/design/knowledge/KB-063-asp-net-core-11-s-openapi-json-context-answers-for-decimal.md @@ -0,0 +1,30 @@ +--- +verified: 2026-11-28 +pins: + - external ASP.NET-Core 11.0.0 + - external ASP.NET-Core 10.0.15 +source: the probe host of DescribedSchemaTests with DecimalStringJsonConverter in the options' converters and a resolver for decimal inserted at index 0 of the chain, on net10.0 (runtime 10.0.15) and net11.0 (runtime 11.0.0); a console program with the same two and no ASP.NET, on both runtimes, macOS arm64 +turned-on: DescribedSchemaTests' writer "a resolver's decimal converter over the options'", and issue 214 +test: none, the facts project runs on net10.0 until it has a net11.0 run (issue 208); DescribedSchemaTests holds the schema to what is written on both targets +--- + +# KB-063. In a host with `AddOpenApi()`, ASP.NET Core 11 writes a `decimal` with the options' converter where a resolver the application put first would write it + +The HTTP JSON options of a host with `AddOpenApi()` have this resolver chain on both versions, with a resolver the +application inserts at index 0 in its `ConfigureHttpJsonOptions`: +`Microsoft.AspNetCore.OpenApi.OpenApiJsonSchemaContext`, the application's resolver, `DefaultJsonTypeInfoResolver`. + +| | ASP.NET Core 10 | ASP.NET Core 11 | +|---|---|---| +| `options.GetTypeInfo(typeof(decimal)).Converter` | the resolver's | the options' | +| `JsonSerializer.Serialize(7.8m, options)` | `7.8` | `"7.8"` | + +Without ASP.NET, the same options' converter and resolver give the resolver's answer on both runtimes +([KB-007](KB-007-a-resolver-s-contract-wins-over-the-options-converters.md) holds on .NET 11). So the difference is +the context ASP.NET puts first: on ASP.NET Core 11 it answers for `decimal`, and a source-generated context's +contract takes a converter of the options. Read from the chain and the answers, not from ASP.NET's source. + +A value object over a `decimal` is written as the plain `decimal` is in both, a string on ASP.NET Core 11, and its +schema says so. + +Not measured: which other types the context answers for on ASP.NET Core 11, and a host without `AddOpenApi()`. diff --git a/design/knowledge/KB-064-sql-server-s-greatest-and-least-leave-a-null-out.md b/design/knowledge/KB-064-sql-server-s-greatest-and-least-leave-a-null-out.md new file mode 100644 index 0000000..9ecf9e2 --- /dev/null +++ b/design/knowledge/KB-064-sql-server-s-greatest-and-least-leave-a-null-out.md @@ -0,0 +1,22 @@ +--- +verified: 2026-11-28 +pins: + - external SQL-Server 2022 + - Microsoft.EntityFrameworkCore.SqlServer 10.0.12 +source: https://learn.microsoft.com/sql/t-sql/functions/logical-functions-greatest-transact-sql ("If one or more arguments aren't NULL, then NULL arguments are ignored during comparison"), measured with plain EF Core at compatibility level 160 on the mssql/server 2022 image +turned-on: the SQL Server query catalogue's Greatest and Least cases over a nullable value (SqlServerQueryVariantTests, issue 215), which EF Core 11 translates at its default compatibility level, so their answers are compared with memory's for the first time +test: test/CodoMetis.TypeKit.Facts/KB064.cs +--- + +# KB-064. SQL Server's `GREATEST` and `LEAST` leave a NULL argument out + +`Select(m => EF.Functions.Greatest(m.Left, 7))` over the rows NULL and 10 answers `7, 10` on SQL Server, and +`Least` answers `7, 7`: the row without a value answers the other argument. In memory, and on SQLite, whose `max` +and `min` of two arguments answer NULL when either is, that row answers no value. PostgreSQL's `GREATEST` and +`LEAST` leave a NULL out as SQL Server's do. + +EF translates the two on SQL Server from compatibility level 160 +([KB-053](KB-053-greatest-and-least-need-compatibility-level-160.md)), which is EF Core 11's default level and was +not EF Core 10's. So on EF Core 10 the catalogue saw these cases refused at the default level, and only compared +their SQL at 160; on EF Core 11 they answer, and the answer differs from memory's by this alone, for the wrapped +type as for the value object over it. diff --git a/design/knowledge/KB-065-sql-server-orders-null-first.md b/design/knowledge/KB-065-sql-server-orders-null-first.md new file mode 100644 index 0000000..a801e98 --- /dev/null +++ b/design/knowledge/KB-065-sql-server-orders-null-first.md @@ -0,0 +1,19 @@ +--- +verified: 2026-11-28 +pins: + - external SQL-Server 2022 + - Microsoft.EntityFrameworkCore.SqlServer 10.0.12 +source: https://learn.microsoft.com/sql/t-sql/queries/select-order-by-clause-transact-sql ("Null values are treated as the lowest possible values"), measured with plain EF Core on the mssql/server 2022 image +turned-on: the SQL Server query catalogue's MinBy cases over a nullable value (SqlServerQueryVariantTests, issue 215), which EF Core 11 translates, and which SQLite cannot second where it orders no ulong and no DateTimeOffset +test: test/CodoMetis.TypeKit.Facts/KB065.cs +--- + +# KB-065. SQL Server orders NULL before every value, so the first row by a nullable column is the one without a value + +`OrderBy(m => m.Left).First()` over the rows 10, NULL and 7 answers the row without a value on SQL Server. In memory, +`MinBy(m => m.Left)` leaves a row without a key out and answers 7. + +EF Core 11 translates `MinBy` to that ordering, where EF Core 10 refuses it. So on SQL Server a `MinBy` over a +nullable value answers the row without one, for the wrapped type as for the value object over it. SQLite orders NULL +first too and answers the same, which is how the catalogue accepts it for most kinds; it refuses to order a `ulong` +or a `DateTimeOffset`, where this fact stands alone. `MaxBy` is not touched: NULL is never the greatest. diff --git a/design/knowledge/README.md b/design/knowledge/README.md index d017164..68b1044 100644 --- a/design/knowledge/README.md +++ b/design/knowledge/README.md @@ -89,3 +89,8 @@ test and later for the harness's `Baseline.Fact`. | [KB-057](KB-057-a-nullable-contract-has-an-element-type-and-reads-null-as-null.md) | A `Nullable` contract has `T` as its element type, and a JSON null read into it is null whatever `T`'s converter does | OpenApi 10.0.12, SDK 10.0.4xx | `KB057` | | [KB-058](KB-058-ef-orders-captured-values-in-sql-only-with-a-lambda.md) | EF orders captured values in SQL only when the chain takes a lambda: `values.Max()` runs in memory, `values.Max(v => v)` in SQL | EF Sqlite 10.0.12 | `KB058` | | [KB-060](KB-060-metalama-2026-1-on-the-net-11-sdk.md) | Metalama 2026.1 weaves a `net11.0` project on SDK 11 RC3 at C# 14, and a web project fails with `LAMA0625` when SDK 11 is the only SDK | .NET SDK 11 RC3, Metalama 2026.1.30, 2027.0.5-preview | prose | +| [KB-061](KB-061-asp-net-core-11-writes-an-operation-s-statuses-ascending.md) | ASP.NET Core 11 writes an operation's response statuses in ascending order, where ASP.NET Core 10 keeps the order they were declared in | ASP.NET Core 10.0.15, 11.0.0 | prose | +| [KB-062](KB-062-asp-net-core-11-answers-a-refused-minimal-api-body-with-a-validation-problem.md) | With `AddProblemDetails()`, ASP.NET Core 11 answers a JSON body a minimal API could not read with a validation problem that carries the converter's message, where ASP.NET Core 10 answers an empty 400 | ASP.NET Core 10.0.15, 11.0.0 | prose | +| [KB-063](KB-063-asp-net-core-11-s-openapi-json-context-answers-for-decimal.md) | In a host with `AddOpenApi()`, ASP.NET Core 11 writes a `decimal` with the options' converter where a resolver the application put first would write it, as on ASP.NET Core 10 | ASP.NET Core 10.0.15, 11.0.0 | prose | +| [KB-064](KB-064-sql-server-s-greatest-and-least-leave-a-null-out.md) | SQL Server's `GREATEST` and `LEAST` leave a NULL argument out, so a row without a value answers the other argument | SQL Server 2022, EF SqlServer 10.0.12 | `KB064` | +| [KB-065](KB-065-sql-server-orders-null-first.md) | SQL Server orders NULL before every value, so the first row by a nullable column, and EF Core 11's `MinBy`, is the one without a value | SQL Server 2022, EF SqlServer 10.0.12 | `KB065` | diff --git a/design/packages.md b/design/packages.md index 178112b..eb06099 100644 --- a/design/packages.md +++ b/design/packages.md @@ -4,7 +4,7 @@ |---|---|---|---| | `CodoMetis.TypeKit` | Analyzers (flows, [Analyzers](analyzers.md)) | **no** | `Option`, `Result`, `Result` and their extensions, all carrying `NotWireTypeJsonConverterFactory` ([Option and Result](option-result.md)); the value-object contracts `IValueObject<,>`, `IPlainValueObject<,>`, `IValue`, `IValidatedValue<,,>`, `IValueObjectMaterializer<,>` ([EF Core](ef-core.md)); the closed-set contracts `IClosedSet<>`, `IFault`, `IFaultSet<>` and `FaultKind`; `Fault` and `Fault.Of`, and `Fault` and `Fault`, a fault of one of several types ([decision 78](adr/0078-fault-sets-compose-side-by-side.md)); `Patch`, `PatchState` and `PatchJsonConverterFactory`; `Result.Catch`/`CatchAsync`; the text guards `AsText()`/`AsIdentifier()` (`StringTextExtensions`) and `TextFault`; the type-argument constraint attributes `[Abstract]`, `[Concrete]`, `[Sealed]`, `[Record]`; `RequireCustomInitializationAttribute`, `RequireParameterlessConstructorAttribute` and `ConstructorAccessibility`; `GuidValueExtensions` (`OrderId.New()` from a version 7 Guid); and what only generated code and the satellites use ([Discovery](discovery.md), [Aspects](aspects.md), [Native AOT](native-aot.md)): `GeneratedValueObjectAttribute<,>`, `GeneratedClosedSetAttribute<>`, `IValueObjectVisitor<>`, `IClosedSetVisitor<>`, `TranslatedAsWrappedValueAttribute`, `TranslatedAsWrappedArithmeticAttribute`, `HandWrittenOrderingAttribute`, `GeneratedFactories`, `GeneratedParsing`, `GeneratedFormatting`, `GeneratedArithmetic`, `GeneratedJson`, `GeneratedJsonPlan<>`, `GeneratedClosedSets`, `IStoredJsonConverterSource` | | `CodoMetis.TypeKit.Analyzers` | — | no | Roslyn analyzers and code fixes ([Analyzers](analyzers.md)). Nobody references it directly: it reaches every consumer through the base package | -| `CodoMetis.TypeKit.Generators` | TypeKit, Metalama.Framework 2026.1.x (flows) | yes | Internal aspects (the value-object family and `ClosedSetAspect`), internal `TransitiveProjectFabric`, `AspectOrder`. Future generated type families join this package too: one fabric, one aspect order | +| `CodoMetis.TypeKit.Generators` | TypeKit, Metalama.Framework 2027.0, a preview until it is stable (flows) | yes | Internal aspects (the value-object family and `ClosedSetAspect`), internal `TransitiveProjectFabric`, `AspectOrder`. Future generated type families join this package too: one fabric, one aspect order | | `CodoMetis.TypeKit.EntityFrameworkCore` | TypeKit, EF Core Relational | no | Generic converter, convention, `.Value` / `GetValue` / `ValueOrNull` translators, `UseTypeKit()` | | `CodoMetis.TypeKit.AspNetCore` | TypeKit, Microsoft.AspNetCore.OpenApi | no | `AddTypeKit()`: one OpenAPI schema transformer ([OpenAPI](openapi.md)); `ToHttpResult()`, `AddFaultResponses`, `FaultProblem`, `FaultResponseOptions`, `IFaultFeature` ([decision 38](adr/0038-result-becomes-response-explicit-tohttpresult-faults.md), [decision 49](adr/0049-fault-responses-client-can-act.md)) | | `CodoMetis.TypeKit.Serilog` | TypeKit, Serilog 4.0.0 | no | `Destructure.WithTypeKit()`: one destructuring policy that logs every value object as its `ToString()` ([decision 41](adr/0041-sensitive-value-object-declares-tostring-serilog.md)) | diff --git a/design/roadmap.md b/design/roadmap.md index 11d478e..b775498 100644 --- a/design/roadmap.md +++ b/design/roadmap.md @@ -58,15 +58,17 @@ Small, each closable in a minor version. Found by the reviews named. converters' trimming warnings decide whether it is a package ([decision 71](adr/0071-converters-say-what-they-write.md)). - A stable external name for a closed-set member, apart from its C# identifier: parsing, JSON, EF, OpenAPI and the fault identifiers at once (proposed in the review of 2026-10-13). -- The Metalama 2027.0 upgrade, in 2.5.0 (#173), once 2027.0 is stable (`2027.0.4-preview` on 2026-10-14; - [decision 4](adr/0004-metalama-2026-1-x-latest-stable.md)), for both targets at once and with 2.3 and 2.4 on - 2026.1 ([decision 120](adr/0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md)). It raises a floor in - a minor, which decision 120 allows when documented: a project that references `Metalama.Framework` 2026.1 - directly gets NU1605 and stays on TypeKit 2.4.x or raises its reference, and a woven `net11.0` project moves - from C# 14 to 15. Its conditions: a build with no Metalama license passes in CI and a clean container on 2027 - (#170), the weaving review and the smoke test run on it, the changelog and the Generators README name the - ceiling, the language-version change, the supported IDEs and what Metalama 2027 drops, and the release notes - say whether 2.4.x is patched. `[Durable]` returns to the `_value` placeholder with it. +- The Metalama 2027.0 upgrade, in 2.4.0 (#173), which is tagged only once 2027.0 is stable (`2027.0.5-preview` on + 2026-10-31; [decision 4](adr/0004-metalama-2026-1-x-latest-stable.md)), for both targets at once and with 2.3 on + 2026.1 ([decision 129](adr/0129-metalama-2027-0-moves-into-2-4-0.md), which moved it from 2.5.0 because on 2026.1 a + web project fails with LAMA0625 where SDK 11 is the only SDK). It raises a floor in a minor, which + [decision 120](adr/0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md) allows when documented: a + project that references `Metalama.Framework` 2026.1 directly gets NU1605 and stays on TypeKit 2.3.x or raises its + reference, and a woven `net11.0` project moves from C# 14 to 15. Its conditions: a build with no Metalama license + passes in CI and a clean container on 2027 (#170), a CI and smoke-test lane with only SDK 11 installed builds a web + consumer (#281), the weaving review and the smoke test run on it, the changelog and the Generators README name the + ceiling, the language-version change, the supported IDEs and what Metalama 2027 drops, and the release notes say + whether 2.3.x is patched. `[Durable]` returns to the `_value` placeholder with it. - A `net11.0` target beside `net10.0`, in a 2.x minor when a feature needs it ([decision 44](adr/0044-2-0-0-net10-0-metalama.md)), on the terms of [decision 120](adr/0120-a-net11-0-target-and-documented-floor-raises-join-a-minor.md): a higher floor in the `net11.0` group (EF Core 11 and Microsoft.AspNetCore.OpenApi 11 in the satellites) allowed when the diff --git a/docs/aspnet-core.md b/docs/aspnet-core.md index f2c6af0..37f89ad 100644 --- a/docs/aspnet-core.md +++ b/docs/aspnet-core.md @@ -61,7 +61,7 @@ reference the generators. **Good to know** -- **Reference `Microsoft.AspNetCore.OpenApi` directly, at 10.0.12 or later.** The package README +- **Reference `Microsoft.AspNetCore.OpenApi` directly, at 10.0.12 or later on .NET 10 and at 11.0.0 or later on .NET 11.** The package README explains why ([Setup](../src/CodoMetis.TypeKit.AspNetCore/README.md#setup)). ## Bind value objects in a minimal API diff --git a/docs/ef-core.md b/docs/ef-core.md index 9e31d8e..241d000 100644 --- a/docs/ef-core.md +++ b/docs/ef-core.md @@ -130,11 +130,15 @@ A composite key of value objects is `HasKey(x => new { x.Order, x.Line })`, as f - **A key over `char` is always yours to assign**, on every provider, since none generates one. A default `'\0'` is stored as it is, so assign a meaningful character. -- **Under Native AOT, a key over `ulong` needs `ValueGeneratedNever()` on SQL Server and PostgreSQL.** +- **On EF Core 10 under Native AOT, a key over `ulong` needs `ValueGeneratedNever()` on SQL Server and PostgreSQL.** Their column is a `decimal`, and in a compiled model made with `--nativeaot`, adding the entity with the key's default value throws `OverflowException` at `Add`. The same goes for a key you configure with `ValueObjectConverter` yourself. Configure `ValueGeneratedNever()` and assign the key. - Otherwise it gets a temporary value, as a plain `ulong` key does. + Otherwise it gets a temporary value, as a plain `ulong` key does. On EF Core 11 it gets one in + those two cases as well. +- **On EF Core 11, a key over `ulong` with SQL Server's HiLo needs one more line.** HiLo isn't chosen + until you clear the generator factory TypeKit sets on the key. The + [package README](../src/CodoMetis.TypeKit.EntityFrameworkCore/README.md#keys) has the line. - **Inheritance hierarchies.** The root of a TPH or TPT hierarchy is generated too. Under TPC, as for an `int` key, it's generated only where the provider has a sequence for the hierarchy (PostgreSQL, SQL Server), not on SQLite. @@ -273,7 +277,8 @@ types makes a round trip through a real PostgreSQL and a real SQL Server. - **A struct value object is stored as it is, or a class one fails the model.** The provider has no relational type mapping. EF's in-memory provider does that, so use SQLite. -- **NU1605 on restore.** You reference an EF Core package below 10.0.12 directly. Raise it. +- **NU1605 on restore.** You reference an EF Core package directly, below 10.0.12 on .NET 10 or below + 11.0.0 on .NET 11. Raise it. - **A convention doesn't reach a value object.** It was configured by the underlying type. Configure it by the value object's type. - **Every migration repeats an `AlterColumn` on SQLite.** An integer key is missing diff --git a/docs/walkthrough.md b/docs/walkthrough.md index 5d4e230..597f38f 100644 --- a/docs/walkthrough.md +++ b/docs/walkthrough.md @@ -223,7 +223,8 @@ Each of these is a 400 with problem details, and none of them quotes what the cl generated `TryParse`. `UseStatusCodePages()` gives these empty 400s their problem body. The body is ASP.NET's own and -names neither the field nor the rule. ASP.NET logs the reason. +names neither the field nor the rule. ASP.NET logs the reason. On ASP.NET Core 11, the rejected body +has a problem body already, which names the field and the rule. ## Find an order diff --git a/global.json b/global.json index 7bae113..063676a 100644 --- a/global.json +++ b/global.json @@ -3,12 +3,12 @@ "The SDK is pinned because the build is generation, not just compilation: Metalama and the", "CMTK analyzers run inside the compiler, so a different SDK feature band (a different Roslyn)", "can change what gets emitted.", - "rollForward latestPatch: patches inside the 10.0.4xx band are safe, and refusing them would", + "rollForward latestPatch: patches inside the 11.0.1xx band are safe, and refusing them would", "fail the build on any machine that installed a security update.", - "The test key selects Microsoft.Testing.Platform, which xunit.v3 4.x requires on SDK 10." + "The test key selects Microsoft.Testing.Platform, which xunit.v3 4.x requires from SDK 10 on." ], "sdk": { - "version": "10.0.402", + "version": "11.0.100", "rollForward": "latestPatch", "allowPrerelease": false }, diff --git a/src/CodoMetis.TypeKit.AspNetCore/CodoMetis.TypeKit.AspNetCore.csproj b/src/CodoMetis.TypeKit.AspNetCore/CodoMetis.TypeKit.AspNetCore.csproj index e8fecc1..38b93c3 100644 --- a/src/CodoMetis.TypeKit.AspNetCore/CodoMetis.TypeKit.AspNetCore.csproj +++ b/src/CodoMetis.TypeKit.AspNetCore/CodoMetis.TypeKit.AspNetCore.csproj @@ -1,4 +1,9 @@ + + + + net10.0;net11.0 + diff --git a/src/CodoMetis.TypeKit.AspNetCore/FaultResponsesOperationTransformer.cs b/src/CodoMetis.TypeKit.AspNetCore/FaultResponsesOperationTransformer.cs index 50f033f..bda33d3 100644 --- a/src/CodoMetis.TypeKit.AspNetCore/FaultResponsesOperationTransformer.cs +++ b/src/CodoMetis.TypeKit.AspNetCore/FaultResponsesOperationTransformer.cs @@ -9,6 +9,12 @@ using Microsoft.Extensions.Options; using Microsoft.OpenApi; using HttpJsonOptions = Microsoft.AspNetCore.Http.Json.JsonOptions; +#if NET11_0_OR_GREATER +// Microsoft.OpenApi 3, which Microsoft.AspNetCore.OpenApi 11 brings: a response's content is of the interface. +using MediaType = Microsoft.OpenApi.IOpenApiMediaType; +#else +using MediaType = Microsoft.OpenApi.OpenApiMediaType; +#endif namespace CodoMetis.TypeKit.AspNetCore; @@ -134,7 +140,7 @@ public async Task TransformAsync(OpenApiOperation operation, OpenApiOperationTra operation.Responses[key] = new OpenApiResponse { Description = Description(status, types, named.Contains(status)), - Content = new Dictionary { ["application/problem+json"] = new() { Schema = problem } }, + Content = new Dictionary { ["application/problem+json"] = new OpenApiMediaType { Schema = problem } }, }; touched = true; } @@ -174,7 +180,7 @@ private static (int Status, int Range) Rank(string key) => /// 's gets them from as well. A $ref under /// application/problem+json to a type that is no problem is left alone. Null where no content is a problem. /// - private static List? DeclaredProblems(OpenApiOperationTransformerContext context, int status, IDictionary content) + private static List? DeclaredProblems(OpenApiOperationTransformerContext context, int status, IDictionary content) { var problems = context.Description.SupportedResponseTypes .Where(declared => declared.StatusCode == status && declared.Type is { } type && typeof(ProblemDetails).IsAssignableFrom(type)) diff --git a/src/CodoMetis.TypeKit.AspNetCore/README.md b/src/CodoMetis.TypeKit.AspNetCore/README.md index 97b8d98..4c61c26 100644 --- a/src/CodoMetis.TypeKit.AspNetCore/README.md +++ b/src/CodoMetis.TypeKit.AspNetCore/README.md @@ -48,7 +48,7 @@ Calling it again for a document that already has it changes nothing. **Good to know** -- **Reference `Microsoft.AspNetCore.OpenApi` at 10.0.12 or later.** This package depends on that +- **Reference `Microsoft.AspNetCore.OpenApi` at 10.0.12 or later on .NET 10, and at 11.0.0 or later on .NET 11.** This package depends on that version, and an earlier direct reference fails to restore with NU1605 (a package downgrade). - **Reference it directly.** The switch for its source generator is imported only for a direct reference. A host that gets the package only through this one fails with CS9137 ("the feature @@ -764,9 +764,12 @@ The generated members handle the request itself: as it does for a `Guid`. - **Request and response bodies** go through the generated JSON converter. A value that a validated value object rejects becomes a `JsonException` naming the type and the rule, never the value, and a - 400. MVC puts that message in its validation problem details. A minimal API answers with an empty - 400 and logs the message, even with `AddProblemDetails()`. Adding `app.UseStatusCodePages()` gives - the response a generic problem body, which names neither the property nor the rule. + 400. MVC puts that message in its validation problem details. On ASP.NET Core 10, a minimal API + answers with an empty 400 and logs the message, even with `AddProblemDetails()`. Adding + `app.UseStatusCodePages()` gives the response a generic problem body, which names neither the + property nor the rule. On ASP.NET Core 11, a minimal API with `AddProblemDetails()` answers as MVC + does: a validation problem with that message under the property's path. Without + `AddProblemDetails()` it's still an empty 400. - **A property missing from the body isn't rejected.** System.Text.Json calls no converter for an absent property, so it stays `default`: a `Guid.Empty` order id, or a validated value object that never went through `Create`. Where a value object is required, say so. Use `required` on the diff --git a/src/CodoMetis.TypeKit.AspNetCore/ValueObjectSchemaTransformer.cs b/src/CodoMetis.TypeKit.AspNetCore/ValueObjectSchemaTransformer.cs index 6078f79..cc5347c 100644 --- a/src/CodoMetis.TypeKit.AspNetCore/ValueObjectSchemaTransformer.cs +++ b/src/CodoMetis.TypeKit.AspNetCore/ValueObjectSchemaTransformer.cs @@ -173,9 +173,44 @@ private static async Task ElementSchemaAsync(Type element, OpenA var options = context.JsonTypeInfo.Options; if (SchemaReferenceId(options.GetTypeInfo(element), context) is null) { +#if NET11_0_OR_GREATER + // Inlined over an inlined wrapped type. ASP.NET Core 11 builds the schema of a Nullable it is asked for + // from T, with no null in it, where the element of a container of the wrapped type holds its null. So + // the null goes into a copy: the schema ASP.NET returned is the one it keeps for that type. + if (SchemaReferenceId(options.GetTypeInfo(ValueObjectTypes.WrappedType(valueObject)!), context) is null) + { + var asked = await PolymorphicBaseBranch.GetOrCreateSchemaAsync(context, element, parameterDescription: null, cancellationToken); + + // A wrapped reference type has no null of its own in any position (a List is of strings). + if (!ValueObjectTypes.WrappedType(valueObject)!.IsValueType) return asked; + + var inlined = new OpenApiSchema(); + inlined.FillFrom(asked); + AdmitNull(inlined, inType: !IsParameterOutsideTheBody(context)); + NullableElements.AddOrUpdate(inlined, element); + return inlined; + } +#else // Inlined over an inlined wrapped type, the nullable value object's own schema admits null (above). if (SchemaReferenceId(options.GetTypeInfo(ValueObjectTypes.WrappedType(valueObject)!), context) is null) return await PolymorphicBaseBranch.GetOrCreateSchemaAsync(context, element, parameterDescription: null, cancellationToken); +#endif + +#if NET11_0_OR_GREATER + // Over the wrapped type's component, as the element of a parameter outside the body: ASP.NET Core 11 puts + // that element's null around it itself, after the transformers ran (MakeArrayItemsNullable), as a null-or + // where the element is a reference and into its type where it is inline. The wrapped type's element is + // the reference to its component, so this one is that component's schema too, which ASP.NET turns into + // the reference. It goes on to visit it as the nullable value object, where there is nothing to describe: + // it is the wrapped type's own. + if (IsParameterOutsideTheBody(context)) + { + var component = await PolymorphicBaseBranch.GetOrCreateSchemaAsync(context, ValueObjectTypes.WrappedType(valueObject)!, parameterDescription: null, cancellationToken); + NullableElements.AddOrUpdate(component, element); + + return component; + } +#endif // Over the wrapped type's component, the content admits null as it does over an inlined wrapped type: a // null-or around it is what OpenAPI 2.0 writes as a bare x-nullable, without the type. @@ -387,11 +422,19 @@ private static async Task DescribeAsync( } else { + schema.FillFrom(wrappedSchema); +#if NET11_0_OR_GREATER + // ASP.NET Core 11 writes the Nullable of an inlined wrapped value type it is asked for without a + // null of its own: none in its type, none among its values, in the body as outside it. A body's or + // a response's null is the null-or ASP.NET puts around it. A nullable property still holds its null + // itself, and so does the element of a container, which ElementSchemaAsync gives it. + if (position == NullablePosition.Property) AdmitNull(schema, inType: true); +#else // An inlined wrapped type admits null in its type and among its values. Outside the body ASP.NET // takes the null out of the type and leaves it among the values (a query DayOfWeek? written by // name), so it goes there alone. - schema.FillFrom(wrappedSchema); AdmitNull(schema, inType: position != NullablePosition.ParameterOutsideTheBody); +#endif } } catch (NotSupportedException unsupported) diff --git a/src/CodoMetis.TypeKit.EntityFrameworkCore/CodoMetis.TypeKit.EntityFrameworkCore.csproj b/src/CodoMetis.TypeKit.EntityFrameworkCore/CodoMetis.TypeKit.EntityFrameworkCore.csproj index 73dacbb..d5f6384 100644 --- a/src/CodoMetis.TypeKit.EntityFrameworkCore/CodoMetis.TypeKit.EntityFrameworkCore.csproj +++ b/src/CodoMetis.TypeKit.EntityFrameworkCore/CodoMetis.TypeKit.EntityFrameworkCore.csproj @@ -1,4 +1,9 @@ + + + + net10.0;net11.0 + diff --git a/src/CodoMetis.TypeKit.EntityFrameworkCore/README.md b/src/CodoMetis.TypeKit.EntityFrameworkCore/README.md index 24478f3..07aeff0 100644 --- a/src/CodoMetis.TypeKit.EntityFrameworkCore/README.md +++ b/src/CodoMetis.TypeKit.EntityFrameworkCore/README.md @@ -1,7 +1,7 @@ # CodoMetis.TypeKit.EntityFrameworkCore Use [CodoMetis.TypeKit](https://www.nuget.org/packages/CodoMetis.TypeKit) value objects in EF Core -10 with one line of setup. Every value object is stored in a plain column of its underlying type, +10 or 11 with one line of setup. Every value object is stored in a plain column of its underlying type, with nothing to register per type, and `.Value` works in a LINQ query the way it does in memory. ```bash @@ -13,9 +13,10 @@ This page is the reference for the package. For a walk through a whole model, re **Good to know** -- **It needs EF Core 10.0.12 or later.** A project that references `Microsoft.EntityFrameworkCore` - or `Microsoft.EntityFrameworkCore.Relational` directly at an earlier version fails to restore with - NU1605 (a package downgrade). Keep the EF Core packages at 10.0.12 or later. +- **It needs EF Core 10.0.12 or later on .NET 10, and EF Core 11.0.0 or later on .NET 11.** A project + that references `Microsoft.EntityFrameworkCore` or `Microsoft.EntityFrameworkCore.Relational` + directly at an earlier version fails to restore with NU1605 (a package downgrade). Raise the EF Core + packages to that version or later. - **The generators stay in your domain project.** This package recognises a value object at run time by the attribute the generators put on it. So the project that hosts the `DbContext` needs only this package and the base package. The domain project that declares the value objects references @@ -89,7 +90,7 @@ On PostgreSQL, for example, a `ulong` is a `numeric(20,0)`, which can't be an id At `Add`, a key that is generated gets the same temporary value a plain key of the underlying type gets, also where the column is of another type, such as the `decimal` that holds a `ulong`. HiLo and a -value generator of your own still come first. There are two exceptions: +value generator of your own still come first. There are three exceptions: - **A key over `char` is yours to assign.** It's never generated, on any provider, because none generates a `char` key. PostgreSQL rejects an identity on `character(1)`, SQLite an `AUTOINCREMENT` @@ -98,13 +99,20 @@ value generator of your own still come first. There are two exceptions: value, but it doesn't check that you set a meaningful one. A default key, `'\0'`, is stored as it is, and a second such row fails on the primary key. `ValueGeneratedOnAdd()` or a value generator of your own on the property still applies. -- **A default key over `ulong` can still throw at `Add`** where the column is a `decimal` (SQL +- **On EF Core 10, a default key over `ulong` can still throw at `Add`** where the column is a `decimal` (SQL Server, PostgreSQL), in two cases. One is a compiled model made with `dotnet ef dbcontext optimize --nativeaot`, which writes each column's mapping out as code and loses what gives the key a temporary `ulong`. The other is a key you configure with `ValueObjectConverter` yourself. EF's temporary value for the column is then a negative `decimal`, and converting it back throws `OverflowException`. Otherwise the key gets a temporary `ulong`, as a plain one does. In those two - cases, configure `ValueGeneratedNever()` on the key and assign it. + cases, configure `ValueGeneratedNever()` on the key and assign it. On EF Core 11 neither case + throws: the key gets its temporary `ulong` in both. +- **On EF Core 11, SQL Server's HiLo isn't chosen for a key over `ulong`.** EF Core 11 leaves TypeKit + one place to give that key its temporary `ulong`, a generator factory on the property, and SQL + Server takes such a factory before HiLo. `SaveChanges` then fails, because the column has no + identity. Clear the factory on the key and HiLo is chosen again: + `Property(o => o.Id).Metadata.SetValueGeneratorFactory((Type?)null)`. On EF Core 10 you need + nothing: HiLo comes first there. A key over a `Guid` is yours to assign, `Id = OrderId.New()` (a version 7 Guid, which sorts by creation time), and EF inserts it as given. To have EF generate it instead, configure @@ -171,6 +179,9 @@ db.Orders.Where(o => o.Tags.Any(t => t.Value == "x")); // WHERE EXISTS (SE db.Orders.OrderBy(o => o.PlacedAt); ``` +The comments are the SQL EF Core 10 writes. EF Core 11 leaves out a cast that changes nothing, so +there the query over `Tags` ends in `WHERE t.value = 'x'`. + `.Value`, `GetValue()` and `ValueOrNull()` translate to the column itself. So the underlying type's own operations work on it: `StartsWith`, arithmetic, comparisons. Use `ValueOrNull()` for an optional value object, where `.Value` would first unwrap the `Nullable`. diff --git a/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectKeyValueGenerationConvention.cs b/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectKeyValueGenerationConvention.cs index 68def30..ec432fb 100644 --- a/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectKeyValueGenerationConvention.cs +++ b/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectKeyValueGenerationConvention.cs @@ -144,11 +144,18 @@ public void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConven foreach (var property in entityType.GetDeclaredProperties()) { if (property.ValueGenerated == ValueGenerated.Never || property.GetValueGeneratorFactory() is not null) continue; - if (property.GetDefaultValueSql() is not null || property.GetComputedColumnSql() is not null) continue; - if (ValueObjectTypes.Describe(Nullable.GetUnderlyingType(property.ClrType) ?? property.ClrType) is { WrappedType: var wrapped } - && WrappedTypeValueGenerator.Generates(wrapped)) - property.Builder.HasValueGeneratorFactory(typeof(WrappedTypeValueGeneratorFactory)); + if (ValueObjectTypes.Describe(Nullable.GetUnderlyingType(property.ClrType) ?? property.ClrType) is not { WrappedType: var wrapped } + || !WrappedTypeValueGenerator.Generates(wrapped)) + continue; + + // A number gets its temporary value with a default or computed SQL value too, as the plain key does + // (a TPC key's sequence is one); a Guid or a string then gets EF's temporary value, not the provider's. + if (!WrappedTypeValueGenerator.IsTemporaryNumber(wrapped) + && (property.GetDefaultValueSql() is not null || property.GetComputedColumnSql() is not null)) + continue; + + property.Builder.HasValueGeneratorFactory(typeof(WrappedTypeValueGeneratorFactory)); } } } diff --git a/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectMapping.cs b/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectMapping.cs index 01950dd..cd8c547 100644 --- a/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectMapping.cs +++ b/src/CodoMetis.TypeKit.EntityFrameworkCore/ValueObjectMapping.cs @@ -3,6 +3,7 @@ using System.Reflection; using CodoMetis.TypeKit.CompilerServices; using CodoMetis.TypeKit.ValueObjects; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.ValueGeneration; @@ -63,6 +64,9 @@ public static ValueObjectMapping For(GeneratedValueObjectAttribute valueObject) /// public abstract bool StoresTheWrappedValue(ValueConverter converter, ValueConverter? wrappedConverter); + /// The generator the provider gives a key of the wrapped type generated on add (). + public abstract ValueGenerator WrappedTypeGenerator(DbContext context); + public RelationalTypeMapping ComposeOnto(RelationalTypeMapping wrapped) => (RelationalTypeMapping)wrapped.WithComposedConverter(Converter, jsonValueReaderWriter: ReaderWriterOver(wrapped.JsonValueReaderWriter)); @@ -70,14 +74,25 @@ private sealed class Of : ValueObjectMapping where TValueObject : IValueObject, IValueObjectMaterializer where T : notnull { +#if NET11_0_OR_GREATER + public Of() => + Converter = new ValueConverter( + ValueObjectConverter.ToProvider, + ValueObjectConverter.FromProvider); +#else public Of() => Converter = new ValueConverter( ValueObjectConverter.ToProvider, ValueObjectConverter.FromProvider, IsTemporaryNumber ? new ConverterMappingHints(valueGeneratorFactory: TemporaryNumber) : null); +#endif public override ValueConverter Converter { get; } + public override ValueGenerator WrappedTypeGenerator(DbContext context) => WrappedTypeValueGenerator.ProviderGenerator(context); + +#if !NET11_0_OR_GREATER + /// /// The types EF gives a generated property a temporary number of (RelationalValueGeneratorSelector.FindForType /// in EF Core 10), chosen by the property's type mapping: for a value object that is its own, so EF fell back to @@ -99,6 +114,7 @@ private ValueGenerator TemporaryNumber(IProperty property, IEntityType entityTyp property.GetTypeMapping().Converter?.ProviderClrType == typeof(T) ? new WrappedTypeValueGenerator(Converter, new TemporaryNumberValueGeneratorFactory().Create(property, entityType)) : new WrappedTypeValueGenerator(Converter, WrappedTypeValueGenerator.ProviderGenerator); +#endif private static readonly MethodInfo ProviderValue = ((MethodCallExpression)ValueObjectConverter.ToProvider.Body).Method; diff --git a/src/CodoMetis.TypeKit.EntityFrameworkCore/WrappedTypeValueGeneratorFactory.cs b/src/CodoMetis.TypeKit.EntityFrameworkCore/WrappedTypeValueGeneratorFactory.cs index c6e564d..61d30f4 100644 --- a/src/CodoMetis.TypeKit.EntityFrameworkCore/WrappedTypeValueGeneratorFactory.cs +++ b/src/CodoMetis.TypeKit.EntityFrameworkCore/WrappedTypeValueGeneratorFactory.cs @@ -39,13 +39,14 @@ public override ValueGenerator Create(IProperty property, ITypeBase typeBase) { ArgumentNullException.ThrowIfNull(property); - return ValueObjectTypes.Describe(Nullable.GetUnderlyingType(property.ClrType) ?? property.ClrType) is { } valueObject - && WrappedTypeValueGenerator.Generates(valueObject.WrappedType) - ? new WrappedTypeValueGenerator( - ValueObjectMapping.For(valueObject).Converter, - valueObject.WrappedType == typeof(Guid) ? WrappedTypeValueGenerator.ProviderGenerator : WrappedTypeValueGenerator.ProviderGenerator) - : throw new InvalidOperationException( - $"{property.DeclaringType.DisplayName()}.{property.Name} is no value object over a Guid or a string, so it has no generator of its wrapped type's."); + if (ValueObjectTypes.Describe(Nullable.GetUnderlyingType(property.ClrType) ?? property.ClrType) is not { } valueObject + || !WrappedTypeValueGenerator.Generates(valueObject.WrappedType)) + throw new InvalidOperationException( + $"{property.DeclaringType.DisplayName()}.{property.Name} is no value object over {WrappedTypeValueGenerator.GeneratedTypes}, so it has no generator of its wrapped type's."); + + var mapping = ValueObjectMapping.For(valueObject); + + return new WrappedTypeValueGenerator(mapping.Converter, mapping.WrappedTypeGenerator); } } @@ -63,9 +64,33 @@ public WrappedTypeValueGenerator(ValueConverter converter, ValueGenerator provid : this(converter, _ => provider) => _provider = provider; +#if NET11_0_OR_GREATER + /// + /// The wrapped types whose generator is the provider's for a key of that type: a and a + /// , whose generator the providers choose by the property's CLR type, and on EF Core 11 a + /// and a , whose temporary value EF chooses by the column's type where the + /// provider stores them as another (a decimal, a string). EF Core 11 has no factory on a type mapping, where + /// EF Core 10 took it from the converter's hints (). + /// + public static bool Generates(Type wrapped) => + wrapped == typeof(Guid) || wrapped == typeof(string) || wrapped == typeof(ulong) || wrapped == typeof(char); + + /// The types of , for a message. + public const string GeneratedTypes = "a Guid, a string, a ulong or a char"; + + /// The types of whose generated value is a temporary number, which the database replaces. + public static bool IsTemporaryNumber(Type wrapped) => wrapped == typeof(ulong) || wrapped == typeof(char); +#else /// The wrapped types whose generator the providers choose by the property's CLR type. public static bool Generates(Type wrapped) => wrapped == typeof(Guid) || wrapped == typeof(string); + /// The types of , for a message. + public const string GeneratedTypes = "a Guid or a string"; + + /// None on EF Core 10, where a number's temporary value is its type mapping's (). + public static bool IsTemporaryNumber(Type wrapped) => false; +#endif + /// EF reads it after a value is generated (ValueGenerationManager in EF Core 10). public override bool GeneratesTemporaryValues => _provider?.GeneratesTemporaryValues diff --git a/src/CodoMetis.TypeKit.Generators/README.md b/src/CodoMetis.TypeKit.Generators/README.md index b0a307d..c177977 100644 --- a/src/CodoMetis.TypeKit.Generators/README.md +++ b/src/CodoMetis.TypeKit.Generators/README.md @@ -649,7 +649,7 @@ error ends with a link to this table. CMTK1023 is the one warning: | CMTK1007 | The `{TSelf}Extensions` companion's name is taken by a declared type or by another value object's companion. | | CMTK1008 | A hand-written comparison operator, object `CompareTo` or explicit implementation of a comparison interface beside the generated ones, on the value object, a base record or an interface it implements. | | CMTK1009 | A hand-written instance constructor, including a positional record's parameter list such as `OrderId(Guid Value)`. The constructor and `Value` are generated. A static constructor is fine. | -| CMTK1010 | Declared in more than one `partial` part. Metalama 2026.1 writes the generated `ToString()` into every part, which doesn't compile. A part a source generator adds, such as a `[GeneratedRegex]` method's, doesn't count. | +| CMTK1010 | Declared in more than one `partial` part. Metalama writes the generated `ToString()` into every part, which doesn't compile. A part a source generator adds, such as a `[GeneratedRegex]` method's, doesn't count. | | CMTK1011 | A hand-written member or attribute the generators add (see "Write your own members", and for a closed set every generated member but `ToString()`, by signature, `IParsable`, `[JsonConverter]` and `[TypeConverter]`), an explicit implementation of an interface they implement, on the value object, a base record or an interface it implements, a hand-written equality (an `operator ==` or `!=` between two of the type included, which C# also reports as CS0111), a `PrintMembers` without `ToString()`, or `Create` implemented explicitly. | | CMTK1012 | Instance state besides the underlying value: a field, an auto-property, a `required` member or a field-like event, declared or inherited. Compute it from `Value`, make it static, or wrap a type that holds all of it. | | CMTK1013 | A closed set not declared `partial`. | diff --git a/src/CodoMetis.TypeKit.Generators/ValueObjectAspect.Templates.cs b/src/CodoMetis.TypeKit.Generators/ValueObjectAspect.Templates.cs index 185f65e..a967993 100644 --- a/src/CodoMetis.TypeKit.Generators/ValueObjectAspect.Templates.cs +++ b/src/CodoMetis.TypeKit.Generators/ValueObjectAspect.Templates.cs @@ -7,9 +7,6 @@ namespace CodoMetis.TypeKit.Generators; internal sealed partial class ValueObjectAspect { #pragma warning disable CS0649 // Field is never assigned to, and will always have its default value - // Metalama 2027.0 requires [Durable] (Metalama.Framework.Utilities) on this placeholder, and - // 2026.1 does not have the attribute. It is never assigned, so the upgrade adds it back as a - // one-line change. [Template] private readonly dynamic? _value; #pragma warning restore CS0649 diff --git a/src/CodoMetis.TypeKit.Generators/ValueObjectConvertibleAspect.cs b/src/CodoMetis.TypeKit.Generators/ValueObjectConvertibleAspect.cs index 170948d..069fd5d 100644 --- a/src/CodoMetis.TypeKit.Generators/ValueObjectConvertibleAspect.cs +++ b/src/CodoMetis.TypeKit.Generators/ValueObjectConvertibleAspect.cs @@ -1,3 +1,4 @@ +using System.Collections.Immutable; using Metalama.Framework.Advising; using Metalama.Framework.Aspects; using Metalama.Framework.Code; @@ -7,7 +8,7 @@ namespace CodoMetis.TypeKit.Generators; internal sealed partial class ValueObjectConvertibleAspect : TypeAspect { // The 14 typed IConvertible conversions, which share one delegation shape. - private static readonly (string MethodName, Type ReturnType)[] TypedConversionMethods = + private static readonly ImmutableArray<(string MethodName, Type ReturnType)> TypedConversionMethods = [ (nameof(IConvertible.ToBoolean), typeof(bool)), (nameof(IConvertible.ToByte), typeof(byte)), diff --git a/src/CodoMetis.TypeKit.Generators/ValueObjectJsonAspect.cs b/src/CodoMetis.TypeKit.Generators/ValueObjectJsonAspect.cs index 6fb5eb7..0aaa827 100644 --- a/src/CodoMetis.TypeKit.Generators/ValueObjectJsonAspect.cs +++ b/src/CodoMetis.TypeKit.Generators/ValueObjectJsonAspect.cs @@ -1,3 +1,4 @@ +using System.Collections.Immutable; using System.Text.Json.Serialization; using System.Text.Json.Serialization.Metadata; using CodoMetis.TypeKit.CompilerServices; @@ -53,7 +54,7 @@ internal sealed partial class ValueObjectJsonAspect : TypeAspect /// The NodaTime types with a parameterless NodaConverters property. ZonedDateTime and /// DateTimeZone are absent: they need an IDateTimeZoneProvider and cannot be resolved statically. /// - private static readonly (string TypeName, string ConverterProperty)[] NodaConverterMap = + private static readonly ImmutableArray<(string TypeName, string ConverterProperty)> NodaConverterMap = [ ("NodaTime.Instant", "InstantConverter"), ("NodaTime.LocalDate", "LocalDateConverter"), diff --git a/test/CodoMetis.TypeKit.AspNetCore.Tests/CodoMetis.TypeKit.AspNetCore.Tests.csproj b/test/CodoMetis.TypeKit.AspNetCore.Tests/CodoMetis.TypeKit.AspNetCore.Tests.csproj index 75a4479..45bf2e4 100644 --- a/test/CodoMetis.TypeKit.AspNetCore.Tests/CodoMetis.TypeKit.AspNetCore.Tests.csproj +++ b/test/CodoMetis.TypeKit.AspNetCore.Tests/CodoMetis.TypeKit.AspNetCore.Tests.csproj @@ -1,4 +1,9 @@ + + + + net10.0;net11.0 + + + + net10.0;net11.0 +