Skip to content

Pin the satellites to their own core version and refuse a mixed pair (#169) - #174

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/169-satellite-core-pin
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/169-satellite-core-pin

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #169

Problem

A consumer who references EFCore.ComplexIndexes.PostgreSQL 5.4.1 and EFCore.ComplexIndexes directly, and merges only the Dependabot PR for core, gets satellite 5.4.1 with core 5.5.0. Restore says nothing, because the 5.4.1 satellite declares EFCore.ComplexIndexes >= 5.4.1. The 5.4.1 differ predates IsSatelliteDiffer, so #150's check takes it for the core differ: GenerateCreateScript() and migrations add fail with "the model is diffed by the provider-agnostic core differ … call UseNpgsqlComplexIndexes()", which the consumer already calls.

The 5.5.0 satellites would have shipped the same >= 5.5.0 while binding to core internals through InternalsVisibleTo, so any later core would be accepted on a line that takes fixes until 2028.

Decision: the dependency range

Exact, [5.5.0] (written as [$(Version)], so every later version pins itself).

  • The three packages always ship together under one Version, patch releases on release/5.x included: a package with nothing in a version is still published, with "No change in this package." So an exact pin never refuses a pair that was released.
  • [5.5.0, 5.6.0) would accept core 5.5.1 under satellite 5.5.0. That is the case to keep out: a patch can change the internals a satellite binds to, and nobody builds or tests that pair. It buys nothing in return, because 5.5.1 of the satellite exists whenever 5.5.1 of the core does.
  • NuGet picks the lowest version in a range. With an exact pin there is one version, so a consumer who references only a satellite gets the core it was built with. With either range they get 5.5.0 too, so the floor is the same.

What the pin does, measured with packed packages in a consumer outside the repository (private NUGET_PACKAGES, local feeds plus nuget.org):

Consumer references Restore Run (GenerateCreateScript(), exclusion constraint, UseNpgsqlComplexIndexes())
satellite 5.5.0 only core 5.5.0, no warning renders EXCLUDE
core 5.5.0 + satellite 5.5.1 NU1605 error (downgrade) —
core 5.5.1 + satellite 5.5.0 NU1608 warning only, resolves core 5.5.1 refused by the runtime check below
core 5.5.0 + satellite 5.4.1 (nuget.org) no warning (5.4.1 declares >=) refused by the runtime check below

So the pin is not enough by itself. A direct reference beats a transitive pin with a warning, and the published 5.4.x satellites can't be changed.

Decision: the 5.4.1 combination at runtime

Refuse a mixed pair with a message that names both versions. Don't take the issue's suggestion of deciding "satellite differ" by type, which would let the 5.4.1 satellite run against 5.5.0 internals:

CustomMigrationsModelDiffer.ThrowIfSatelliteVersionDiffers runs first in GetDifferences. HasDifferences, EnsureCreated(), Migrate()'s pending-changes check and migrations add all route through GetDifferences. The check walks the differ's type hierarchy to the first type in one of the satellite assemblies listed in Satellites, and compares its informational version (without +commit) with the core's. Assemblies that aren't satellites are left alone, and so is an application's subclass of a satellite differ, which is checked by the satellite's version. The message:

EFCore.ComplexIndexes.PostgreSQL 5.4.1 is running against EFCore.ComplexIndexes 5.5.0. The satellite is built against the core's internals, and the packages are released together under one version: a mixed pair was never built or tested. Reference the same version of both, EFCore.ComplexIndexes.PostgreSQL 5.5.0 with this core.

That is the real output from the packed consumer with satellite 5.4.1 from nuget.org. The same consumer at 5.4.1 + 5.4.1 still renders EXCLUDE.

Change

  • src/Directory.Build.targets: PinProjectReferenceDependencies (before GenerateNuspec) rewrites NuGet's _ProjectReferencesWithVersions to [%(ProjectVersion)]. NuGet has no ProjectReference metadata for a range. The target fails the pack when that item doesn't hold one entry per ProjectReference, which is how a rename on NuGet's side would show; otherwise the dependency would quietly go back to >=.
  • CustomMigrationsModelDiffer: ThrowIfSatelliteVersionDiffers, called at the start of GetDifferences.
  • test/consumer-smoke-test.sh: checks that each satellite in the feed depends on EFCore.ComplexIndexes [version], so the artifacts the pack and release jobs ship are held too.
  • Changelogs (root, core, both satellites): one Packaging: line under ### Changed. It goes in core's changelog too, because the refusal is core code and the consumer who updates core alone reads core's release notes.
  • CLAUDE.md: the PackagingConventionTests row and a paragraph beside the release-notes target.
  • MigrationHarness.CreateDiffer(Type, DbContext), which BuilderApiParityTests now calls instead of reflecting over the generic overload.

Not labelled breaking: the only pair that newly fails is a mixed one, which was never supported. A 5.4.1-satellite consumer with a satellite declaration failed before as well, with the wrong advice.

Tests

  • PackagingConventionTests.Satellites_pin_the_core_to_their_own_version packs each satellite (--no-build) and reads [5.5.0] from the nuspec. Seeded: with [%(ProjectVersion)] reverted to %(ProjectVersion), it fails (5.5.0 vs [5.5.0]). With the NuGet item name broken, the pack fails: "Cannot pin the dependencies of EFCore.ComplexIndexes.PostgreSQL … expected one versioned entry per ProjectReference (1), found 0."
  • SatelliteVersionTests compiles stand-in differs with Roslyn: one in an assembly named EFCore.ComplexIndexes.PostgreSQL at 5.4.1, the same at 5.5.0, a Contoso.Migrations subclass of the core differ, and one of the real Npgsql differ. Seeded: with the ThrowIfSatelliteVersionDiffers call removed, the 5.4.1 test fails with exactly the issue's message ("… diffed by the provider-agnostic core differ … call UseNpgsqlComplexIndexes() …").
  • The smoke-test check passes on the packed feed and fails on a seeded copy of the SQL Server nupkg declaring 5.5.0.
  • The packed-consumer matrix above, run locally. dotnet ef migrations add wasn't run against the mixed pair; it reaches the same GetDifferences.
  • Unit suite: 636 passed (TestCategory!=Integration). Integration lanes are left to CI.

🤖 Generated with Claude Code

The satellites bind to the core's internals through InternalsVisibleTo, but a
ProjectReference packs as ">=", so any later core satisfied them. A consumer
who updated only a direct core reference ran a 5.4.1 satellite against core
5.5.0 with no warning, and the 5.4.1 differ, which predates IsSatelliteDiffer,
was refused as the core differ while the consumer called the satellite's
registration.

- src/Directory.Build.targets pins every ProjectReference dependency to
  [$(Version)] (PinProjectReferenceDependencies), failing the pack when NuGet's
  item no longer holds one entry per ProjectReference.
- The core differ refuses a satellite assembly built as another version than
  itself at the start of GetDifferences, naming both versions. A direct core
  reference still overrides the pin with NU1608, and the published 5.4.x
  satellites declare ">=", so the pin alone does not reach them.
- PackagingConventionTests packs each satellite and reads the dependency; the
  smoke test checks the feed it is given; SatelliteVersionTests compiles
  stand-in satellites of another version with Roslyn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working severity/medium Inconsistency or failure in a narrow scenario package/core Affects EFCore.ComplexIndexes package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL package/sqlserver Affects EFCore.ComplexIndexes.SqlServer area/release Versioning, changelogs, release wiring labels Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 9a96c53 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/169-satellite-core-pin branch October 20, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/release Versioning, changelogs, release wiring bug Something isn't working package/core Affects EFCore.ComplexIndexes package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL package/sqlserver Affects EFCore.ComplexIndexes.SqlServer severity/medium Inconsistency or failure in a narrow scenario

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A 5.4.1 satellite with core 5.5.0 is refused as the core differ; satellites accept any later core while binding to its internals

1 participant