Make JasperFx.Events.SourceGenerator flow transitively (drop DevelopmentDependency)#368
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Martenpackage.This package is marked
<DevelopmentDependency>true</DevelopmentDependency>, which NuGet consumes asPrivateAssets=all, so the analyzer never flows transitively from a package that references it (notably Marten) to that package's consumers. A consumer referencing onlyMartentherefore never ran the generator and hitNo source-generated dispatcher found ...atDocumentStore.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, soAggregateEvolverGeneratorruns twice and emits each projection's generated constructor +Evolve/DetermineActionAsynctwice —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
DevelopmentDependencyso the package flows transitively as a normal analyzer-only dependency.IncludeBuildOutput=false, nolib/), so flowing it adds nothing to consumers at runtime.CS0111becomes impossible.Companion change (separate Marten PR)
Marten should stop bundling the analyzer and instead reference this package with
PrivateAssets=noneso it flows. That Marten change should target the release that carries this version, and bump Marten'sJasperFx.Events.SourceGeneratorreference accordingly.Verification
Built two repro consumers against locally-built packages:
csc, one evolver generated, zeroCS0111, clean build.🤖 Generated with Claude Code