Migration Guide
Key Changes in 3.13.0
Mapped and nullable natural keys (#1281, marten#5813). An aggregate can map a natural key whose lookup another projection owns, with
[MappedNaturalKey<TSource>]or[NaturalKey(SourceProjection = typeof(TSource))], and a struct key can be declared asTKey?on the aggregate, a[NaturalKeySource]return type or an event property. An aggregate owns at most one key, maps any number, and every key on it has its own type. Stores support mapped keys separately: Marten 10 does. Polecat and Fisher accept the attribute but can't fetch by a mapped key yet (polecat#1131, fisher#679).Natural key setups that used to fail silently are refused when projections are registered.
InvalidProjectionExceptionfor two owned keys on one aggregate, two keys of one type, an owned key that no event sets, a non-public[NaturalKeySource]method, two sources for one event that derive the key differently, an owned key on an aggregate inside a composite projection, and a mapped key whose source isn't registered, owns no key or owns a key of another type. An explicitNaturalKeyFor()mapping clears the source method refusals.Build-time natural key diagnostics
JFXEVT010toJFXEVT017, all errors, from the source generator inJasperFx.Events. They cover the rules above, and a key type named by Wolverine's[WriteAggregate<TKey>],[ReadAggregate<TKey>],[WriteModel<TKey>],[ReadModel<TKey>]orNaturalKey = typeof(TKey)that the aggregate doesn't have, or that isTKey?.New store members for event store authors, all with defaults, so a store built against 3.12 still compiles and loads:
IEventStoreOperations.FetchForWriting<T, TId>(id, expectedVersion)fetches, then checks the version. A store should override it to check before the stream is enlisted in the session.IEventStoreOperations.FetchManyForWriting<T, TId>(ids)fetches one id at a time, afterIEventStoreOperations.AssertFetchableIdsrefuses aNullable<T>id type, a null id and a repeated id.IAggregateProjection.MappedNaturalKeyDefinitionsis empty.AggregateWriteCacheSession.OnPublished(key, aggregate)calls the existingOnPublished(key), and an override that throws no longer fails a commit that has already happened.NaturalKeyDefinitiongainsSourceProjectionType,IsMapped,SourceProjectionDefinition,LookupAggregateType,IsNullable,KeyTypeOf()andReadValue(), andProjectionGraph.AllAggregateProjections()includes composite members.- Compliance suites
MappedNaturalKeyCompliance(behind the newSupportsMappedNaturalKeys) andNaturalKeyRegistrationCompliance.
A store's aggregate types, and stream counts and lengths by aggregate type (#1282).
IEventStore.RegisteredAggregateTypes()andIEventDatabase.FetchAggregateStreamStatsAsync(AggregateStreamStatsRequest). Both default to throwingNotSupportedException; the in-memory store implements them, andAggregateStreamStatsCompliance(behindSupportsAggregateStreamStats) is the contract for the stores.
Key Changes in 3.12.1
- A composite projection rebuild that fails now throws (#1277). Rebuilding a composite projection used to return normally when a page failed and the shard ended up paused or stopped, so the rebuild looked finished when it wasn't. It now throws the shard's own failure, the same way a single-stream rebuild always has. A composite rebuild that runs out of time between pages throws
OperationCanceledException. A full rebuild never parks identities, soRebuildErrors = Parkbehaves like Pause there and throws too.
Key Changes in 3.12.0
JasperFx now depends on the .NET 11 GA packages (#1270). The net11.0 build takes
Microsoft.Extensions.*andMicrosoft.Bcl.TimeProvider11.0.0 instead of 11.0.0-rc.3, so no .NET 11 prerelease package comes in through JasperFx any more.A natural key of a type a store can't hold is refused when the projection is registered (#1272). A natural key must be an
int,longorstring, or a strong-typed identifier wrapping one of those. Anything else, aGuidfor example, used to pass validation and then fail on the first append. It now throwsInvalidProjectionExceptionat startup, naming the aggregate, the member and its type.A parked identity can carry its natural key (#1273).
ParkedIdentityhas a newNaturalKeyproperty that a store fills when it reads the parked list, andprojections parkedshows it in a new "Natural Key" column after "Identity".--identitystill takes the stream id. See Parking a Failing Identity.The extended progression write contract is restated (#1270). A state carrying a failure creates the shard's progression row at its start position when there isn't one yet; every other state only updates an existing row. This is documentation for store authors and doesn't change JasperFx's behaviour.
Key Changes in 3.11.0
Transient failures while building a projection batch are retried through the store's resilience pipeline (#1256). A batch that fails for a transient reason (a timeout, a dropped connection, a driver's transient error) is built again through a Polly pipeline the store hands the daemon (Marten and Polecat configure it with
StoreOptions.ConfigureDaemonPolly()), under every error policy, whether one slice failed or several. When the pipeline gives up, the shard pauses withIsTransient = trueso a supervisor such as Wolverine can restart it. Skip no longer retries such a batch without limit.IEventStorehas a newResiliencePipelinemember that defaults toResiliencePipeline.Empty; with the default, a transient failure pauses the shard the first time.Replaying or discarding a parked identity right after it parks no longer answers
NotParked(#1258).The extended progression row keeps the parked count current with periodic heartbeats off (#1255).
Stepping a projection from stored events keeps their DCB tags (#1254). A new
WithRecordMetadata(..., tagTypes)overload rebuilds an event's tags fromEventRecord.Tags, whose keys are the tag type's name (a table suffix is accepted too). Events created by fan-out or enrichment while stepping carry their source event's tags.
Key Changes in 3.10.0
Parking a failing projection identity (marten#6003, #1251, #1252). An async projection can now set aside the one identity whose events fail to apply, keep running for every other identity, and replay or discard the parked one later. Nothing parks unless a store or your configuration asks for it, so JasperFx's own default does not change. See Parking a Failing Identity.
Rebuilding one identity of a multi-stream projection.
RebuildIdentityAsyncnow works for a multi-stream projection that groups by stream (IdentityFromStream<TEvent>()), by tag (IdentityFromTag<TTag>()) or through the new slice index (UseSliceIndex()). One whose grouping cannot find a single identity's events is now refused withIdentityRebuildRefusal.IdentityNotFindableinstead ofNotASingleStreamProjection;RebuildIdentityByScanAsyncrebuilds those by reading the event store.New store members for event store authors.
SupportsIdentityEventSource,LoadEventsForIdentityAsync,IProjectionBatch.AppendSliceIndexandIEventDatabase.PruneSliceIndexAsync, plus the parked identity members from #1251. All have defaults, so a store built against 3.9.0 still compiles and simply does not park.
Key Changes in 3.9.0
Culture-independent names (#1246, #1248).
EqualsIgnoreCase,StartsWithIgnoreCaseandEndsWithIgnoreCasenow compare withStringComparison.OrdinalIgnoreCaseinstead of the current culture, andToTableAliaslowers with the invariant culture. On most machines nothing changes. On a machine whose culture is Turkish or Azerbaijani, an uppercaseIused to become a dotlessı. Event type names, tag table suffixes and duplicated-field column names created there with anIin the type or member name will now be spelled differently. If you ran on such a machine, map the old names with an event type alias before upgrading.Command and flag names are matched the same way in every culture (#1248). Command names, flag names and aliases are lower-cased and compared with the invariant culture, both at runtime and in the code the CLI source generator writes. On a Turkish machine, a command or flag with an
Iin its name used to miss.More of an
Evolvebody counts toward the events an aggregate fetches (#1243). The generator used to read only declaration patterns (case Foo foo:) when it built the evolver'sEventTypesfilter. A barecase Foo:, aFoo =>switch arm,case Foo when ...:and the types inside anorpattern now count too, andnot Foois still skipped. Events matched any of those ways were never fetched before, so an aggregate written that way can start seeing events it was always meant to handle. See Projection Apply Dispatch.
Key Changes in 3.8.0
Command line numbers and time spans are read with the invariant culture (#1237). Number flags and arguments,
TimeSpanquantities, and theTODAY+NandHH:mmforms of a date used the machine's culture. On a German machine1.5read as 15, on a French machine-1.5was split into three short flags, and on an Arabic machine-5threw. The decimal separator is now always.. A full date (DateTime.Parse) still uses the machine's culture. See Arguments and Flags.An
Evolveaggregate can inherit its conventional methods (#1241). When a self-aggregating type with anEvolvemethod inherits publicApply,CreateorShouldDeletemethods from a base class, the generated evolver now routes those event types to the inherited methods first, and they join the aggregate'sEventTypes. Before, those methods were never called.
Key Changes in 3.7.1
Stopping the daemon while a shard is loading a page no longer fails it (#1231). Stopping an agent now waits for its in-flight page load, and a page that arrives after the stop is dropped. This showed up as "The channel has been closed" failing a catch-up that had actually worked.
A rebuild reads the running agents after it takes the registry lock (#1233), so it can't miss an agent that started in between.
Key Changes in 3.7.0
Backfilling a new projection version from where the old one stopped (#1222).
AsyncOptions.SubscribeFromPriorVersionMark(backfillName)starts a new version of a projection where its prior version left off, at a mark stored for the named backfill. The backfill job stops at the same mark, so the live version and the backfill split history at exactly one sequence and nothing is processed twice. The jobs that run backfills live in Wolverine. A store that doesn't implement event-range marks fails the shard at startup withNotSupportedException, rather than replaying history the backfill also covers.Rewriting stored events (#1215).
EventRegistry.AddRewriteTransform<T>(name, transform)registers a named transform that a rewrite can apply to stored events, and naming one that isn't registered throwsUnknownRewriteTransformException. This rewrites history: nothing derived from the old events, like projections, natural keys or tags, is updated.New store members for event store authors, all with defaults:
IEventStore.SupportsEventRewritesandRewriteStoredEventsAsync,IEventStore.SupportsBackfillsandRunBackfillAsync, andIEventDatabase.FetchEventRangeMarkAsync,TrySetEventRangeMarkAsyncandSetEventRangeMarkAsync. The contracts areEventRangeMarkCompliance,EventRewriteComplianceandBackfillCompliance.Stopping the daemon saves the
Stoppedstatus (#1225). With extended progression on,StopAllAsync()followed straight away byDispose()left the shard's progression row sayingRunning. BothStopAllAsync()andStopAgentAsync()now wait for the status to be written, bounded byDaemonSettings.StopAndDrainTimeout.F# output leaves the AOT roots companion out (#1228), even for an assembly assembled on the C# default and rendered with
GenerateFSharpCode(). See Publishing AOT.
Key Changes in 3.6.0
New time-ordered Guids,
SequentialGuid.JasperFx.Core.SequentialGuidmakes Guids in MassTransit's NewId layout (a 100 ns timestamp, a 6-byte worker id drawn at random once per process, and a sequence) without a lock and without a random number per id. There are two sort orders, one per database:SequentialGuid.NextPostgresOrder()for PostgreSQLuuid(and SQLite, or anything that stores the id as text) andSequentialGuid.NextSqlServerOrder()for SQL Serveruniqueidentifier.SequentialGuid.PostgresOrderandSequentialGuid.SqlServerOrderare the same thing as anIGuidGeneratorto hand to something else.Appended event ids, new stream ids and dead letter ids now come from
SequentialGuid.NextPostgresOrder(). Event and stream ids were COMB Guids, andDeadLetterEventids wereGuid.CreateVersion7(). Both of those are only ordered by millisecond and random within it, and both draw from the OS random number generator on every id.A store chooses the generator for the Guid stream ids JasperFx makes up (#1220).
IEventRegistry.StreamIdGenerator(settable onEventRegistry) and the protected virtualEventOperationsBase.StreamIdGeneratorboth default toSequentialGuid.PostgresOrder. They are used byStartStreamwithout an id and by the new stream anEventBoundarystarts for an event no tag routes. A SQL Server store such as Polecat sets it toSequentialGuid.SqlServerOrder, because its stream table is keyed by a clustereduniqueidentifier. Both members have defaults, so nothing changes for a store that does not set them.CombGuidIdGeneration.NewGuid()delegates toSequentialGuid.NextPostgresOrder(). It keeps its signature and stays[Obsolete], now pointing atSequentialGuid.NewGuid(DateTimeOffset),Create()andGetTimestamp()still make and read COMB Guids, butGetTimestamp()cannot read an id fromNewGuid()any more.New ids do not sort like version 7 or COMB Guids. They start with the .NET tick count, not unix milliseconds. In PostgreSQL and SQLite every new id sorts after every existing version 7 or COMB id, so an index keeps appending at its right edge and there is nothing to migrate. Code that read a timestamp back out of these ids (
Guid.Version == 7,CombGuidIdGeneration.GetTimestamp()) has to stop doing that.IStorageOperations.LastAppendedPositionreplacesLastAppendedSequence(#1218). The 3.5.0 name holds a fullEventStorePosition(database, tenant and sequence), not a sequence.LastAppendedSequencestays as an[Obsolete]forwarder toLastAppendedPosition. A store built against 3.5.0 that implements the old name keeps working for callers of the old name, but answers null under the new one until it moves over.A paused projection on another node shows as
PausedtoWaitForProjectionsAsync()only with extended progression on. Without it the wait runs to its timeout and returnsTimedOut, which never fails the write.Rebuild one identity of a single-stream projection inside its running shard (#1201).
IProjectionDaemon.RebuildIdentityAsync(projectionName, tenantId, identity)binds the rebuild to the next batch the shard builds, re-folds that identity over its stream with side effects suppressed, and commits it with the shard's progression. A rebuild that can't run is refused before anything is written withIdentityRebuildRefusedException. Store authors get default members forSupportsIdentityRebuild,LoadEventsForIdentityRebuildAsyncandIProjectionStorage.HardDeleteById, plusIdentityRebuildGuardand theIdentityRebuildCompliancesuite. See Parking a Failing Identity.projections --advanceworks again (#1210). It advances every selected database's high water mark before a run or rebuild and reports what each mark did, and a failed advance stops before anything runs. A rebuild now covers every selected event store instead of returning after the first.StreamState.ColdVersion(#1211) is the last version of a stream in an application-owned cold store, when there is one.A slice that ends with its
Compacted<T>marker hands the marker toStoreProjectionas the last event (#1214) instead of null.
Key Changes in 3.5.0
Read your own writes from an async projection (marten#6004). After you commit, wait for the projections you care about to catch up to your events, and only your events:
csvar position = session.LastAppendedPosition; var result = await store.WaitForProjectionsAsync(position, [typeof(TripSummary)], TimeSpan.FromSeconds(5));EventStorePositionis the database, tenant and sequence of what a session committed. It's small, serializes to JSON, and has a compact text form (ToString(),Parse(),TryParse()) to carry in a header from one request to the next.WaitForProjectionsAsynctakes projection types (or the documents they write) or names, and returns aProjectionWaitResultthat saysReached,TimedOut,PausedorRebuilding, with how far each shard got. It never throws on a timeout, because a slow projection shouldn't fail a write that already succeeded. It reads the progression table, so it works from any node.IEventStore.AsyncShardNamesFor(Type)lists the shards for a projection type. 3.6.0 renamed the session member toLastAppendedPosition.projections floor(#1205) shows, pins, sets and clears a projection's start floor, for any store that implements the floor seam:bashdotnet run -- projections floor --projection Trips dotnet run -- projections floor --projection Trips --pin-current dotnet run -- projections floor --projection Trips --set 12345 dotnet run -- projections floor --projection Trips --clearShowing is the default. A write needs one projection, applies to every selected database, and asks first unless you pass
--yes.ForTenanton the shared document write operations (#1202).IDocumentWriteOperations.ForTenant(tenantId)lets store-agnostic codeInsert,UpdateandStoreas another tenant without casting to a store's session. A store that hasn't adopted it throws rather than writing to the wrong tenant.A store-wide projection lag read.
IEventStore.FetchProjectionLagAsync(token)reads the lag of every shard across every database the store has, composite members included. TheShardNameoverload narrows it to one shard.Warning
JFXEVT009for a non-public conventional handler (#1196). Generated dispatch only calls publicApply,CreateandShouldDeletemethods, so a non-public one compiled, ran and never applied its event. See Build Diagnostics.A warning when a composite member sets a shard setting the composite ignores. A composite runs as one shard built from its own options, so
BatchSize,MaximumHopperSize,EnableDocumentTrackingByIdentity,GateSideEffectsBehindPriorVersionand the starting position on a member are never read. The daemon now logs which ones once per composite.JasperFxOptions.RememberApplicationAssembly(#1204) lets a host opt out of recording and reusing the process-wide remembered application assembly, andJasperFxOptions.ResetRememberedApplicationAssembly()clears it between hosts in a test suite. See JasperFxOptions.Event modeling: which stream an emitted event goes to (#1203), with
.Emits<T>().OnStream<TAggregate>(). See Declaring the Model in Code.
Key Changes in 3.4.0
- No more broken builds from an aggregate a generated evolver can't name (#1194). For an open generic aggregate, or one nested behind
privateorprotected, the generator used to emit an evolver that didn't compile, inside a generated file you can't edit. It now emits nothing for it and reports warningJFXEVT008, unless something else in the compilation already covers the type. See Build Diagnostics.
Key Changes in 3.3.0
A
[FromKeyedServices]key that isn't a string now resolves its own registration (#1189). Codegen turned the key into a string before looking it up, so an enum key never matched and silently fell through to the last unkeyed registration of the type. Keys now match the way Microsoft's container matches them. Watch for: a keyed parameter whose key has no registration now fails codegen instead of quietly taking the unkeyed service.An aggregate's non-public parameterless constructor now runs (#1188). An aggregate whose only parameterless constructor was private, protected or internal was created without calling it, so the constructor body and every field and property initializer were skipped, and the first
Applycould throw aNullReferenceException. The generated evolver now calls that constructor through[UnsafeAccessor], which stays trim and AOT safe. If you were relying on initializers not running, they run now.IEventStoreOperations.UnArchiveStream(Guid)andUnArchiveStream(string)(marten#5476), so store-agnostic code can do whatArchivedStreamExceptiontells it to. The compliance fixture'sUnArchiveStreamhook is obsolete.IEventBinarySerializercan write into pooled buffers (#1187).Serialize(Type, object, IBufferWriter<byte>)andDeserialize(Type, ReadOnlySpan<byte>)are default members over the existingbyte[]pair, so a serializer built against 3.2 keeps working.
Key Changes in 3.2.0
- A
[BoundaryAggregate]with anIdmember also gets a string-keyed evolver (#1184). Marten builds every boundary aggregate's projection keyed by string, soFetchForWritingByTags<T>()found no dispatcher for a boundary aggregate with, say, aGuid Id.
Key Changes in 3.1.0
Runtime-async is on by default for
net11.0(#1180). Both switches described under 3.0.0 flip:- Generated code:
GenerationRules.UseRuntimeAsyncnow defaults totruein thenet11.0build (it staysfalsein thenet10.0build, where the runtime cannot load runtime-async code). Runtime-compiled code then uses runtime-async methods instead of compiler-built state machines. Opt out withGenerationRules.UseRuntimeAsync = false(Wolverine exposes it asopts.CodeGeneration.UseRuntimeAsync). - JasperFx's own assemblies: the
net11.0packages are compiled withruntime-async=on. Build with-p:JasperFxRuntimeAsync=falseto compile them without it.
Measured in Wolverine's in-process benchmark (wolverine#5542), allocations fell by 38–84% and median latency by 5–34%, depending on how often a handler suspends. Plain
net11.0without the feature changed nothing. Watch for: stack traces, debugger stepping, and APM agents or profilers that hook async state machines can behave differently with runtime-async methods. If one misbehaves, turn the generated-code switch off first.- Generated code:
StreamLockedException.StreamIds(#1172): a store whose lock covers several streams at once can report every stream that lost it. The single-stream constructor andIdare unchanged.--log-leveland--verbosewin over configured log levels (#1132). Before, aLogging:LogLevelrule bound from configuration silently overrode the flag.Extensions that defer
AddJasperFx()can hand over the registering assembly (#1179). The new overloadAddJasperFx(services, configure, registeredFrom)uses the assembly the entry point captured before it deferred (for example from anIHostBuilder.ConfigureServicescallback that runs insideBuild()), instead of walking the stack insideBuild(). Without it, a host built by a helper in another assembly was attributed to that helper andApplicationAssemblyReuseWarningfired on a healthy host. Nothing changes for callers of the existing overloads.
Key Changes in 3.0.1
- Projection side effects publish under Native AOT (#1171). Publishing a message from a projection batch compiled a delegate with FastExpressionCompiler, which Native AOT refuses, so every side effect failed and paused its shard. It now falls back to the expression interpreter where dynamic code isn't available.
Key Changes in 3.0.0
JasperFx 3.0 is the foundation of the Critter Stack .NET 11 release train, alongside Weasel 10, Marten 10, Polecat 6, Fisher 2 and Wolverine 7.
TIP
This section covers 3.0.0 itself. Everything that changed in a later 3.x release is in that release's section above, newest first.
Foundation
.NET 9 support was dropped. JasperFx 3.0 targets
net10.0;net11.0(#1039). Stay on JasperFx 2.x if you still need .NET 9. The repository builds with C# 14 (LangVersion14), and its workflows install the 11.0.x SDK beside 10.0.x. The source generator tests run onnet10.0.Runtime-async is opt-in, in two places (#1040). It only takes effect on
net11.0, running on a .NET 11 runtime with Roslyn 5.x. Onnet10.0it is ignored.- Generated code: set
GenerationRules.UseRuntimeAsync = true(defaultfalse) to compile runtime-generated code with the C# compiler'sruntime-async=onfeature, so async methods are emitted as runtime-async methods rather than compiler-built state machines. It is part of the reuse key forReuseCompiledAssemblies, so a runtime-async and a plain compilation of the same source never share an assembly.AssemblyGenerator.UseRuntimeAsyncis the same switch when you drive the generator directly. - JasperFx's own assemblies: build with
-p:JasperFxRuntimeAsync=trueto compile thenet11.0assemblies with the feature. Changing the property does not trigger a recompile, so cleanbin/andobj/between a build with it and a build without.
Nothing changes unless you opt in. 3.1.0 turns both on by default for
net11.0, see Key Changes in 3.1.0.- Generated code: set
JasperFx.RuntimeCompilermoves to 6.0.0, because it follows the same target framework change and depends on JasperFx 3.Microsoft.Extensions.*packages have a 10.0.0 floor.JasperFx.Aspire targets
net10.0;net11.0and Aspire 13.6 (#1055). TheAspire.Hostingpackages move from 13.4.6 to 13.6.4 (13.6.5 since 3.6.0, for GHSA-f7vh-h5g3-7jrh), so an AppHost that references JasperFx.Aspire moves with them.JasperFx.RuntimeCompilercompiles with Roslyn 5.9, andFastExpressionCompilermoves to 6.0, which itself dropsnetstandard2.0andnet9.0and renamesClosureInfotoCompilerContext. Neither name appears in JasperFx's public API, but code of yours that uses FastExpressionCompiler directly will meet the rename.
Testing
JasperFx.Events.ComplianceTestsdepends on xunit.v3 4.x, which runs on Microsoft.Testing.Platform 2.x. A test project that enrolls in the compliance suites has to move to xunit.v3 4.x with it, because 3.x beside platform 2.x fails at run time. Add"test": { "runner": "Microsoft.Testing.Platform" }toglobal.json, and pass a project todotnet testwith--projectrather than as a positional path.
Changed defaults
GateSideEffectsBehindPriorVersionis on by default for every event store (#1075).When a new version of a projection (
Version > 1) starts behind the highest prior version's progress during a blue/green or rolling deploy, it now catches up to that version's mark with side effects suppressed.RaiseSideEffects, raised events and published messages only fire for events the prior version never processed. Before 3.0 the new version emitted them over the whole replay, so the same messages could go out twice.- Schema effect: none. The gate reads the existing progression rows.
- Cost: each start of a
Version > 1shard reads the store's projection progress once. Projections at version 1 do not pay this, and neither do shards that subscribe from the present, which have no prior replay to gate. - Pacing: a gated shard starts normally and reports
ShardState.SideEffectsSuppressedwhile it warms up.DaemonSettings.MaxConcurrentSideEffectGateWarmupsPerDatabaselimits how many warm up at once. - Opt out: set
GateSideEffectsBehindPriorVersion = falseon the projection, or use your store's restore helper (RestoreV9Defaults()in Marten, and the Polecat 6 and Fisher 2 equivalents) to put every changed default back.
A shard that subscribes from the present used to log a warning when this was set. It now logs at
Information, since the combination is no longer one anyone chose.AsyncOptions.MaximumHopperSizenow defaults to 2 xBatchSizeinstead of a flat 5,000 (#1076).A shard that is behind keeps loading pages until it holds this many events, and those pages then wait for a write slot, so memory followed behind shards x 5,000 events however small
BatchSizewas. ShrinkingBatchSizeto save memory made that worse, because it meant more pages of prefetch per shard.- Effect: far less memory on write-bound shards at the default
BatchSizeof 500. Measured against the real agent with a simulated database, peak in-flight events fell by 77% with no measurable change in throughput. - Larger batches: the default follows
BatchSizein both directions, so aBatchSizeabove 2,500 now gets a deeper hopper than it had before. SetMaximumHopperSizeif you tuned around the old cap. - Schema effect: none.
- Opt out: set
MaximumHopperSizeexplicitly, which always wins over the derived default.MaximumHopperSize = 5000restores the old behavior.
- Effect: far less memory on write-bound shards at the default
Exceptions
StreamLockedExceptionderives fromConcurrencyException(#1169). A stream lock timeout is the same user-facing failure as an optimistic concurrency conflict (a 409, retry), so it now shares the type. Code that doescatch (ConcurrencyException)and retries also catches lock timeouts, which is usually what is wanted. Code that caughtConcurrencyExceptionand treated it as a version mismatch only should catchStreamLockedExceptionfirst.ConcurrencyException.Idcarries the stream id, andDocTypeis null.
C# 15 unions as events (net11.0)
A C# 15 union can be appended and applied as an event (#1053). Everything union-specific is
net11.0only; onnet10.0no type is a union.- Append stores the active case. Each case gets its own event type name and
IEvent<TCase>, and the stored JSON is unchanged because System.Text.Json already writes the bare case.AddEventType(union)registers every case. Apply(TUnion)is dispatched per case. A handler that takes a union listens for the union's cases, and the source generator emits one arm per case that rebuilds the union. An explicitApply(TCase)wins overApply(TUnion).- Refused shapes: a union in
Create,ShouldDelete,Project, a constructor, orIEvent<TUnion>fails validation, rather than listening for the cases and dispatching none of them. UnionTypes(IsUnion,CaseTypes,ExpandToCaseTypes,UnionCasesFor,Unwrap,Wrap) is public for stores and tools.- Store authors: an
EventGraph.BuildEventoverride that does not end inbase.BuildEventhas to callUnionTypes.Unwrapitself.
- Append stores the active case. Each case gets its own event type name and
For event store authors
The types below were lifted out of Marten, Polecat and Fisher so that each store can delete its own copy. Adopting them is expected to land in the same change as the JasperFx 3.0 pin bump: where a store keeps a type of the same name, any file importing both namespaces stops compiling with CS0104.
EventBoundary<T>andTagValueStringifierare now inJasperFx.Events.Tags(#1044).Build the boundary from
FetchForWritingByTags, and pass the sameIEventOperationsthe fetch went through, because that decides the tenant of what it appends. UnderForTenantthat means the tenant-scoped operations, not the root session's. The boundary does not enforce consistency: the store still checksLastSeenSequenceatSaveChangesAsync.Behavior that differs from the stores' own copies:
- An event routed by a tag stamps the tag's aggregate type on a stream that has none.
- On a Guid-identity store, a string or numeric tag no longer names a stream. The next tag that can name one does, and failing that the event gets its own new stream.
- On a string-identity store, any tag value names a stream, in invariant form.
- A
Guid.Emptytag value reaches the store'sAppendguard rather than being accepted. - Under Marten's
UseMandatoryStreamTypeDeclaration, an event no tag can route now throwsStreamTypeMissingExceptionatAppendOne.
EventRegistrynow owns masking rules, binary serializers, tag types and the name and alias caches (#1043).Override
AliasForrather thanAggregateAliasFor, which is now the caching wrapper around it. A store that keeps overridingAggregateAliasFormust move both alias overrides together, orAggregateTypeForandTryResolveAggregateTypecome back empty. CallRegisterDotNetTypeNameswherever you build an event mapping: stores overrideEventMappingForand never reach the base one, so this is how the name cache hears about a registration. A bareEventRegistry.AggregateTypeFornow throwsArgumentOutOfRangeExceptionon an unknown alias rather thanNotSupportedException.Until a store adopts these, it compiles with
CS0108hiding warnings and behaves as before, because its own members win. That includes masking: a store's own rules hide the base ones, so adopt this before building on the shared masking in any later lift.IEventDatabase.WaitForNonStaleProjectionDataAsynchas a default implementation (#1046).A store may delete its own and implement
RegisteredShardNames(). A store that keeps its own is unaffected. A class that needs the method public should forward toNonStaleProjectionWait.WaitAsync, not to the interface, which would recurse. The default reads the ceiling once so sustained appends cannot keep it waiting, returns at once on an empty store, and always reports expiry as aTimeoutException.ProjectionTeardownPlan.For(source)lists everything a rebuild must clear (#1046).Implement
IProjectionTableResolverto resolve it to tables. The SQL, the transaction and the tenant scoping stay in the store. The plan is the union of what the three stores each covered, and it honorsTeardownDataOnRebuildacross every data category. On a composite,falsealso covers its members, which is new: a member can still opt out on its own.DeletePublishedTypesOnTeardown = falseis honored too, where Polecat and Fisher truncated those tables anyway.ProjectionBatchBase<TSession>,MessagePublishing, and the sharedIMessageOutboxandIMessageBatchare now in JasperFx.Events (#1045).The interfaces live in
JasperFx.Events.Documents. Polecat's and Fisher's ownIMessageOutboxandIMessageBatchderive from them for one release, so existing implementers such as Wolverine's keep compiling. Move to the shared interfaces before those are removed. Pass the realShardExecutionModeto the base constructor, which has no default, and always awaitbeforeCommitas the last step before commit, even for an empty batch.EventDataMaskingBase<TSession>andStreamCompactingExecution<TSession>are now in JasperFx.Events (#1048).Implement
TryMaskas a call on your own event graph, so that this and theEventRegistrymasking lift can be adopted in either order. The*IncludingArchived*reads have to include archived events, andSupportsMaskingArchivedEventson the compliance fixture turns on the facts for them. Masking commits nothing on failure, and compaction queues its work on your session and returns whether it did, so a store that commits inside compaction can do so ontrue.Projections.StepThrough(toEvent, serializer)replaces the stores'RunProjectionAsync,RunProjectionByNameAsyncandRunMultiStreamProjectionAsyncbodies (#1049).ProjectionStateSerializerrequires both a serialize and a deserialize delegate. There is deliberately no copy delegate, because an identity function would compile and record live references. EnrollProjectionStepThroughCompliancewhen you adopt it.Session hooks and enlistment (#1052).
IDocumentSessionOperations.AddSaveListener,IDocumentWriteOperations.AddTransactionParticipantandProjectionGraph.Subscribe(IEventSubscription)throwNotSupportedExceptionuntil a store adopts them, so a hook a store does not run fails at registration rather than losing messages silently. Use oneDocumentSessionHooksper session, countHasPendingParticipantsas work, and throw from either registration on a session whose commit the store does not run. A shared participant belongs to one unit of work, unlike the stores' own, which last until dispose.The hook order is fixed: before-save, participants, then the message hook immediately before commit. After-commit runs only after a successful commit, takes no cancellation token, and runs every hook before rethrowing a failure.
session.MetadataContextexposes session metadata (#1052), includingCurrentUserName, which is the same state asLastModifiedByon all three stores. It is an accessor rather thanIDocumentSessionOperations : IMetadataContext, because inheriting makessession.TenantIdambiguous (CS0229) on every store-typed session.IEventStore.IdentityTypeForgives an aggregate's identity type, with strong types preserved (#1052).IdentityTypeForProjectedTypeanswers differently per store, so use the new member.IEventStore.StreamIdentityis answered for you from the registry, andIEventStore.FindNaturalKeyDefinitionis new.Insert<T>(T),Update<T>(T),StoreObjectsandCheckExistsAsync<T>(object)are on the shared write and read tiers (#1052).AggregateWriteCacheSessionandAggregateWriteBaseline<T>hold the aggregate write-back (#1050).Flushonly after a commit you own, and callDiscardotherwise, including on a failed save and on a transaction the caller owns. Register at the version the instance reflects, and useAdvanceonly with the instance that actually holds the newer state. CallTakeBaseline(..., 0)for a missing stream, so a stale entry cannot outlive it.IAggregateWriteCache.StoreIfNewerrefuses a write older than the existing entry (#1050). It is a default member, so custom caches keep compiling and get the guard throughTryTakeandStore. A write-back therefore reads as a take to anything counting takes. Override it if your cache can compare and swap, or if your counters matter.ScopedSubscriptionServiceWrapper<T, TOperations, TQuerySession, TSubscription>is public (#1050), so Marten and Fisher can drop their copies. Its scope now spans the store's whole run, including the commit, so a scoped service that flushes on dispose flushes after the commit.EventOperationsBaseholds the shared write surface (#1047):StartStream,Append,AppendOptimistic,AppendExclusive,FetchForWriting,FetchForExclusiveWriting,WriteToAggregateandWriteExclusivelyToAggregate.Derive from it, or implement
IEventOperationsHostif your class already has a base class, and implement the*Coreseams. The base reads no tenant and assumes no append mode, so the tenant is stamped in your seams, on the instance the call was made on. Natural-key fetches stay per store.OpenTelemetryOptionsowns oneActivitySource, named like itsMeter, and both are shared by name for the process (#1054). AnswerIEventStore.MeterandIEventStore.ActivitySourcefrom your options rather than creating your own. Derive fromOpenTelemetryOptions<TChangeSet>forExportCounterOnChangeSets, and callRecordCommitfrom your commit listener.StoreActivator<TStore, TDatabase>replaces a hand-written startup service (#1054). Global locks stay inside Weasel's per-database apply: the activator takes none of its own. UnderContinueOnFailures, leave the Weasel database atFailFastand let the activator handle the failure, because a lost lock otherwise looks like a successful migration.StrongTypedIdResolverreplaces local strong-typed id discovery (#1054). It keeps both stores' rules for class wrappers as namedStrongTypedIdStylevalues.JasperFx.PaginationholdsCursorCodec,IPagedList<T>andPagedList<T>(#1054). The v1 cursor format is unchanged for clients, and the seek predicate stays per store.ClientSideAppendPlannerholds the append decisions for client-side stores (#1051), in the newJasperFx.Events.Appendingnamespace. Supply a row per action, scoped to that action's tenant, and callPlanand thenApply.Planchanges nothing and does no I/O, so a refused batch leaves every action as it was. A stream you forget to read arrives asNotReadand is refused rather than restarting at version 1. Marten keeps its own append path.
Behavior changes
Append(stream, expectedVersion, ...)means the version of the stream after the append, on every store (#1047).Append(id, 2, e)succeeds on a stream at version 1, as Marten and Polecat have always done. This is a breaking change on Fisher and the in-memory store, which read the argument as the version before the append, so the same portable call behaved differently per store:Call Fisher before 2.0 Now Append(id, 2, e), stream at version 2Succeeds Fails with a concurrency exception. Pass 3Append(id, 2, e), stream at version 1Fails Succeeds Append(id, 0, e), stream missingCreates the stream Throws ArgumentOutOfRangeException. Pass1To migrate, add the number of events being appended to the version you were passing.
FetchForWritingandAppendOptimisticare unaffected, because neither takes this argument.FetchForWritingCompliancepins the meaning, so a store on the old reading fails it.Client-side appends are decided the same way on Polecat and Fisher (#1051), as each store adopts the planner:
- Polecat event timestamps come from the application's
TimeProviderrather than SQL Server's clock, and a caller-setIEvent.Timestampis kept. Inline projections and the stored row now agree. - Polecat no longer stamps correlation, causation, user or headers on the envelope when that
Enable*option is off. - On Fisher, a session header no longer replaces an event's own header of the same name, and events raised by a projection are not checked against the slice's version.
StartStreamwith a non-zeroExpectedVersionOnServeris refused, and under conjoined tenancy so is an event of another tenant.
- Polecat event timestamps come from the application's
Two stores in one process with the same meter name share one
Meter(#1054). This applies as soon as you take JasperFx 3.0, with no store adoption, becausenew OpenTelemetryOptions(name).Meteris now shared by name. Don't dispose it.With
ContinueOnFailures,IInitialDatano longer runs after a failed migration, and a host stopping during activation cancels rather than logging a failed migration (#1054). This takes effect as each store adoptsStoreActivator.A malformed cursor is always refused with an
ArgumentException, and a key type the codec cannot carry now fails atEncoderather than on the next request (#1054). Polecat cursors over enum keys change bytes, and were undecodable before.Stream validation is uniform on every event operations overload (#1047), before anything is read, as each store adopts the base. A stream identity that doesn't match the store's
StreamIdentitythrowsInvalidOperationException, an empty Guid or key throwsArgumentOutOfRangeException,StartStreamwith no events throwsEmptyEventStreamException, and null events throwArgumentNullException. In particular,FetchForWriting(Guid.Empty)no longer starts aGuid.Emptystream on Polecat or Fisher, andAppendOptimistic(Guid.Empty)throwsArgumentOutOfRangeExceptionrather thanNonExistentStreamException.Pre-generated code fails at startup rather than at first use (#1041).
DynamicCodeBuilder.LoadPrebuiltTypes()now throwsExpectedTypeMissingExceptionwhen the static type loader is in effect (TypeLoadMode.Static, orAutoon Native AOT) and an expected pre-built type is missing. Dynamic mode,Autowith runtime code generation, customITypeLoaders and thecodegencommands are unaffected. The text ofExpectedTypeMissingExceptionandMissingTypeExceptionchanged, so don't match on it.Stepping through a projection shows true history (#1049). A delete shows as a null state, and a failed apply no longer leaks partial changes into later steps. The typed
RunProjectionAsyncthrowsProjectionStateRoundTripExceptionfor a state the serializer cannot read back faithfully, such as a{ get; private set; }property, instead of reporting wrong values; useRunProjectionByNameAsyncfor those aggregates.ISteppableAggregation.BuildTimelinesAsyncstamps version metadata, honorsCompacted<T>, treatsHardDeleteas a delete and rethrows cancellation, and those four reach stores without any adoption.Masking and compaction fixes arrive as each store adopts the shared classes (#1048):
- Masking reaches archived streams and events. Marten and Polecat skipped them silently, so re-run masking if you relied on it for archived data.
- An event selected twice in a pass is masked once, and a pass that fails commits nothing.
ForTenantrefuses a null or empty tenant, andIncludeStreamrefusesGuid.Emptyand an empty key.- Compaction leaves a stream that folds to nothing alone, where Marten and Polecat replaced it with an empty snapshot and deleted the events.
- An archiver the store cannot call fails the compaction rather than being skipped, and compaction refuses an empty stream identity.
StreamArchivingComplianceholds every store to archived events being opt-in. The suite used to let a store return archived events fromFetchStreamAsync. It now asserts thatFetchStreamAsync,QueryRawEvents,QueryEventsAsyncandQueryEventData<T>leave them out, and that a predicate namingIEvent.IsArchivedreads them, replacing the implicit filter rather than sitting beside it. A store whoseWhere(x => x.IsArchived)still carries its defaultis_archivedterm matches nothing and fails that fact.Projection batches built on
ProjectionBatchBasepublish nothing outsideShardExecutionMode.Continuous(#1045). A rebuild or catch-up replays history, so a message from one is a second delivery of something already sent, and a re-raised event permanently grows the stream on every rebuild. Neither the message hooks nor raised events were gated consistently across the stores. This takes effect in each store once it adopts the base.FetchProjectionLagAsync: a shard with only tenant-qualified progress rows, under a store-global high-water mark, now reports those tenants' cells rather than "no row" (#1046).Masking rules against a base type now work (#1043).
AddMaskingRuleForProtectedInformation<T>(Func<T,T>)applies to events assignable toT, as theAction<T>overload always has. A replacing rule against a base type or interface used to match nothing, which left protected data in place, so re-run masking if you relied on one. The rule must return something the event type can hold, or the masking pass fails. This takes effect in each store once it adopts the shared masking.Tag registration (#1043): once Polecat and Fisher adopt it, an empty or whitespace table suffix is refused, and registering a tag type again with a different inner type throws.
Compliance suites
SingleTenantedEventSlicingCompliancewas removed (#1065), along withTallyIncrementedandTenantSlicingTally. It was marked obsolete in 2.x because it could only execute on Marten. Remove any enrollment from your store's compliance tests.
Key Changes in 2.0.0
JasperFx 2.0 is the foundation release of the Critter Stack 2026 wave. It ships in lockstep with Marten 9.0, Wolverine 6.0, Polecat 4.0, and Weasel 9.0. Most of the changes below are mechanical pin bumps + namespace adjustments; a few API shapes changed in ways that downstream code will notice.
Foundation
.NET 8 support was dropped. JasperFx 2.0 targets
net9.0andnet10.0. Stay on JasperFx 1.x if you still need .NET 8.JasperFx.RuntimeCompileris now its own NuGet package. The Roslyn-based runtime code generation pipeline was split out of the coreJasperFxpackage so applications that pre-generate code (and want to publish AOT) don't transitively pullMicrosoft.CodeAnalysis.*into their production deployment.Applications that need runtime code generation must explicitly reference the package and register the assembly generator:
xml<PackageReference Include="JasperFx.RuntimeCompiler" Version="2.0.0-alpha.2" />csharpservices.AddSingleton<IAssemblyGenerator, AssemblyGenerator>();Applications that run in
TypeLoadMode = Staticand read pre-generated code do not need the runtime compiler. Omitting it lets the linker drop the entire Roslyn graph in AOT publishes.ITypeLoaderabstraction. The codegen lifecycle behindTypeLoadModeis now driven by a polymorphicITypeLoaderinterface (AutoTypeLoader/DynamicTypeLoader/StaticTypeLoader). For most apps this is invisible —GenerationRules.TypeLoadModecontinues to select the right loader. Hosts that registered a customIAssemblyGeneratorshould switch toservices.AddRuntimeCompilation()(the supported helper that wires both the loader and the generator in one call).
Package versions
Every JasperFx-family package is at the 2.0.0 line:
| Package | 1.x | 2.0 |
|---|---|---|
JasperFx | 1.31.0 | 2.0.0-alpha.8 |
JasperFx.Events | 1.36.0 | 2.0.0-alpha.3 |
JasperFx.RuntimeCompiler | 4.5.0 | 2.0.0-alpha.2 |
JasperFx.SourceGeneration | 1.1.0 | 2.0.0-alpha.2 |
JasperFx.SourceGenerator | 1.x | 2.0.0-alpha.2 |
JasperFx.Events.SourceGenerator | 1.4.0 | 2.0.0-alpha.2 |
Note JasperFx.RuntimeCompiler's major-version jump from 4 → 2: the package was renumbered as part of the 2.0 wave to align with the rest of the JasperFx family.
Breaking API changes
IJasperFxAggregateGrouper<TId, TQuerySession>.Group parameter type tightened
#201 / #202. The events parameter is now IReadOnlyList<IEvent> instead of IEnumerable<IEvent>. Custom groupers frequently need two or more passes over the same batch (partition by type, then resolve related document IDs), and the prior IEnumerable<IEvent> gave no guarantee that re-iteration was safe.
// before (JasperFx.Events 1.x)
Task Group(TQuerySession session, IEnumerable<IEvent> events, IEventGrouping<TId> grouping);
// after (JasperFx.Events 2.0)
Task Group(TQuerySession session, IReadOnlyList<IEvent> events, IEventGrouping<TId> grouping);Update your Group implementations to the new signature; no logic change required. Defensive events.ToList() calls at the top of Group can be dropped.
The same shape applies to the lambda-form CustomGrouping(Func<TQuerySession, IReadOnlyList<IEvent>, IEventGrouping<TId>, Task>) overload on EventSlicer / JasperFxMultiStreamProjectionBase. Most lambda callers will compile unchanged thanks to type inference plus IReadOnlyList<T> : IEnumerable<T>.
OptionsDescription.Children + Sets are now properties, not fields
#203 / #236. System.Text.Json's default options walk properties only — fields are skipped unless the caller sets IncludeFields = true. Pre-2.0 the two fields were silently dropped at the JSON boundary by every downstream serializer that didn't override the default.
Source-compatible for the typical case (the field initializers carry over to the auto-property's backing field, and no internal call site reassigns either member). Only affects code that referenced the explicit field symbol via reflection or nameof(OptionsDescription.Children) in field-only contexts.
IInlineProjection<TOperations>.ApplyAsync parameter widened to IEnumerable<StreamAction>
The streams parameter was tightened from IEnumerable<StreamAction> in some early shapes and is now uniformly IEnumerable<StreamAction> across the projection hierarchy. Third-party IInlineProjection<TOperations> implementors should update the signature; if your implementation needed Count or indexed access, materialize the parameter once with .ToList() at the top of the method.
public Task ApplyAsync(TOperations operations,
IEnumerable<StreamAction> streams,
CancellationToken cancellation) { ... }SnapshotLifecycle enum moved to JasperFx.Events.Projections
#220. The enum (Inline / Async) is canonical in JasperFx.Events.Projections now; pre-2.0 each consuming product carried its own copy. If your code references Polecat.Projections.SnapshotLifecycle or Marten.Events.Projections.SnapshotLifecycle (the product-side aliases), update to JasperFx.Events.Projections.SnapshotLifecycle. The product-side wrappers are aliased for transitional source-compat where possible.
ProjectionLifecycle(theInline/Async/Liveenum passed toProjections.Add<T>(...)) moved to the sameJasperFx.Events.Projectionsnamespace for the same reason.using JasperFx.Events.Projections;covers both.
Convention-based projections are dispatched by the source generator
Conventional Apply / Create / ShouldDelete methods on a projection subclass — one that derives from SingleStreamProjection<TDoc, TId>, MultiStreamProjection<TDoc, TId>, or EventProjection — are now dispatched by the compile-time JasperFx.Events.SourceGenerator. Pre-2.0 they were dispatched by runtime reflection; in 2.0 there is no runtime reflection fallback. The convention methods must be public so the generated dispatcher can call them.
A non-public method is not an error. Under reflection it was called, and now it is skipped, so the projection compiles and runs but never applies that event. The generator reports each one as warning JFXEVT009 (#1196). The warning covers Apply / Create / ShouldDelete methods, Project / Create / Transform on an EventProjection, and single-argument event constructors on a self-aggregating type. It fires only when the member has a parameter shape the generator would dispatch if it were public. Make the member public. If it is a private helper that only happens to share the name, rename it or mark it [JasperFxIgnore]. On a type with no public handlers at all, the warning fires only when something in the same compilation names the type as an aggregate: a projection over it, a Snapshot<T>-style call, an IRefersToAggregate parameter, or [BoundaryAggregate].
public class TripProjection : SingleStreamProjection<Trip, Guid>
{
public Trip Create(IEvent<TripStarted> e) => new() { Id = e.StreamId };
public void Apply(Travel e, Trip trip) => trip.Traveled += e.TotalDistance();
}Most projections do not need to be partial. The dispatcher for an aggregation projection is emitted as a separate, file-scoped type registered through [assembly: GeneratedEvolver(...)], so it needs nothing from your declaration. This covers self-aggregating snapshot types registered via Snapshot<T> (or the single-arg SingleStreamProjection<T> / AggregateStream<T> forms) as well as SingleStreamProjection<TDoc, TId> / MultiStreamProjection<TDoc, TId> subclasses.
partial is required only where the dispatcher has to be generated into the projection class itself, which the generator reports as JFXEVT003 at build time:
- an
EventProjectionsubclass using conventional methods — its dispatcher is anApplyAsyncoverride on your class; - a generic projection, or one nested behind
private/protected, which a separate type cannot name. Every containing type has to bepartialtoo.
In 2.0 a DI-activated projection, one whose conventional methods are instance methods and which has no public parameterless constructor, needed partial too. Since 2.48.0 (#653) the generated evolver is handed the registered projection instance through its constructor, so it doesn't:
// no `partial` needed: the evolver calls Apply on the DI-built instance
public class TripProjection(ILogger<TripProjection> logger) : SingleStreamProjection<Trip, Guid>
{
public void Apply(Travel e, Trip trip) => logger.LogInformation("...");
}When a projection needs partial and does not have it, the build fails with JFXEVT003 naming the declaration that is missing the modifier. If the generator never ran at all — for instance because the project reference excludes the analyzers asset — the failure instead surfaces at projection registration:
JasperFx.Events.Projections.InvalidProjectionException:
No source-generated dispatcher found for TripProjection. Conventional
Apply/Create/ShouldDelete methods are dispatched by the compile-time
JasperFx.Events.SourceGenerator; there is no runtime fallback.Two escape hatches if the generated dispatcher is not what you want:
- Override the evolver directly. Implementing
Evolve/EvolveAsync/DetermineAction/DetermineActionAsyncbypasses the generated dispatcher — nopartialrequired. - Confirm the generator ran. It is delivered as a Roslyn analyzer and must run in the assembly that defines the aggregate type; make sure that reference does not strip the
analyzersasset, then do a clean build.
How the analyzer reaches your build is product-specific — each product's own migration guide carries the consumer-facing detail, and they do not deliver it identically. Marten ships JasperFx.Events.SourceGenerator inside the Marten NuGet package, so a plain Marten reference is enough; Marten's migration guide documents the full consumer story — the No runtime reflection fallback admonition, the public-method requirement, and the exact InvalidProjectionException site — at martendb.io/migration-guide.html#inline-lambda-projection-removal. Other consumers may deliver the generator through a different package (or require an explicit analyzer reference) — consult that product's guide. The cross-stack AOT walkthrough is Publishing AOT with JasperFx.
UnknownTenantIdException.TenantId exposed as a property
#224 / #240. The exception now carries a public read-only TenantId property so consumers can catch (UnknownTenantIdException ex) { ex.TenantId } without parsing the message string. The single-argument constructor signature is unchanged; the new property is populated automatically. Purely additive — no caller-side migration needed unless you were custom-deriving from the type.
Codegen CLI now enforces ServiceLocationPolicy per file
#227 / #239. Pre-2.0 the codegen preview / write / test CLI paths silently bypassed the AssertServiceLocationsAreAllowed hook that downstream products (Wolverine, Marten) use to enforce ServiceLocationPolicy.NotAllowed. In 2.0 those paths fail fast.
If you set ServiceLocationPolicy.NotAllowed in your host options and have lambda-factory registrations that the codegen has to resolve via IServiceProvider, the CLI now throws InvalidServiceLocationException at generation time. The fix is either:
- Switch to a constructable registration (preferred — most lambda factories can be hoisted to a constructor)
- Add an explicit allow-list entry:
opts.CodeGeneration.AlwaysUseServiceLocationFor<T>()(in Wolverine; the equivalent in your product) - Relax to
ServiceLocationPolicy.AllowedButWarn(the pre-2.0 default behavior)
ScopedContainerCreation gates await using on AsyncMode.AsyncTask
#228 / #238. Pre-2.0 the scope-creation frame emitted await using var scope = _serviceScopeFactory.CreateAsyncScope(); whenever method.AsyncMode != AsyncMode.None. That bucket includes ReturnFromLastNode and ReturnCompletedTask — both produce method declarations without the async keyword, so the emitted body was a CS4032/CS1996 compile error in those modes.
2.0 only emits await using when AsyncMode == AsyncMode.AsyncTask (the mode that produces the async ReturnType declaration); other modes fall through to a synchronous using var scope = factory.CreateScope();. Source-compatible for callers that previously hit the compile-error path (those now compile); behavior-equivalent otherwise.
AOT publishing
JasperFx 2.0 is the first version where AOT publishing is a supported posture for apps that don't need runtime code generation:
dotnet run -- codegen write # dev-time pre-generation
dotnet publish /p:PublishAot=true # production publish, Static mode, no RoslynStatus as of JasperFx 2.0.0-alpha.12 + JasperFx.Events 2.0.0-alpha.5:
JasperFx.csprojbuilds withIsAotCompatible=trueand 0 IL warnings. Every reflective surface either has precise[RequiresUnreferencedCode]/[RequiresDynamicCode]annotations or carries a[DynamicallyAccessedMembers]parameter constraint. Consumers compiling withIsAotCompatible=truesee a precise punch-list of which JasperFx APIs are trim-hostile rather than a wall of analyzer noise.JasperFx.Events.csprojalso hasIsAotCompatible=true; the annotation propagation cascade is tracked in #262 for completion.JasperFx.Core.Reflection.CloseAndBuildAs<T>overloads carry[RequiresDynamicCode]+[RequiresUnreferencedCode]. The AOT-friendly replacement for hot paths isJasperFx.Core.Reflection.GenericFactoryCache— a delegate cache keyed on type arguments. Consumers source-generate the per-type delegate factory and stay clean.JasperFx.RuntimeCompiler.AssemblyGeneratorcarries both attributes at the class level. Don't reference the package or callservices.AddRuntimeCompilation()in your production publish — letting the trimmer drop the entireMicrosoft.CodeAnalysis.*graph is the whole point of the package split.DynamicTypeLoadercarries both attributes;StaticTypeLoaderis AOT-safe by construction.JasperFx.CommandLineis annotated as a dev-time CLI surface. AOT consumers route command discovery through theJasperFx.SourceGenerator-emittedDiscoveredCommandsmanifest, which is read at runtime by string lookup and survives trimming.
For the full end-to-end walkthrough — package references, csproj configuration, dev-time + publish-time workflow, the WarningsAsErrors policy, smoke-test verification, and the cross-stack AOT story — see Publishing AOT with JasperFx.
Internal changes worth noting
These don't break the public API but show up in behavior that users have asked about:
- Deterministic codegen ordering (#196). Pre-generated source files are byte-identical across runs, making them a reliable build artifact for source-control commit and AOT publishing. Pre-2.0
ImHashMapenumeration order varied across processes because of randomized string/type hash codes. RecentlyUsedCachethread-safety + deterministic LRU (#226, #231). The cache'sStorefield-level update is now serialised, and LRU eviction uses a strictly-increasinglong _tickcounter instead ofDateTimeOffset.UtcNow(which had sub-µs ties on tight Store loops).AssemblyGeneratortolerates missing referenced assemblies (#188). Oracle.ManagedDataAccess.Core lists six platform-conditional satellites of which a given deployment typically pulls in zero or one. Pre-2.0 a missing satellite aborted the parent assembly's reference setup and surfaced as cascading runtime-compile failures; 2.0 skips and continues.- Package metadata (#221, #222). The deprecated
PackageIconUrlis replaced with the modernPackageIcon+ embeddedlogo.jpg;PackageReadmeFilepacks each project's per-package README into its.nupkg.
Dependency lockstep
JasperFx 2.0 ships with the rest of the Critter Stack 2026 wave. Supported pairings:
| JasperFx | JasperFx.Events | JasperFx.RuntimeCompiler | Marten | Wolverine | Polecat | Weasel |
|---|---|---|---|---|---|---|
| 2.0 | 2.0 | 2.0 | 9.0 | 6.0 | 4.0 | 9.0 |
Mixing major versions across products is unsupported in this wave (the dedup work moves abstractions between assemblies and ABI-binds them to specific majors). If you upgrade JasperFx to 2.0, plan to upgrade Marten / Wolverine / Polecat to their respective 2026-wave majors at the same time.
