Skip to content
Purview Dev logo

Source Generator Code Fixes

Preview Event Sourcing Reviewed 2026-09-05 purview-dev/event-sourcing Star on GitHub 4 aggregates azure-cosmosdb azure-storage cqrs csharp ddd dotnet event-driven event-sourcing event-store mongodb postgresql roslyn snapshots source-generator sql-server transactions

The source-generator package ships IDE code fixes alongside its diagnostics. Fixes live in a separate analyzer assembly (Purview.EventSourcing.SourceGenerator.CodeFixes) so the core Purview.EventSourcing.SourceGenerator assembly never acquires a Microsoft.CodeAnalysis.Workspaces dependency.

AssemblyContentsWorkspaces dependency
Purview.EventSourcing.SourceGeneratorIncremental generators, the analyzer, and all diagnostic descriptorsNone
Purview.EventSourcing.SourceGenerator.CodeFixesCodeFixProvider implementations that use DocumentEditor / SyntaxGeneratorYes (PrivateAssets)

Both assemblies are packed under analyzers/dotnet/cs of Purview.EventSourcing. No Workspaces assembly is shipped in the package and no Workspaces dependency flows into consumer projects. The compiler loads the code-fix assembly without instantiating its Workspaces-dependent types; the IDE activates them for code fixes.

DiagnosticFixNotes
EVENTSTORE001 (aggregate must be partial)Adds partial to the aggregate declarationTrivia, nesting, generic parameters, and accessibility preserved
EVENTSTORE101 (value object must be partial)Adds partial to the value-object declarationWorks for record structs, structs, and classes
EVENTSTORE007 (event method must be partial)Adds partial to the method
EVENTSTORE021 (schema version must be positive)Resets the version to 1Only when the version argument is explicit
EVENTSTORE022 (duplicate schema version)Moves the version to the next unused version on the aggregateOnly when the version argument is explicit

Fixes use stable equivalence keys and support Fix All where safe. No fix is offered when a correct correction is ambiguous (for example a renamed event contract or an incompatible payload change); the diagnostic message provides guidance instead.

The fixes share the diagnostic descriptors defined in the source-generator assembly via InternalsVisibleTo; no diagnostic is defined in the code-fix assembly.