Skip to content

Make JasperFx.Events.SourceGenerator flow transitively (drop DevelopmentDependency)#368

Merged
jeremydmiller merged 1 commit into
mainfrom
fix/events-sg-not-development-dependency
May 26, 2026
Merged

Make JasperFx.Events.SourceGenerator flow transitively (drop DevelopmentDependency)#368
jeremydmiller merged 1 commit into
mainfrom
fix/events-sg-not-development-dependency

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Problem

Marten 9 removed the runtime evolver fallback, so every project that defines projection types needs this source generator at compile time — including projects that reference only the Marten package.

This package is marked <DevelopmentDependency>true</DevelopmentDependency>, which NuGet consumes as PrivateAssets=all, so the analyzer never flows transitively from a package that references it (notably Marten) to that package's consumers. A consumer referencing only Marten therefore never ran the generator and hit No source-generated dispatcher found ... at DocumentStore.For() (marten#4557).

The workaround in Marten 9.0.2 (marten#4558) was to bundle a copy of this analyzer DLL inside the Marten package (analyzers/dotnet/cs). That fixed plain-Marten consumers but introduced a new failure: any project that also references this package directly now receives the analyzer from two distinct package paths (Marten's bundled copy + this package). Roslyn can't dedup analyzers by content, so AggregateEvolverGenerator runs twice and emits each projection's generated constructor + Evolve/DetermineActionAsync twice — CS0111 "already defines a member". This broke real downstream solutions whose projection-defining projects followed the documented guidance of referencing this package explicitly.

Fix

Drop DevelopmentDependency so the package flows transitively as a normal analyzer-only dependency.

  • It has no runtime surface (IncludeBuildOutput=false, no lib/), so flowing it adds nothing to consumers at runtime.
  • Because it's a single package identity, a consumer that also references it directly collapses (direct + transitive) to one analyzer path — duplicate generation / CS0111 becomes impossible.

Companion change (separate Marten PR)

Marten should stop bundling the analyzer and instead reference this package with PrivateAssets=none so it flows. That Marten change should target the release that carries this version, and bump Marten's JasperFx.Events.SourceGenerator reference accordingly.

Verification

Built two repro consumers against locally-built packages:

  • Marten only → generator flows transitively, evolver generated, clean build (fixes marten#4557).
  • Marten + explicit reference to this package → exactly one analyzer path reached csc, one evolver generated, zero CS0111, clean build.

🤖 Generated with Claude Code

…entDependency)

Marten 9 removed the runtime evolver fallback, so every project that defines
projection types needs this source generator at compile time — including projects
that reference only the Marten package.

This package was marked <DevelopmentDependency>true</DevelopmentDependency>, which
NuGet consumes as PrivateAssets=all, so the analyzer never flowed transitively from
Marten to Marten's consumers (marten#4557). The workaround there was to bundle a copy
of this analyzer DLL inside the Marten package; that in turn collides with any project
that also references this package directly — the analyzer then reaches csc from two
distinct package paths, the AggregateEvolverGenerator runs twice, and the generated
constructor + Evolve/DetermineActionAsync are emitted twice (CS0111 duplicate members).

Drop DevelopmentDependency so the package flows transitively as a normal analyzer-only
dependency. It has no runtime surface (IncludeBuildOutput=false, no lib/), so flowing it
adds nothing at runtime. As a single package identity, a consumer that also references it
directly collapses to one analyzer path, so double-loading is no longer possible.

The companion change in Marten (stop bundling the analyzer; reference this package with
PrivateAssets=none so it flows) ships separately and should target the release that
carries this version.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 536d8f9 into main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant