Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "1.3.0",
"version": "1.4.0",
"commands": [
"csharpier"
],
"rollForward": false
},
"dotnet-inspect": {
"version": "0.26.0",
"version": "0.27.0",
"commands": [
"dotnet-inspect"
],
"rollForward": false
},
"purview.build": {
"version": "0.8.1",
"version": "0.9.1",
"commands": [
"purview-build"
],
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Purview.BuildSdk 1.3.0 - managed file, do not edit
# Purview.BuildSdk 2.0.0 - managed file, do not edit
#
# This file is written by Purview.BuildSdk and is replaced whenever the SDK version changes. The version
# on the first line is how the SDK recognises a file it owns: a .editorconfig without that marker is
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
with:
# The shared workflow defaults to the 10.0.x SDK, which cannot build the net11.0 target this
# repository gained (NETSDK1045). Keep in sync with `sdk.version` in global.json.
dotnet-version: "11.0.100-rc.3.26522.148"
dotnet-version: "11.0.100"
run-pack: true
validate-pack: true
secrets: inherit

# Every other job builds against ProjectReferences; this one builds what ships. It packs Purview.ValueObjects to an
# isolated feed and package cache, then publishes and runs consumers that reference the package only - a Native AOT
# console, a Blazor WebAssembly app (trimmed and RunAOTCompilation, run in headless Chrome), a Blazor Server app
# and a net8.0 console - and leak-scans every bin and publish folder for compiler-host assemblies. It then proves
# and a net10.0 console - and leak-scans every bin and publish folder for compiler-host assemblies. It then proves
# every PackValidation ForbiddenContent rule rejects a package. `just smoke-packed-consumers` and
# `just verify-pack-rules` run the same locally.
packed-consumers:
Expand All @@ -36,11 +36,16 @@ jobs:
steps:
- uses: actions/checkout@v7

# The SDK from global.json, plus the .NET 8 runtime the net8.0 consumer runs on.
# The SDK global.json pins, plus the .NET 10 SDK and runtime the oldest consumer builds and runs on. The pin is
# named here rather than left to global-json-file: setup-dotnet reads a global.json whose rollForward is
# latestMajor as "the latest" and installs the LTS channel, so global-json-file alone installs 10.0.x and every
# later `dotnet` command fails with "A compatible .NET SDK was not found" for the 11.x pin.
# Keep both versions in sync with `sdk.version` in global.json.
- uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
dotnet-version: 8.0.x
dotnet-version: |
11.0.100
10.0.x

# First, before any toolchain is installed: the generator is built against the Purview.SourceGeneratorFramework
# version Directory.Packages.props pins, and the consumers use the pinned Purview.ZodSharp. Until both are on
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
release-mode: NuGet
# Keep in sync with `sdk.version` in global.json (and with .github/workflows/pr.yml).
dotnet-version: "11.0.100-rc.3.26522.148"
dotnet-version: "11.0.100"
trusted-publishing: true
# The nuget.org profile name, not the sign-in email.
nuget-user: kieronlanning
Expand Down
38 changes: 27 additions & 11 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,30 @@ a diagnostic analyzer, a code fix, tests, samples, and documentation for scalar

## Runtime project rules

- The runtime targets `net8.0;net9.0;net10.0;net11.0`, selected through `PurviewTargetFrameworkSet=All` rather
than a literal list, so the set moves with `Purview.BuildSdk`. Static abstract interface members
(`IScalarValueObject`) require a net7+ floor.
- The runtime targets `net10.0;net11.0`, selected through `PurviewTargetFrameworkSet=Supported` rather
than a literal list, so the set moves with `Purview.BuildSdk`. .NET 8 and .NET 9 were dropped at the
.NET 11 GA: they are out of support and the package's minimum is the current LTS. Static abstract
interface members (`IScalarValueObject`) require a net7+ floor, which this preserves.
- C# 15 language features are available only on the `net11.0` leg, so do not put C# 15 syntax in
generated output, which has to compile on both targets. `closed` was evaluated for
`ScalarOptionsAttribute` and is not applicable: a generic descendant's type parameter must appear in
the closed base's specification, and `ScalarAttribute<TValue>` derives from that non-generic base
(CS9383). A future fixed hierarchy can use it behind `#if NET11_0_OR_GREATER`, keeping the `net10.0`
declaration equivalent.
- A C# `union` declaration always boxes value-type cases. If the public surface ever needs a union, use
the custom non-boxing pattern (`[Union]` plus `HasValue` and `TryGetValue` overloads) rather than the
`union` keyword, and keep the net10.0 polyfill honest. No union is required by the current API: the
`Create`/`Hydrate`/`TryCreate` contract is deliberately unchanged.
- The `.NET 11` **updated memory-safety rules** stay off repo-wide (`MemorySafetyRules=0`): they are a
preview feature, the repository has no unsafe code, and the in-box System.Text.Json source generator
emits the preview `safe` modifier when they are on, which fails with `CS8652` unless every consuming
project selects `LangVersion=preview`. Runtime Async stays on (`PurviewRuntimeAsync=true`). Do not flip
either without reproving the System.Text.Json source-generated contexts on `net11.0`.
- `ScalarJsonConverterFactory` uses only reflection over `ScalarAttribute` + `Create`/`Hydrate`/constructor;
keep it free of event-sourcing dependencies.
- Keep the runtime package dependency-free (System.Text.Json is in-box for the supported TFMs).
- Purview.ZodSharp 3 ships `net10.0`/`net11.0` only. A project that references it selects
`PurviewTargetFrameworkSet=Supported`; the runtime package does not reference it and keeps `All`.
- Purview.ZodSharp 3 ships `net10.0`/`net11.0` only, the same set as the runtime. A project that
references it uses `PurviewTargetFrameworkSet=Supported`; the runtime package does not reference it.

## Trimming and Native AOT (non-negotiable)

Expand Down Expand Up @@ -116,10 +132,10 @@ a diagnostic analyzer, a code fix, tests, samples, and documentation for scalar
- Unit tests should cover domain logic, contracts, failure behavior, and regressions without external
infrastructure.
- Entity Framework Core version differences are covered by
`src/tests/ValueObjects.EFCompatibility.IntegrationTests`, which targets `net8.0` with EF Core 7, `net9.0`
with EF Core 9, and `net10.0` with EF Core 10. Add version-dependent behavior there (and, where a synthetic
reference set is enough, to `SourceGenerator.IntegrationTests`) rather than weakening generated output gated
on `IsEF8Referenced`.
`src/tests/ValueObjects.EFCompatibility.IntegrationTests`, which targets `net10.0` with EF Core 10 and
`net11.0` with EF Core 11. Add version-dependent behavior there (and, where a synthetic reference set is
enough, to `SourceGenerator.IntegrationTests`) rather than weakening generated output gated on
`IsEF8Referenced`.
- Source-generator tests assert generated code and diagnostics using the existing testing framework
(`Purview.SourceGeneratorFramework.Testing.TUnit`).

Expand All @@ -146,7 +162,7 @@ just verify-pack-rules
```

`just smoke-packed-consumers` is the packed-consumer gate (Native AOT, Blazor WebAssembly trimmed and AOT in a
headless browser, Blazor Server, net8.0, compiler-host leak scan). It needs the Native AOT toolchain, the
headless browser, Blazor Server, net10.0, compiler-host leak scan). It needs the Native AOT toolchain, the
`wasm-tools` workload and Chrome or Edge; dependency versions not yet on nuget.org restore from
`LOCAL_NUGET_FEED_PATH`. Run it when generated code, the runtime, packaging or a dependency version changes.

Expand Down Expand Up @@ -271,7 +287,7 @@ collides and the loser is whichever installed second.
`Purview.Skills.Testing`'s rule set (the Agent Skills specification: frontmatter fields, name and
description constraints, bundled links, body size). The `[InheritsTests]` attribute on that class is
load-bearing — TUnit does not walk base types during discovery, so without it the run is green and
nothing is checked. That project pins `net10.0` rather than taking the repository's `All` set,
nothing is checked. That project pins `net10.0` rather than taking the repository's `Supported` set,
because it asserts something about the repository rather than about the runtime's reach.

A relative link from one `SKILL.md` into another skill's folder is a rule violation: only a skill's
Expand Down
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,49 @@ Released versions correspond to `v<version>` GitHub releases. `package.json` is
newest heading below is the version in development. Earlier releases are listed under
[releases](https://github.com/purview-dev/value-objects/releases).

## 2.0.0-prerelease.1

A major release for the .NET 11 GA. It drops the two out-of-support target frameworks and modernises the build;
the generated API and the serialized payload shapes are unchanged.

### Breaking

- **`net8.0` and `net9.0` are no longer supported.** The runtime now targets `net10.0` (the current LTS) and
`net11.0`. A consumer on .NET 8 or .NET 9 must stay on the 1.x line. `Purview.ValueObjects` was the only
package in this repository; the source generator and code fixes still target `netstandard2.0`, so they load in
every compiler host.
- **The Entity Framework Core compatibility matrix is now EF Core 10 (`net10.0`) and EF Core 11 (`net11.0`).**
The EF Core 7 and EF Core 9 legs, and the `VO1019` suppression that the EF Core 7 leg needed, are gone. The
generated EF members are unchanged; `VO1019` is still reported for a project that references EF Core 7.
- **The packed-consumer gate's oldest consumer is now `net10.0`**, replacing the `net8.0` console.

### Changed

- **Package validation now records the dropped frameworks.** The baseline is the last stable release (1.2.3) and
`CompatibilitySuppressions.xml` suppresses only `PKV006` for `net8.0` and `net9.0`, so any future public API
regression is still a `dotnet pack` failure.
- Built and tested against Purview.BuildSdk 2.0.0, Purview.SourceGeneratorFramework 2.0.0 and
Purview.ZodSharp 3.0.0-prerelease.5 on the .NET 11 GA SDK (11.0.100), TUnit 1.81.16,
Microsoft.SourceLink.GitHub 11.0.100, and EF Core 10.0.15 and 11.0.0.
- The `net11.0` leg compiles with Runtime Async (`runtime-async=on`) and C# 15 as the default language version.
The updated memory-safety rules are deliberately left off: they are preview, this repository has no unsafe
code, and the .NET 11 System.Text.Json source generator emits the preview `safe` modifier when they are on,
which fails with CS8652 unless every consuming project also selects `LangVersion=preview`.
- The EF compatibility tests read an identifier's RFC 9562 version with `Guid.Version` (available since .NET 9)
instead of the hand-rolled nibble.

### Evaluated and not adopted

- **`closed` hierarchies.** `ScalarOptionsAttribute` is the only fixed hierarchy in the runtime, but its generic
descendant `ScalarAttribute<TValue>` cannot derive from a non-generic closed base (CS9383: the type parameter
must appear in the base specification). The API was left unchanged rather than reshaped to satisfy the
modifier. A future hierarchy with only non-generic descendants can adopt it behind
`#if NET11_0_OR_GREATER`.
- **Union types.** No union is required by the current API. The `TryCreate` contract stays the documented
`bool`/`out` shape. If a union is ever added, the `union` keyword is not suitable: it always stores
`object?` and boxes value-type cases. The public surface will use the custom non-boxing pattern
(`[Union]` with `HasValue` and `TryGetValue`) described in the C# union reference.

## 1.3.0-prerelease.2

A prerelease of fixes and guidance: no target framework is dropped and the public API only grows.
Expand Down
25 changes: 9 additions & 16 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<Project>
<PropertyGroup>
<!-- Set explicitly rather than relying on auto-detection, so projects outside src/ (samples)
also use central package management. -->
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<RoslynVersion>5.9.0</RoslynVersion>
<TUnitVersion>1.76.0</TUnitVersion>
<PurviewSGFVersion>1.2.2</PurviewSGFVersion>
<PurviewZodSharpVersion>3.0.0-prerelease.2</PurviewZodSharpVersion>
<TUnitVersion>1.83.0</TUnitVersion>
<PurviewSGFVersion>2.0.0</PurviewSGFVersion>
<PurviewZodSharpVersion>3.0.0-prerelease.6</PurviewZodSharpVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Purview.SourceGeneratorFramework" Version="$(PurviewSGFVersion)" />
<PackageVersion Include="Purview.SourceGeneratorFramework.Testing.TUnit" Version="$(PurviewSGFVersion)" />
<PackageVersion Include="Purview.ZodSharp" Version="$(PurviewZodSharpVersion)" />
<PackageVersion Include="Purview.ZodSharp.AspNetCore" Version="$(PurviewZodSharpVersion)" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.402" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="11.0.100" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(RoslynVersion)" />
Expand All @@ -25,16 +21,13 @@
<PackageVersion Include="TUnit.Core" Version="$(TUnitVersion)" />
<PackageVersion Include="TUnit.Mocks" Version="$(TUnitVersion)" />
<PackageVersion Include="TUnit.Assertions" Version="$(TUnitVersion)" />
<PackageVersion Include="Purview.Skills.Testing" Version="1.2.0" />
<PackageVersion Include="Purview.Skills.Testing" Version="2.0.0" />
<PackageVersion Include="Bogus" Version="35.6.5" />
</ItemGroup>
<ItemGroup Label="Entity Framework (test/sample only)">
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.13" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.13" />
<!-- Entity Framework Core 7's SQLite provider resolves SQLitePCLRaw 2.1.4, which has a published
advisory (GHSA-2m69-gcr7-jv3q). Central transitive pinning moves every consumer onto the
patched version that the newer providers already use. -->
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.14" />
<PackageVersion Include="SQLitePCLRaw.core" Version="2.1.14" />
<!-- The central version is EF Core 10, so every net10.0 target restores. The net11.0 leg of the
compatibility matrix pins EF Core 11 with a VersionOverride. -->
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.15" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.15" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pack *args:

# Prove the packed package works for real consumers: packs Purview.ValueObjects to an isolated feed, then publishes
# and runs a Native AOT console, a Blazor WebAssembly app (trimmed and RunAOTCompilation, run in a headless browser),
# a Blazor Server app and a net8.0 console against it, and leak-scans every output for compiler-host assemblies.
# a Blazor Server app and a net10.0 console against it, and leak-scans every output for compiler-host assemblies.
# Needs the Native AOT toolchain, the wasm-tools workload for the WebAssembly AOT step, and Chrome or Edge for the
# browser steps. Purview.ZodSharp/Purview.SourceGeneratorFramework versions not yet on nuget.org restore from
# LOCAL_NUGET_FEED_PATH (or VALUEOBJECTS_DEPENDENCY_FEED). See scripts/test-packed-consumers.ps1 for the options.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ incremental source generator produces:
dotnet add package Purview.ValueObjects
```

The package targets `net10.0` (LTS) and `net11.0`. .NET 8 and .NET 9 are no longer supported. The `net11.0`
build uses C# 15 as its default language version and compiles with Runtime Async (`runtime-async=on`); the
generated code is identical on both targets.

The package ships the runtime contracts (`[Scalar]`, `[ValueObject]`, `IValueObject`, ...), the source generator,
the diagnostic analyzer, and code fixes for the analyzer's diagnostics (for example `VO1001` offers
**Add 'partial' modifier**). There is no dependency on any event-sourcing library.
Expand Down Expand Up @@ -172,15 +176,15 @@ var result = EmailAddressSchema.Validate(EmailAddress.Create("demo@example.com")
See [ZodSharp Validation](docs/ZodSharp-Validation.md), the `src/src/ZodSharpSample` project, and
the `src/src/ZodSharp.AspNetCoreSample` project (ASP.NET Core Problem Details for a request of value objects, each
invalid member reported under its own path).
Purview.ZodSharp 3 targets `net10.0`/`net11.0` (this package still ships `net8.0`-`net11.0` and does not depend on
Purview.ZodSharp 3 targets `net10.0`/`net11.0` (this package ships the same two targets and does not depend on
it); `Purview.ZodSharp.Blazor` validates Blazor forms over value objects - see
[Trimming, Native AOT and Blazor](docs/Trimming-AOT-and-Blazor.md#blazor).

## Trimming, Native AOT and Blazor

Generated code uses no reflection, so trimmed, Native AOT and Blazor WebAssembly applications get no IL2xxx/IL3xxx
warning from it. `just smoke-packed-consumers` proves it against the packed package: a Native AOT console, a Blazor
WebAssembly app (trimmed and `RunAOTCompilation`, run in a headless browser), a Blazor Server app and a `net8.0`
WebAssembly app (trimmed and `RunAOTCompilation`, run in a headless browser), a Blazor Server app and a `net10.0`
console, all built with warnings as errors and scanned for compiler-host assemblies.

The generated Entity Framework Core mapping, JSON-column converters included, adds no warning either, though EF Core
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
'type-enum': [
2,
'always',
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test'],
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test', 'qol'],
],
},
};
Loading
Loading