diff --git a/Directory.Packages.props b/Directory.Packages.props
index bd55253198..027584ef8b 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -19,7 +19,6 @@
allruntime; build; native; contentfiles; analyzers; buildtransitive
-
diff --git a/docs/configuration/aot-publishing.md b/docs/configuration/aot-publishing.md
index 6b57680d83..9d7cd390ba 100644
--- a/docs/configuration/aot-publishing.md
+++ b/docs/configuration/aot-publishing.md
@@ -42,7 +42,7 @@ Marten's storage / projection / compiled-query surfaces all build their dispatch
- **No `dotnet run -- codegen write` step.** If you have an `Internal/Generated/` folder committed from a pre-9.0 Marten app, delete it and remove it from `.gitignore`. Nothing reads or writes those files.
- **No `services.AddRuntimeCompilation()` call.** PR [#4461](https://github.com/JasperFx/marten/pull/4461) ripped out the runtime-codegen seam entirely. Don't add it back.
-- **`StoreOptions.GeneratedCodeMode`, `AllowRuntimeCodeGeneration`, `SourceCodeWritingEnabled`, `GeneratedCodeOutputPath`** are kept on the API surface as `[Obsolete]` no-ops so existing bootstrapping compiles unchanged. Setting them has no effect in Marten 9 — they're documented for source-compatibility only.
+- **`StoreOptions.GeneratedCodeMode`, `AllowRuntimeCodeGeneration`, `SourceCodeWritingEnabled`, `GeneratedCodeOutputPath`** have been deleted entirely — references to them will fail to compile against Marten 9.0. Remove any leftover assignments from your bootstrapping. `StoreOptions.ApplicationAssembly` survives because `AutoRegister` and `TryUseSourceGeneratedDiscovery` still use it as a scan hint.
If you have a Wolverine app sitting next to your Marten app in the same composition root, the Wolverine side **does** still use the JasperFx two-phase model — Wolverine retains runtime codegen as an opt-in seam ([per the 2026 plan](https://github.com/JasperFx/jasperfx/issues/217)). The JasperFx guide is the authoritative reference for the Wolverine half of that story.
diff --git a/docs/configuration/cli.md b/docs/configuration/cli.md
index b2768f312a..d817b31cb4 100644
--- a/docs/configuration/cli.md
+++ b/docs/configuration/cli.md
@@ -130,16 +130,11 @@ dotnet run -- db-dump -d Marten ./marten.sql
### Codegen
::: warning Marten 9.0
-Marten 9.0 retired the Roslyn-driven runtime code-generation pipeline (`JasperFx.RuntimeCompiler`).
-The `codegen` family of subcommands is still exposed by the shared JasperFx CLI for other
-Critter-Stack tools, but it has no Marten artifacts to write or compare against — every
-document-storage, event-storage, compiled-query, and secondary-store surface ships as
-hand-written, closed-shape code or as `Marten.SourceGenerator`-emitted output under `obj/`.
-
-Existing applications that committed an `Internal/Generated/` folder pre-9.0 should delete it
-and remove it from `.gitignore`; nothing reads or writes those files anymore. See
-[Runtime code generation removed](/migration-guide#runtime-code-generation-removed) for the
-full migration story.
+Marten 9.0 completely removed its runtime code-generation pipeline (PR [#4461](https://github.com/JasperFx/marten/pull/4461)). **`dotnet run -- codegen write` is no longer necessary for Marten** — there are no Marten artifacts to write or pre-generate. If you committed an `Internal/Generated/` folder pre-9.0, delete it and remove it from `.gitignore`; nothing reads or writes those files anymore.
+
+The `codegen` family of subcommands is still surfaced by the shared JasperFx CLI for other Critter-Stack tools (Wolverine, for example), so the command itself may still run successfully against a host that registers those tools. It just won't do anything on Marten's behalf.
+
+See [Runtime code generation removed](/migration-guide#runtime-code-generation-removed) for the full migration story.
:::
## Outside the Dotnet CLI
diff --git a/docs/configuration/hostbuilder.md b/docs/configuration/hostbuilder.md
index 3f156707bc..c62b4f3a02 100644
--- a/docs/configuration/hostbuilder.md
+++ b/docs/configuration/hostbuilder.md
@@ -99,11 +99,10 @@ services.AddMarten(opts =>
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
Lastly, if you prefer, you can pass a Marten `StoreOptions` object to `AddMarten()` like this example:
@@ -123,11 +122,10 @@ services.AddMarten(options);
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
## Using NpgsqlDataSource
@@ -152,7 +150,7 @@ services.AddMarten()
.UseLightweightSessions()
.UseNpgsqlDataSource();
```
-snippet source | anchor
+snippet source | anchor
If you're on .NET 8 (and above), you can also use a dedicated [keyed registration](https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8#keyed-di-services). This can be useful for scenarios where you need more than one data source registered:
@@ -168,7 +166,7 @@ services.AddMarten()
.UseLightweightSessions()
.UseNpgsqlDataSource(dataSourceKey);
```
-snippet source | anchor
+snippet source | anchor
## Using a Multi-Host Data Source
@@ -194,7 +192,7 @@ services.AddMarten(x =>
.UseLightweightSessions()
.UseNpgsqlDataSource();
```
-snippet source | anchor
+snippet source | anchor
::: warning
@@ -269,7 +267,7 @@ public interface IConfigureMarten
void Configure(IServiceProvider services, StoreOptions options);
}
```
-snippet source | anchor
+snippet source | anchor
You could alternatively implement a custom `IConfigureMarten` (or `IConfigureMarten where T : IDocumentStore` if you're working with multiple databases class like so:
@@ -333,7 +331,7 @@ public interface IAsyncConfigureMarten
ValueTask Configure(StoreOptions options, CancellationToken cancellationToken);
}
```
-snippet source | anchor
+snippet source | anchor
As an example from the tests, here's a custom version that uses the Feature Management service:
@@ -435,7 +433,7 @@ public class CustomSessionFactory: ISessionFactory
}
}
```
-snippet source | anchor
+snippet source | anchor
To register the custom session factory, use the `BuildSessionsWith()` method as shown in this example:
@@ -458,11 +456,10 @@ services.AddMarten(opts =>
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
The session factories can also be used to build out and attach custom `IDocumentSessionListener` objects or replace the logging as we'll see in the next section.
@@ -484,7 +481,7 @@ public interface ISession
Guid CorrelationId { get; set; }
}
```
-snippet source | anchor
+snippet source | anchor
And a custom Marten session logger to add the correlation identifier to the log output like this:
@@ -544,7 +541,7 @@ public class CorrelatedMartenLogger: IMartenSessionLogger
}
}
```
-snippet source | anchor
+snippet source | anchor
Now, let's move on to building out a custom session factory that will attach our correlated marten logger to sessions being resolved from the IoC container:
@@ -584,7 +581,7 @@ public class ScopedSessionFactory: ISessionFactory
}
}
```
-snippet source | anchor
+snippet source | anchor
Lastly, let's register our new session factory, but this time we need to take care to register the session factory as `Scoped` in the underlying container so we're using the correct `ISession` at runtime:
@@ -606,11 +603,10 @@ services.AddMarten(opts =>
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
::: tip
@@ -645,7 +641,7 @@ public interface IInvoicingStore : IDocumentStore
}
```
-snippet source | anchor
+snippet source | anchor
A couple notes on the interface:
@@ -683,15 +679,14 @@ using var host = Host.CreateDefaultBuilder()
.InitializeWith(new DefaultDataSet());
// In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
+ // automatic database migrations
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
}).StartAsync();
```
-snippet source | anchor
+snippet source | anchor
At runtime we can inject an instance of our new `IInvoicingStore` and work with it like any other
@@ -721,7 +716,7 @@ public class InvoicingService
}
}
```
-snippet source | anchor
+snippet source | anchor
### Session Configuration for Ancillary Stores
@@ -756,7 +751,7 @@ using var host = Host.CreateDefaultBuilder()
// .BuildSessionsWith();
}).StartAsync();
```
-snippet source | anchor
+snippet source | anchor
You can resolve the keyed `ISessionFactory` for an ancillary store directly from the DI container if needed:
diff --git a/docs/configuration/optimized_artifact_workflow.md b/docs/configuration/optimized_artifact_workflow.md
index c0e71123e5..2eb7f6ee1d 100644
--- a/docs/configuration/optimized_artifact_workflow.md
+++ b/docs/configuration/optimized_artifact_workflow.md
@@ -10,13 +10,9 @@ let developers just get things done without having to spend a lot of time fiddli
scripts or ORM configuration. To that end, the default configuration for Marten is optimized for
immediate developer productivity:
-
-
```cs
var store = DocumentStore.For("connection string");
```
-snippet source | anchor
-
In the configuration above, as needed, behind the scenes Marten is checking the
underlying database to see whether the existing database schema matches the
@@ -30,15 +26,7 @@ database migrations require a little bit of in-memory locking in the Marten
code that has been problematic for folks using Marten from Blazor.
::: tip Marten 9.0
-The Roslyn runtime code-generation path and the `TypeLoadMode` switch that
-controlled it were retired in Marten 9.0. The closed-shape document storage
-hierarchy, the source generator for compiled queries (with a reflection-built
-fallback), and a small `System.Reflection.Emit` shim for secondary stores
-replace what `JasperFx.RuntimeCompiler` used to handle. `StoreOptions.GeneratedCodeMode`,
-`StoreOptions.ApplicationAssembly`, `StoreOptions.SourceCodeWritingEnabled`, and
-`StoreOptions.GeneratedCodeOutputPath` are still on the surface for source-
-compatibility but are no-ops. `CritterStackDefaults` still controls the
-`ResourceAutoCreate` half of the per-environment workflow.
+The Roslyn runtime code-generation path was completely removed in Marten 9.0 (PR [#4461](https://github.com/JasperFx/marten/pull/4461)). The `StoreOptions.GeneratedCodeMode`, `StoreOptions.SourceCodeWritingEnabled`, `StoreOptions.GeneratedCodeOutputPath`, and `StoreOptions.AllowRuntimeCodeGeneration` properties have been **deleted** — remove any references to them from your bootstrapping. If you have an `Internal/Generated/` folder committed from a pre-9.0 Marten app, delete it and remove it from `.gitignore` — nothing reads or writes those files anymore. `CritterStackDefaults` still controls the `ResourceAutoCreate` half of the per-environment workflow, which is the remaining concern this page covers.
:::
To allow for maximum developer productivity while using more efficient production
@@ -51,8 +39,6 @@ options and how `ResourceAutoCreate` is resolved from `JasperFxOptions`, see the
[JasperFx shared libraries documentation](https://shared-libs.jasperfx.net/).
:::
-
-
```cs
using var host = await Host.CreateDefaultBuilder()
.ConfigureServices(services =>
@@ -60,20 +46,15 @@ using var host = await Host.CreateDefaultBuilder()
services.AddMarten("connection string");
// In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
+ // automatic database migrations.
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
}).StartAsync();
```
-snippet source | anchor
-
-The `GeneratedCodeMode` line in that sample is a no-op in Marten 9.0 — it's
-retained only so existing application bootstrapping compiles unchanged. The
-effective behavior per environment is now driven entirely by `ResourceAutoCreate`:
+The effective behavior per environment is driven entirely by `ResourceAutoCreate`:
* In `Development`: `StoreOptions.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate` to detect and apply database schema migrations as needed.
* In `Production`: `StoreOptions.AutoCreateSchemaObjects = AutoCreate.None` to short-circuit any kind of automatic database change detection and migration at runtime. This is also a minor performance optimization that sidesteps potential locking issues.
diff --git a/docs/configuration/storeoptions.md b/docs/configuration/storeoptions.md
index 60fb8636fb..2076d9692d 100644
--- a/docs/configuration/storeoptions.md
+++ b/docs/configuration/storeoptions.md
@@ -15,7 +15,7 @@ public static DocumentStore For(Action configure)
return new DocumentStore(options);
}
```
-snippet source | anchor
+snippet source | anchor
The major parts of `StoreOptions` are shown in the class diagram below:
@@ -211,7 +211,7 @@ public class ConfiguresItself
}
}
```
-snippet source | anchor
+snippet source | anchor
The `DocumentMapping` type is the core configuration class representing how a document type is persisted or
@@ -235,7 +235,7 @@ public class ConfiguresItselfSpecifically
}
}
```
-snippet source | anchor
+snippet source | anchor
## Document Policies
@@ -337,5 +337,5 @@ var store = DocumentStore.For(_ =>
_.NameDataLength = 100;
});
```
-snippet source | anchor
+snippet source | anchor
diff --git a/docs/devops/devops.md b/docs/devops/devops.md
index b89085cfaf..755e3953b1 100644
--- a/docs/devops/devops.md
+++ b/docs/devops/devops.md
@@ -78,14 +78,16 @@ Of course, it is fully up to you how you want to configure grate or if you want
## Application project set-up
-How you set-up your csproj is all up to you, but for this example you'll need to opt into the JasperFx command line execution that is bundled
-with Marten so we can export migrations to the migration project in a later step and pre generate code. To that end, the latest line in your `program.cs` needs to be:
+How you set-up your csproj is all up to you, but for this example you'll need to opt into the JasperFx command line execution that is bundled
+with Marten so we can export migrations to the migration project in a later step. To that end, the latest line in your `program.cs` needs to be:
```cs
return await app.RunJasperFxCommands(args);
```
-The dockerfile will include a step that writes the generated code by executing `dotnet run -- codegen write`.
+::: tip Marten 9.0
+Pre-Marten-9.0 versions of this guide ran `dotnet run -- codegen write` inside the build stage to pre-generate runtime code. Marten 9.0 removed its Roslyn runtime code-generation pipeline entirely (PR [#4461](https://github.com/JasperFx/marten/pull/4461)), so the step is no longer needed for Marten. If you still use Wolverine or another JasperFx-family tool that ships its own codegen, see the equivalent guidance in those projects' DevOps docs.
+:::
```dockerfile
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
@@ -99,7 +101,6 @@ COPY ["Application/Application.csproj", "Application/"]
COPY . .
WORKDIR "/src/Application"
-RUN dotnet run -- codegen write
RUN dotnet publish "Application.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS runtime
diff --git a/docs/diagnostics.md b/docs/diagnostics.md
index 2a3d2bc7a7..ebb2297aa2 100644
--- a/docs/diagnostics.md
+++ b/docs/diagnostics.md
@@ -365,7 +365,7 @@ var store = DocumentStore.For(_ =>
_.Logger(new ConsoleMartenLogger());
});
```
-snippet source | anchor
+snippet source | anchor
You can also directly apply a session logger to any `IQuerySession` or `IDocumentSession` like this:
@@ -377,7 +377,7 @@ using var session = store.LightweightSession();
// Replace the logger for only this one session
session.Logger = new RecordingLogger();
```
-snippet source | anchor
+snippet source | anchor
The session logging is a different abstraction specifically so that you _could_ track database commands issued per session. In effect, my own shop is going to use this capability to understand what HTTP endpoints or service bus message handlers are being unnecessarily chatty in their database interactions. We also hope that the contextual logging of commands per document session makes it easier to understand how our systems behave.
diff --git a/docs/documents/identity.md b/docs/documents/identity.md
index 5ce1c6d233..68f105d1fa 100644
--- a/docs/documents/identity.md
+++ b/docs/documents/identity.md
@@ -260,16 +260,9 @@ A custom ID generator strategy should implement [IIdGeneration](https://github.c
public class CustomIdGeneration : IIdGeneration
{
public bool IsNumeric { get; } = false;
- public void GenerateCode(GeneratedMethod assign, DocumentMapping mapping)
- {
- var document = new Use(mapping.DocumentType);
- assign.Frames.Code($"_setter({{0}}, \"newId\");", document);
- assign.Frames.Code($"return {{0}}.{mapping.CodeGen.AccessId};", document);
- }
-
}
```
-snippet source | anchor
+snippet source | anchor
The `Build()` method should return the actual `IdGenerator` for the document type, where `T` is the type of the Id field.
@@ -295,7 +288,7 @@ It is also possible define a custom id generation algorithm for a specific docum
```cs
options.Schema.For().IdStrategy(new CustomIdGeneration());
```
-snippet source | anchor
+snippet source | anchor
## Strong Typed Identifiers
@@ -337,7 +330,7 @@ public readonly struct Task2Id
public static Task2Id From(Guid value) => new Task2Id(value);
}
```
-snippet source | anchor
+snippet source | anchor
In _all_ cases, the type name will have to be suffixed with "Id" (and it's case sensitive) to be considered by Marten to be
@@ -367,7 +360,7 @@ public class Invoice
public string Name { get; set; }
}
```
-snippet source | anchor
+snippet source | anchor
The usage of our `Invoice` document is essentially the same as a document type with the primitive identifier types:
@@ -394,7 +387,7 @@ public async Task update_a_document_smoke_test()
loaded.Name.ShouldBeNull("updated");
}
```
-snippet source | anchor
+snippet source | anchor
::: tip
@@ -515,7 +508,7 @@ public async Task include_a_single_reference()
list.Single().Id.ShouldBe(teacher.Id);
}
```
-snippet source | anchor
+snippet source | anchor
* Within LINQ `Where()` clauses
diff --git a/docs/documents/sessions.md b/docs/documents/sessions.md
index 778c00bc71..801ee062dc 100644
--- a/docs/documents/sessions.md
+++ b/docs/documents/sessions.md
@@ -327,7 +327,7 @@ public void ConfigureCommandTimeout(IDocumentStore store)
}
}
```
-snippet source | anchor
+snippet source | anchor
## Unit of Work Mechanics
diff --git a/docs/documents/storage.md b/docs/documents/storage.md
index d052d8e7a2..10096f749d 100644
--- a/docs/documents/storage.md
+++ b/docs/documents/storage.md
@@ -55,7 +55,7 @@ public class Customer
[Identity] public string Name { get; set; }
}
```
-snippet source | anchor
+snippet source | anchor
## Type Aliases
diff --git a/docs/events/appending.md b/docs/events/appending.md
index b892ab3655..dafe2eb464 100644
--- a/docs/events/appending.md
+++ b/docs/events/appending.md
@@ -144,7 +144,7 @@ session.Events.Append(id, joined, departed);
await session.SaveChangesAsync();
```
-snippet source | anchor
+snippet source | anchor
## Mandatory Stream Types
diff --git a/docs/events/multitenancy.md b/docs/events/multitenancy.md
index 5cc00562a9..509a1aa81f 100644
--- a/docs/events/multitenancy.md
+++ b/docs/events/multitenancy.md
@@ -31,7 +31,7 @@ Let's start with a possible implementation of a single stream projection:
```cs
-public class SpecialCounterProjection: SingleStreamProjection
+public partial class SpecialCounterProjection: SingleStreamProjection
{
public void Apply(SpecialCounter c, SpecialA _) => c.ACount++;
public void Apply(SpecialCounter c, SpecialB _) => c.BCount++;
@@ -48,7 +48,7 @@ Or this equivalent, but see how I'm explicitly registering event types, because
```cs
-public class SpecialCounterProjection2: SingleStreamProjection
+public partial class SpecialCounterProjection2: SingleStreamProjection
{
public SpecialCounterProjection2()
{
diff --git a/docs/events/optimizing.md b/docs/events/optimizing.md
index 6aebc8796b..461f871c6a 100644
--- a/docs/events/optimizing.md
+++ b/docs/events/optimizing.md
@@ -62,7 +62,7 @@ like so:
```cs
-public class DayProjection: MultiStreamProjection
+public partial class DayProjection: MultiStreamProjection
{
public DayProjection()
{
diff --git a/docs/events/projections/composite.md b/docs/events/projections/composite.md
index fa7c0213e8..84d2badb46 100644
--- a/docs/events/projections/composite.md
+++ b/docs/events/projections/composite.md
@@ -90,7 +90,7 @@ First, let's just look at the simple `ProviderShiftProjection`:
```cs
-public class ProviderShiftProjection: SingleStreamProjection
+public partial class ProviderShiftProjection: SingleStreamProjection
{
public ProviderShiftProjection()
{
@@ -169,7 +169,7 @@ ultimately need to use the build products of all three upstream projections:
```cs
-public class AppointmentDetailsProjection: MultiStreamProjection
+public partial class AppointmentDetailsProjection: MultiStreamProjection
{
public AppointmentDetailsProjection()
{
@@ -367,7 +367,7 @@ And also the definition for the downstream `BoardSummary` view:
```cs
-public class BoardSummaryProjection: MultiStreamProjection
+public partial class BoardSummaryProjection: MultiStreamProjection
{
public BoardSummaryProjection()
{
diff --git a/docs/events/projections/conventions.md b/docs/events/projections/conventions.md
index 220cd569bd..5c38f84f5f 100644
--- a/docs/events/projections/conventions.md
+++ b/docs/events/projections/conventions.md
@@ -64,7 +64,7 @@ public class Trip
internal bool ShouldDelete(VacationOver e) => Traveled > 1000;
}
```
-snippet source | anchor
+snippet source | anchor
Or finally, you can use a method named `Create()` on a projection type as shown in this sample:
@@ -96,14 +96,12 @@ public partial class TripProjection: SingleStreamProjection
return new Trip { Id = started.StreamId, StartedOn = started.Data.Day, Active = true };
}
- // ShouldDelete method-convention overloads — replace the pre-9.0
- // DeleteEvent() / DeleteEvent(predicate) constructor helpers.
public bool ShouldDelete(TripAborted _) => true;
public bool ShouldDelete(Breakdown e) => e.IsCritical;
public bool ShouldDelete(VacationOver _, Trip trip) => trip.Traveled > 1000;
}
```
-snippet source | anchor
+snippet source | anchor
The `Create()` method has to return either the aggregate document type or `Task` where `T` is the aggregate document type. There must be an argument for the specific event type or `IEvent` where `T` is the event type if you need access to event metadata. You can also take in an `IQuerySession` if you need to look up additional data as part of the transformation or `IEvent` in addition to the exact event type just to get at event metadata.
@@ -144,14 +142,12 @@ public partial class TripProjection: SingleStreamProjection
return new Trip { Id = started.StreamId, StartedOn = started.Data.Day, Active = true };
}
- // ShouldDelete method-convention overloads — replace the pre-9.0
- // DeleteEvent() / DeleteEvent(predicate) constructor helpers.
public bool ShouldDelete(TripAborted _) => true;
public bool ShouldDelete(Breakdown e) => e.IsCritical;
public bool ShouldDelete(VacationOver _, Trip trip) => trip.Traveled > 1000;
}
```
-snippet source | anchor
+snippet source | anchor
The `Apply()` methods can accept any combination of these arguments:
@@ -182,7 +178,7 @@ aggregate projection type:
```cs
-public class TripProjection: SingleStreamProjection
+public partial class TripProjection: SingleStreamProjection
{
public TripProjection()
{
@@ -201,7 +197,7 @@ and maybe even other document state in your Marten database, you can use the `Sh
```cs
-public class TripProjection: SingleStreamProjection
+public partial class TripProjection: SingleStreamProjection
{
// The current Trip aggregate would be deleted if
// the Breakdown event is "critical"
diff --git a/docs/events/projections/enrichment.md b/docs/events/projections/enrichment.md
index 898c5a0801..98a2665c5d 100644
--- a/docs/events/projections/enrichment.md
+++ b/docs/events/projections/enrichment.md
@@ -103,7 +103,7 @@ as a way of wringing more performance and scalability out of your Marten usage!
```cs
-public class UserTaskProjection: SingleStreamProjection
+public partial class UserTaskProjection: SingleStreamProjection
{
// This is where you have a hook to "enrich" event data *after* slicing,
// but before processing
diff --git a/docs/events/projections/explicit.md b/docs/events/projections/explicit.md
index 5a2b5f15ae..b25aa368f8 100644
--- a/docs/events/projections/explicit.md
+++ b/docs/events/projections/explicit.md
@@ -19,7 +19,7 @@ through only the event data:
```cs
-public class AppointmentProjection: SingleStreamProjection
+public partial class AppointmentProjection: SingleStreamProjection
{
public AppointmentProjection()
{
@@ -124,7 +124,7 @@ data (because users have absolutely wanted to do that over the years):
```cs
-public class StartAndStopProjection: SingleStreamProjection
+public partial class StartAndStopProjection: SingleStreamProjection
{
public StartAndStopProjection()
{
@@ -199,7 +199,7 @@ and another example:
```cs
-public class HardDeletedStartAndStopProjection: SingleStreamProjection
+public partial class HardDeletedStartAndStopProjection: SingleStreamProjection
{
public HardDeletedStartAndStopProjection()
{
diff --git a/docs/events/projections/multi-stream-projections.md b/docs/events/projections/multi-stream-projections.md
index 298a1a69ab..057c7561c3 100644
--- a/docs/events/projections/multi-stream-projections.md
+++ b/docs/events/projections/multi-stream-projections.md
@@ -170,7 +170,7 @@ Here's a simple example of creating an aggregated view by user id:
```cs
-public class UserGroupsAssignmentProjection: MultiStreamProjection
+public partial class UserGroupsAssignmentProjection: MultiStreamProjection
{
public UserGroupsAssignmentProjection()
{
@@ -198,7 +198,7 @@ we care about and use this:
```cs
-public class UserGroupsAssignmentProjection2: MultiStreamProjection
+public partial class UserGroupsAssignmentProjection2: MultiStreamProjection
{
public UserGroupsAssignmentProjection2()
{
@@ -227,7 +227,7 @@ As of Marten V7, you can also use `IEvent` metadata as part of creating the iden
```cs
-public class CustomerInsightsProjection : MultiStreamProjection
+public partial class CustomerInsightsProjection : MultiStreamProjection
{
public CustomerInsightsProjection()
@@ -258,7 +258,7 @@ shown below:
```cs
-public class UserGroupsAssignmentProjection: MultiStreamProjection
+public partial class UserGroupsAssignmentProjection: MultiStreamProjection
{
public UserGroupsAssignmentProjection()
{
@@ -329,7 +329,7 @@ public class LicenseFeatureToggledEventGrouper: IAggregateGrouper
}
// projection with documentsession
-public class UserFeatureTogglesProjection: MultiStreamProjection
+public partial class UserFeatureTogglesProjection: MultiStreamProjection
{
public UserFeatureTogglesProjection()
{
@@ -414,7 +414,7 @@ public class ExternalAccountLink
public required Guid CustomerId { get; set; }
}
-public class ExternalAccountLinkProjection: SingleStreamProjection
+public partial class ExternalAccountLinkProjection: SingleStreamProjection
{
public void Apply(CustomerLinkedToExternalAccount e, ExternalAccountLink link)
{
@@ -479,7 +479,7 @@ public class CustomerBillingMetrics
public HashSet ModesSeen { get; set; } = [];
}
-public class CustomerBillingProjection: MultiStreamProjection
+public partial class CustomerBillingProjection: MultiStreamProjection
{
public CustomerBillingProjection()
{
@@ -565,7 +565,7 @@ public class CustomerBillingMetrics
public int ShippingLabels { get; set; }
}
-public class CustomerBillingProjection: MultiStreamProjection
+public partial class CustomerBillingProjection: MultiStreamProjection
{
public CustomerBillingProjection()
{
@@ -659,7 +659,7 @@ public class ExternalAccountLink
public required Guid CustomerId { get; set; }
}
-public class ExternalAccountLinkProjection: SingleStreamProjection
+public partial class ExternalAccountLinkProjection: SingleStreamProjection
{
public void Apply(CustomerLinkedToExternalAccount e, ExternalAccountLink link)
{
@@ -722,7 +722,7 @@ public class BatchAwareExternalAccountGrouper: IAggregateGrouper
}
}
-public class CustomerBillingProjection: MultiStreamProjection
+public partial class CustomerBillingProjection: MultiStreamProjection
{
public CustomerBillingProjection()
{
@@ -841,7 +841,7 @@ public class CustomerBillingMetrics
public required int Items { get; set; }
}
-public class CustomerBillingProjection: MultiStreamProjection
+public partial class CustomerBillingProjection: MultiStreamProjection
{
public CustomerBillingProjection()
{
@@ -880,7 +880,7 @@ tenant id and make that the identity of the projected document. That usage is sh
```cs
-public class RollupProjection: MultiStreamProjection
+public partial class RollupProjection: MultiStreamProjection
{
public RollupProjection()
{
@@ -929,7 +929,7 @@ In a sample `ViewProjection`, we do a "fan out" of the `Travel.Movements` member
```cs
-public class DayProjection: MultiStreamProjection
+public partial class DayProjection: MultiStreamProjection
{
public DayProjection()
{
@@ -1015,7 +1015,7 @@ The `MonthlyAllocationProjection` class uses a custom grouper for this transform
```cs
-public class MonthlyAllocationProjection: MultiStreamProjection
+public partial class MonthlyAllocationProjection: MultiStreamProjection
{
public MonthlyAllocationProjection()
{
@@ -1173,7 +1173,7 @@ The key technique is `Identity>()` which gives you access to both the
```cs
-public class MonthlyAccountActivityProjection : MultiStreamProjection
+public partial class MonthlyAccountActivityProjection : MultiStreamProjection
{
public MonthlyAccountActivityProjection()
{
diff --git a/docs/events/projections/rebuilding.md b/docs/events/projections/rebuilding.md
index 3b4baab803..7a5643644b 100644
--- a/docs/events/projections/rebuilding.md
+++ b/docs/events/projections/rebuilding.md
@@ -10,7 +10,7 @@ For example, if we have this projection:
```cs
-public class ShopProjection: SingleStreamProjection
+public partial class ShopProjection: SingleStreamProjection
{
public ShopProjection()
{
diff --git a/docs/events/projections/side-effects.md b/docs/events/projections/side-effects.md
index bdfdb6ba8e..42740b51f5 100644
--- a/docs/events/projections/side-effects.md
+++ b/docs/events/projections/side-effects.md
@@ -26,7 +26,7 @@ Here's an example of that method overridden in a projection:
```cs
-public class TripProjection: SingleStreamProjection
+public partial class TripProjection: SingleStreamProjection
{
// Access event metadata through IEvent
public Trip Create(IEvent @event)
diff --git a/docs/events/projections/single-stream-projections.md b/docs/events/projections/single-stream-projections.md
index de5c521181..f9398e8a7d 100644
--- a/docs/events/projections/single-stream-projections.md
+++ b/docs/events/projections/single-stream-projections.md
@@ -121,14 +121,12 @@ public partial class TripProjection: SingleStreamProjection
return new Trip { Id = started.StreamId, StartedOn = started.Data.Day, Active = true };
}
- // ShouldDelete method-convention overloads — replace the pre-9.0
- // DeleteEvent() / DeleteEvent(predicate) constructor helpers.
public bool ShouldDelete(TripAborted _) => true;
public bool ShouldDelete(Breakdown e) => e.IsCritical;
public bool ShouldDelete(VacationOver _, Trip trip) => trip.Traveled > 1000;
}
```
-snippet source | anchor
+snippet source | anchor
And register that projection like this:
@@ -171,7 +169,7 @@ Here's a simple example of explicit code in projections:
```cs
-public class AppointmentProjection: SingleStreamProjection
+public partial class AppointmentProjection: SingleStreamProjection
{
public AppointmentProjection()
{
@@ -234,7 +232,7 @@ the possibility of soft deleting and later "un-deleting" the projected document
```cs
-public class StartAndStopProjection: SingleStreamProjection
+public partial class StartAndStopProjection: SingleStreamProjection
{
public StartAndStopProjection()
{
diff --git a/docs/events/projections/using-metadata.md b/docs/events/projections/using-metadata.md
index 30af6b053d..1216426270 100644
--- a/docs/events/projections/using-metadata.md
+++ b/docs/events/projections/using-metadata.md
@@ -64,7 +64,7 @@ Below is a small example of accessing event metadata during aggregation:
```cs
-public class TripProjection: SingleStreamProjection
+public partial class TripProjection: SingleStreamProjection
{
// Access event metadata through IEvent
public Trip Create(IEvent @event)
@@ -169,7 +169,7 @@ public record ItemWorked;
public record ItemFinished;
-public class ItemProjection: SingleStreamProjection
+public partial class ItemProjection: SingleStreamProjection
{
public void Apply(Item item, ItemStarted started)
{
diff --git a/docs/events/quickstart.md b/docs/events/quickstart.md
index 7c665746f0..883df0a818 100644
--- a/docs/events/quickstart.md
+++ b/docs/events/quickstart.md
@@ -110,7 +110,7 @@ What about the quest itself? On top of seeing our in-progress quest, we also wan
```cs
public sealed record Quest(Guid Id, List Members, List Slayed, string Name, bool isFinished);
-public sealed class QuestProjection: SingleStreamProjection
+public sealed partial class QuestProjection: SingleStreamProjection
{
public static Quest Create(QuestStarted started) => new(started.QuestId, [], [], started.Name, false);
public static Quest Apply(MembersJoined joined, Quest party) =>
diff --git a/docs/migration-guide.md b/docs/migration-guide.md
index 86fe0d479e..b6829cb6f1 100644
--- a/docs/migration-guide.md
+++ b/docs/migration-guide.md
@@ -243,8 +243,8 @@ What was replaced:
What that means for application code:
-* **No more `dotnet run -- codegen write` step.** Pre-built `Internal/Generated/` folders are obsolete — delete them from your project and `.gitignore`. The closed-shape paths build their descriptors at first use (cheap) and cache them; there is no compile-on-cold-start.
-* **The `[Obsolete]` knobs stay on the surface as no-ops** so existing bootstrapping compiles unchanged: `StoreOptions.GeneratedCodeMode`, `StoreOptions.ApplicationAssembly`, `StoreOptions.SourceCodeWritingEnabled`, `StoreOptions.GeneratedCodeOutputPath`, `StoreOptions.AllowRuntimeCodeGeneration`, and `opts.Events.UseClosedShapeStorage` (which was an opt-in flag in 9.0-alpha; the closed-shape path is now the only path). None of them do anything at runtime — remove them at your convenience.
+* **No more `dotnet run -- codegen write` step for Marten.** Pre-built `Internal/Generated/` folders are obsolete — delete them from your project and `.gitignore`. The closed-shape paths build their descriptors at first use (cheap) and cache them; there is no compile-on-cold-start. If your host also runs Wolverine or another JasperFx-family tool, those still ship their own codegen and may still require the `codegen write` step in your Dockerfile — only the Marten portion of the step is now redundant.
+* **The codegen-config knobs have been deleted.** `StoreOptions.GeneratedCodeMode`, `StoreOptions.SourceCodeWritingEnabled`, `StoreOptions.GeneratedCodeOutputPath`, and `StoreOptions.AllowRuntimeCodeGeneration` are gone — references to them will fail to compile against Marten 9.0. Remove them from your bootstrapping. `StoreOptions.ApplicationAssembly` is kept (legitimately used by `AutoRegister` and `TryUseSourceGeneratedDiscovery` as a scan hint).
* **The `Pre-Building Generated Types` documentation page has been retired.** Anything that linked to `/configuration/prebuilding` now 404s. The closest equivalent for "I want to ship without dynamic codegen" is reading the [compiled queries source-generator section](#source-gen-compiled-queries) below — the source generator covers the AOT-clean cases the pre-build flow used to.
#### **Lazy document-mapping materialization**
@@ -495,19 +495,16 @@ See [#4420](https://github.com/JasperFx/marten/issues/4420).
Marten 9 retires obsolete types and members deprecated in Marten 8.x:
-* **`StoreOptions.GeneratedCodeMode` is `[Obsolete]`.** Prefer the global `IServiceCollection.CritterStackDefaults()` API, which sets `GeneratedCodeMode` and `AutoCreate` per-environment (`Development` / `Production`) and applies the values across every Critter Stack tool in your application (Marten + [Wolverine](https://wolverinefx.net)) in one place:
+* **`StoreOptions.GeneratedCodeMode` and the codegen-config family have been deleted** (see [Runtime code generation removed](#runtime-code-generation-removed)). The `x.Production.GeneratedCodeMode = TypeLoadMode.Static;` line that appeared in 8.x `CritterStackDefaults` samples is no longer relevant to Marten — drop it from your bootstrapping. The `ResourceAutoCreate` half of `CritterStackDefaults` is unchanged:
```csharp
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
// x.Development.* defaults are sensible; override only if needed.
});
```
- The old per-`StoreOptions` `GeneratedCodeMode` setter still works in Marten 9 (it carries an `[Obsolete]` warning) — it will be **removed in Marten 10**. Migrate now to avoid the build-break later.
-
* `[Obsolete]` types and members deprecated since Marten 8.x have been retired in Marten 9. If your code compiled in Marten 8.x with `[Obsolete]` warnings against any Marten type, those members are now gone in Marten 9 — fix the warnings on 8.x first, then upgrade.
### Renames coordinated with JasperFx 2.0 / JasperFx.Events 2.0
@@ -667,11 +664,10 @@ services.AddMarten(opts =>
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
Note the usage of `CritterStackDefaults()` above. This will allow you to specify separate behavior for `Development` time vs
diff --git a/docs/scenarios/aggregates-events-repositories.md b/docs/scenarios/aggregates-events-repositories.md
index 59180b654a..6f4f83a6ea 100644
--- a/docs/scenarios/aggregates-events-repositories.md
+++ b/docs/scenarios/aggregates-events-repositories.md
@@ -48,7 +48,7 @@ public abstract class AggregateBase
}
}
```
-snippet source | anchor
+snippet source | anchor
With the first piece of infrastructure implemented, two events to capture state changes of an invoice are introduced. Namely, creation of an invoice, accompanied by an invoice number, and addition of lines to an invoice:
@@ -80,7 +80,7 @@ public sealed class LineItemAdded
}
}
```
-snippet source | anchor
+snippet source | anchor
With the events in place to present the deltas of an invoice, an aggregate is implemented, using the infrastructure presented above, to create and replay state from the described events.
@@ -107,7 +107,11 @@ public sealed class Invoice: AggregateBase
AddUncommittedEvent(@event);
}
- private Invoice()
+ // Public parameterless ctor for Marten's event-store replay. Pre-9.0
+ // Marten could call a private parameterless ctor reflectively; the
+ // source-generated dispatch path in 9.0 emits direct calls instead,
+ // which require public visibility. See the 9.0 migration guide.
+ public Invoice()
{
}
@@ -138,8 +142,11 @@ public sealed class Invoice: AggregateBase
private readonly List> lines = new List>();
- // Apply the deltas to mutate our state
- private void Apply(InvoiceCreated @event)
+ // Apply methods need to be `public` for the source-generated dispatcher
+ // to invoke them — pre-9.0 Marten reflected over private members; the
+ // SG-emitted dispatch path in 9.0 emits direct method calls. See the
+ // 9.0 migration guide.
+ public void Apply(InvoiceCreated @event)
{
Id = @event.InvoiceNumber.ToString(CultureInfo.InvariantCulture);
@@ -147,8 +154,7 @@ public sealed class Invoice: AggregateBase
Version++;
}
- // Apply the deltas to mutate our state
- private void Apply(LineItemAdded @event)
+ public void Apply(LineItemAdded @event)
{
var price = @event.Price * (1 + @event.Vat / 100);
Total += price;
@@ -159,7 +165,7 @@ public sealed class Invoice: AggregateBase
}
}
```
-snippet source | anchor
+snippet source | anchor
The implemented invoice protects its state by not exposing mutable data, while enforcing its contracts through argument validation. Once an applicable state modification is introduced, either through the constructor (which numbers our invoice and captures that in an event) or the `Invoice.AddLine` method, a respective event capturing that data is recorded.
@@ -201,7 +207,7 @@ public sealed class AggregateRepository
}
}
```
-snippet source | anchor
+snippet source | anchor
With the last infrastructure component in place, versioned invoices can now be created, persisted and hydrated through Marten. For this purpose, first an invoice is created:
diff --git a/docs/schema/index.md b/docs/schema/index.md
index 0096a3da08..85a9b6b98c 100644
--- a/docs/schema/index.md
+++ b/docs/schema/index.md
@@ -32,7 +32,7 @@ var store = DocumentStore.For(opts =>
opts.AutoCreateSchemaObjects = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
To prevent unnecessary loss of data, even in development, on the first usage of a document type, Marten will:
@@ -53,7 +53,6 @@ All/None/CreateOnly/CreateOrUpdate rules as the table storage.**
## Overriding Schema Name
By default marten will use the default `public` database scheme to create the document tables and function. You may, however, choose to set a different document store database schema name, like so:
-::: warning If you run code before schema changes and using `opts.GeneratedCodeMode = TypeLoadMode.Auto;` (by yourself or by `OptimizeArtifactWorkflow()` in dev env) schema won't change. You need to delete `Internal` folder manually to force regenerating code and schema changes. :::
```cs
StoreOptions.DatabaseSchemaName = "other";
diff --git a/docs/schema/migrations.md b/docs/schema/migrations.md
index e80f7668f0..04ae110332 100644
--- a/docs/schema/migrations.md
+++ b/docs/schema/migrations.md
@@ -51,7 +51,7 @@ var store = DocumentStore.For(opts =>
opts.AutoCreateSchemaObjects = AutoCreate.None;
});
```
-snippet source | anchor
+snippet source | anchor
As long as you're using a permissive auto creation mode (i.e., not _None_), you should be able to code in your application model
@@ -170,7 +170,7 @@ services.AddMarten(opts =>
// database changes on application startup
.ApplyAllDatabaseChangesOnStartup();
```
-snippet source | anchor
+snippet source | anchor
In the option above, Marten is calling the same functionality within an `IHostedService` background task.
diff --git a/package-lock.json b/package-lock.json
index 872c9b7f8b..70be71d496 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "marten",
+ "name": "scrub-codegen",
"lockfileVersion": 3,
"requires": true,
"packages": {
diff --git a/src/AspNetCoreWithMarten/Samples/ByNestedClosure/Startup.cs b/src/AspNetCoreWithMarten/Samples/ByNestedClosure/Startup.cs
index 20424c8295..85f0221590 100644
--- a/src/AspNetCoreWithMarten/Samples/ByNestedClosure/Startup.cs
+++ b/src/AspNetCoreWithMarten/Samples/ByNestedClosure/Startup.cs
@@ -1,5 +1,4 @@
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -35,7 +34,6 @@ public void ConfigureServices(IServiceCollection services)
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
#endregion
diff --git a/src/AspNetCoreWithMarten/Samples/ByStoreOptions/Startup.cs b/src/AspNetCoreWithMarten/Samples/ByStoreOptions/Startup.cs
index 819bf15b5f..6236210ae4 100644
--- a/src/AspNetCoreWithMarten/Samples/ByStoreOptions/Startup.cs
+++ b/src/AspNetCoreWithMarten/Samples/ByStoreOptions/Startup.cs
@@ -1,5 +1,4 @@
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -35,7 +34,6 @@ public void ConfigureServices(IServiceCollection services)
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
diff --git a/src/AspNetCoreWithMarten/Samples/ConfiguringSessionCreation/Startup.cs b/src/AspNetCoreWithMarten/Samples/ConfiguringSessionCreation/Startup.cs
index f4769c7deb..84c0eb0888 100644
--- a/src/AspNetCoreWithMarten/Samples/ConfiguringSessionCreation/Startup.cs
+++ b/src/AspNetCoreWithMarten/Samples/ConfiguringSessionCreation/Startup.cs
@@ -1,6 +1,5 @@
using System.Data;
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -69,7 +68,6 @@ public void ConfigureServices(IServiceCollection services)
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
#endregion
diff --git a/src/AspNetCoreWithMarten/Samples/EagerInitialization/Startup.cs b/src/AspNetCoreWithMarten/Samples/EagerInitialization/Startup.cs
index 06415946ed..4e510ca21d 100644
--- a/src/AspNetCoreWithMarten/Samples/EagerInitialization/Startup.cs
+++ b/src/AspNetCoreWithMarten/Samples/EagerInitialization/Startup.cs
@@ -1,5 +1,4 @@
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -30,7 +29,6 @@ public void ConfigureServices(IServiceCollection services)
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
diff --git a/src/AspNetCoreWithMarten/Samples/PerScopeSessionCreation/Startup.cs b/src/AspNetCoreWithMarten/Samples/PerScopeSessionCreation/Startup.cs
index 7c912b7f4b..8ca103aee6 100644
--- a/src/AspNetCoreWithMarten/Samples/PerScopeSessionCreation/Startup.cs
+++ b/src/AspNetCoreWithMarten/Samples/PerScopeSessionCreation/Startup.cs
@@ -1,7 +1,6 @@
using System;
using System.Data;
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten;
using Marten.Services;
using Microsoft.Extensions.Configuration;
@@ -139,7 +138,6 @@ public void ConfigureServices(IServiceCollection services)
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
diff --git a/src/CommandLineRunner/Program.cs b/src/CommandLineRunner/Program.cs
index ae3e417e1c..ff1576fc3b 100644
--- a/src/CommandLineRunner/Program.cs
+++ b/src/CommandLineRunner/Program.cs
@@ -4,7 +4,6 @@
using DaemonTests.EventProjections;
using DaemonTests.TestingSupport;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Events;
using JasperFx.Events.Daemon;
using JasperFx.Events.Projections;
@@ -46,13 +45,11 @@ public static IHostBuilder CreateHostBuilder(string[] args)
opts.RegisterDocumentType();
opts.RegisterDocumentType();
opts.RegisterDocumentType();
- opts.GeneratedCodeMode = TypeLoadMode.Static;
});
services.AddMartenStore(opts =>
{
opts.Connection(ConnectionSource.ConnectionString);
- opts.GeneratedCodeMode = TypeLoadMode.Static;
opts.RegisterDocumentType();
@@ -68,7 +65,6 @@ public static IHostBuilder CreateHostBuilder(string[] args)
services.AddMarten(opts =>
{
opts.Events.AppendMode = EventAppendMode.Quick;
- opts.GeneratedCodeMode = TypeLoadMode.Dynamic;
opts.AutoCreateSchemaObjects = AutoCreate.All;
opts.DatabaseSchemaName = "cli";
opts.DisableNpgsqlLogging = true;
@@ -80,10 +76,6 @@ public static IHostBuilder CreateHostBuilder(string[] args)
t => t.WithTenants("tenant1", "tenant2", "tenant3")
);
- // This is important, setting this option tells Marten to
- // *try* to use pre-generated code at runtime
- //opts.GeneratedCodeMode = TypeLoadMode.Static;
-
//opts.Schema.For().AddSubClass();
// You have to register all persisted document types ahead of time
diff --git a/src/CommandLineRunner/TestCommand.cs b/src/CommandLineRunner/TestCommand.cs
index d4542631e2..89e6954498 100644
--- a/src/CommandLineRunner/TestCommand.cs
+++ b/src/CommandLineRunner/TestCommand.cs
@@ -3,7 +3,6 @@
using System.Threading.Tasks;
using DaemonTests.TestingSupport;
using EventSourcingTests.Aggregation;
-using JasperFx.CodeGeneration;
using JasperFx.CommandLine;
using Marten;
using Marten.Testing.Documents;
@@ -19,23 +18,6 @@ public override async Task Execute(NetCoreInput input)
{
using var host = input.BuildHost();
- var collections = host.Services.GetServices().ToArray();
- foreach (var collection in collections)
- {
- Console.WriteLine(collection);
- Console.WriteLine(" " + collection.Rules.GeneratedCodeOutputPath);
-
- var files = collection.BuildFiles();
- if (files.Any())
- {
- foreach (var file in files) Console.WriteLine(" * " + file);
- }
- else
- {
- Console.WriteLine(" * NONE");
- }
- }
-
using var store = host.Services.GetRequiredService();
await store.Advanced.Clean.DeleteAllDocumentsAsync();
diff --git a/src/CoreTests/Examples/CodeGenerationOptions.cs b/src/CoreTests/Examples/CodeGenerationOptions.cs
deleted file mode 100644
index 2bad8109fb..0000000000
--- a/src/CoreTests/Examples/CodeGenerationOptions.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System.Threading.Tasks;
-using JasperFx.Core;
-using JasperFx.CodeGeneration;
-using Marten;
-using Marten.Testing.Documents;
-using Marten.Testing.Harness;
-using Microsoft.Extensions.Hosting;
-using Xunit;
-
-namespace CoreTests.Examples;
-
-public class CodeGenerationOptions
-{
- public void build_store()
- {
- #region sample_code_generation_modes
-
- using var store = DocumentStore.For(opts =>
- {
- opts.Connection("some connection string");
-
- // This is the default. Marten will always generate
- // code dynamically at runtime
- opts.GeneratedCodeMode = TypeLoadMode.Dynamic;
-
- // Marten will only use types that are compiled into
- // the application assembly ahead of time. This is the
- // "pre-built" model
- opts.GeneratedCodeMode = TypeLoadMode.Static;
-
- // Explained Below :)
- opts.GeneratedCodeMode = TypeLoadMode.Auto;
- });
-
- #endregion
- }
-
- public async Task using_auto()
- {
- #region sample_document_store_for_user_document
-
- using var store = DocumentStore.For(opts =>
- {
- // ConnectionSource is a little helper in the Marten
- // test suite
- opts.Connection(ConnectionSource.ConnectionString);
-
- opts.GeneratedCodeMode = TypeLoadMode.Auto;
- });
-
- #endregion
-
- #region sample_save_a_single_user
-
- await using var session = store.LightweightSession();
- var user = new User { UserName = "admin" };
- session.Store(user);
- await session.SaveChangesAsync();
-
- #endregion
- }
-
- [Fact]
- public void override_application_assembly()
- {
- #region sample_using_set_application_project
-
- using var host = Host.CreateDefaultBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten(opts =>
- {
- opts.Connection("some connection string");
- opts.SetApplicationProject(typeof(User).Assembly);
- });
- })
- .StartAsync();
-
- #endregion
- }
-}
diff --git a/src/CoreTests/Examples/MultipleDocumentStores.cs b/src/CoreTests/Examples/MultipleDocumentStores.cs
index dc2e39483a..718cf1bfe8 100644
--- a/src/CoreTests/Examples/MultipleDocumentStores.cs
+++ b/src/CoreTests/Examples/MultipleDocumentStores.cs
@@ -1,7 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Events.Daemon;
using Marten;
using Marten.Schema;
@@ -40,10 +39,9 @@ public static async Task bootstrap()
.InitializeWith(new DefaultDataSet());
// In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
+ // automatic database migrations
services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
}).StartAsync();
diff --git a/src/CoreTests/Internal/CodeGeneration/MartenSnapshotInputsTests.cs b/src/CoreTests/Internal/CodeGeneration/MartenSnapshotInputsTests.cs
deleted file mode 100644
index 8606b3d73a..0000000000
--- a/src/CoreTests/Internal/CodeGeneration/MartenSnapshotInputsTests.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-using System;
-using JasperFx.CodeGeneration.Snapshots;
-using Marten;
-using Marten.Internal.CodeGeneration;
-using Marten.Testing.Harness;
-using Shouldly;
-using Xunit;
-
-namespace CoreTests.Internal.CodeGeneration;
-
-///
-/// Trust-gate tests for the codegen snapshot canonical-input shape (marten#4370
-/// Phase 2). These pin determinism + mutation-sensitivity. They run without
-/// Postgres (canonical-input is a pure function of
-/// and doesn't touch the database).
-///
-public class MartenSnapshotInputsTests
-{
- ///
- /// Build a minimal StoreOptions that's still composed enough to walk.
- /// We never call ApplyConfiguration / Validate / DocumentStore.For —
- /// those open a database connection. We work directly against a
- /// constructed StoreOptions and exercise the canonical-input shape.
- ///
- private static StoreOptions FreshOptions()
- {
- var opts = new StoreOptions();
- opts.Connection(ConnectionSource.ConnectionString);
- return opts;
- }
-
- // ─── Determinism ─────────────────────────────────────────────────────
-
- [Fact]
- public void compose_is_deterministic_for_unchanged_options()
- {
- var a = MartenSnapshotInputs.Compose(FreshOptions());
- var b = MartenSnapshotInputs.Compose(FreshOptions());
-
- a.ShouldBe(b);
- }
-
- [Fact]
- public void fingerprint_is_deterministic_for_unchanged_options()
- {
- var a = MartenSnapshot.BuildFingerprint(FreshOptions());
- var b = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- a.ConfigHash.ShouldBe(b.ConfigHash);
- a.ShouldBe(b);
- }
-
- [Fact]
- public void config_hash_is_a_lowercase_64_char_hex_digest()
- {
- var fp = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- fp.ConfigHash.Length.ShouldBe(64);
- fp.ConfigHash.ShouldAllBe(c => (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'));
- }
-
- [Fact]
- public void fingerprint_records_marten_product_name()
- {
- MartenSnapshot.BuildFingerprint(FreshOptions()).ProductName.ShouldBe("marten");
- }
-
- // ─── Mutation matrix ────────────────────────────────────────────────
- // Each mutation tests one dimension of MartenSnapshotInputs.Compose and
- // verifies the resulting fingerprint differs. If any of these stop
- // failing, you've broken invalidation for that input — bad.
-
- [Fact]
- public void mutation_adding_a_document_type_changes_the_hash()
- {
- var baseline = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var mutated = FreshOptions();
- mutated.Schema.For();
- var withDoc = MartenSnapshot.BuildFingerprint(mutated);
-
- withDoc.ConfigHash.ShouldNotBe(baseline.ConfigHash);
- }
-
- [Fact]
- public void mutation_different_document_type_yields_different_hash()
- {
- var a = FreshOptions();
- a.Schema.For();
- var hashA = MartenSnapshot.BuildFingerprint(a).ConfigHash;
-
- var b = FreshOptions();
- b.Schema.For();
- var hashB = MartenSnapshot.BuildFingerprint(b).ConfigHash;
-
- hashA.ShouldNotBe(hashB);
- }
-
- [Fact]
- public void mutation_changing_database_schema_name_changes_the_hash()
- {
- var baseline = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var mutated = FreshOptions();
- mutated.DatabaseSchemaName = "different_schema";
- var withCustomSchema = MartenSnapshot.BuildFingerprint(mutated);
-
- withCustomSchema.ConfigHash.ShouldNotBe(baseline.ConfigHash);
- }
-
- [Fact]
- public void mutation_changing_store_name_changes_the_hash()
- {
- var baseline = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var mutated = FreshOptions();
- mutated.StoreName = "AnotherStore";
- var withCustomName = MartenSnapshot.BuildFingerprint(mutated);
-
- withCustomName.ConfigHash.ShouldNotBe(baseline.ConfigHash);
- }
-
- [Fact]
- public void mutation_changing_stream_identity_changes_the_hash()
- {
- var baseline = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var mutated = FreshOptions();
- mutated.Events.StreamIdentity = JasperFx.Events.StreamIdentity.AsString;
- var withStringStream = MartenSnapshot.BuildFingerprint(mutated);
-
- withStringStream.ConfigHash.ShouldNotBe(baseline.ConfigHash);
- }
-
- [Fact]
- public void mutation_enabling_strict_stream_identity_changes_the_hash()
- {
- var baseline = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var mutated = FreshOptions();
- mutated.Events.EnableStrictStreamIdentityEnforcement = true;
- var withStrict = MartenSnapshot.BuildFingerprint(mutated);
-
- withStrict.ConfigHash.ShouldNotBe(baseline.ConfigHash);
- }
-
- [Fact]
- public void mutation_enabling_extended_progression_tracking_changes_the_hash()
- {
- // EventGraph is internal so we access the flag via the internal property
- // rather than the IEventStoreOptions public surface. CoreTests sees Marten
- // internals via InternalsVisibleTo.
- var baseline = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var mutated = FreshOptions();
- mutated.EventGraph.EnableExtendedProgressionTracking = true;
- var withExt = MartenSnapshot.BuildFingerprint(mutated);
-
- withExt.ConfigHash.ShouldNotBe(baseline.ConfigHash);
- }
-
- // ─── Composition / order-stability ──────────────────────────────────
-
- [Fact]
- public void doc_type_registration_order_does_not_affect_hash()
- {
- // Sorting in MartenSnapshotInputs means two stores that register the same
- // types in different orders should produce identical fingerprints. If
- // this test fails the sort isn't doing its job and downstream snapshots
- // would spuriously invalidate on cosmetic option-build reorderings.
- var a = FreshOptions();
- a.Schema.For();
- a.Schema.For();
- var hashA = MartenSnapshot.BuildFingerprint(a).ConfigHash;
-
- var b = FreshOptions();
- b.Schema.For();
- b.Schema.For();
- var hashB = MartenSnapshot.BuildFingerprint(b).ConfigHash;
-
- hashA.ShouldBe(hashB);
- }
-
- // ─── Verdict via SnapshotGate ───────────────────────────────────────
-
- [Fact]
- public void verify_returns_Accept_when_persisted_matches_live()
- {
- var live = MartenSnapshot.BuildFingerprint(FreshOptions());
- SnapshotGate.Verify(live, persisted: live).ShouldBe(SnapshotVerdict.Accept);
- }
-
- [Fact]
- public void verify_returns_FirstBoot_when_no_persisted_fingerprint()
- {
- var live = MartenSnapshot.BuildFingerprint(FreshOptions());
- SnapshotGate.Verify(live, persisted: null).ShouldBe(SnapshotVerdict.FirstBoot);
- }
-
- [Fact]
- public void verify_returns_RejectAndRegenerate_when_options_mutated()
- {
- var persisted = MartenSnapshot.BuildFingerprint(FreshOptions());
-
- var live = FreshOptions();
- live.Schema.For();
- var liveFingerprint = MartenSnapshot.BuildFingerprint(live);
-
- SnapshotGate.Verify(liveFingerprint, persisted)
- .ShouldBe(SnapshotVerdict.RejectAndRegenerate);
- }
-
- // ─── Test fixtures ──────────────────────────────────────────────────
-
- public class DocTypeA
- {
- public Guid Id { get; set; }
- public string Name { get; set; } = "";
- }
-
- public class DocTypeB
- {
- public Guid Id { get; set; }
- public int Count { get; set; }
- }
-}
diff --git a/src/CoreTests/Internal/CodeGeneration/MartenSnapshotPersistenceTests.cs b/src/CoreTests/Internal/CodeGeneration/MartenSnapshotPersistenceTests.cs
deleted file mode 100644
index 557d66220a..0000000000
--- a/src/CoreTests/Internal/CodeGeneration/MartenSnapshotPersistenceTests.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-using System;
-using System.IO;
-using JasperFx.CodeGeneration.Snapshots;
-using Marten;
-using Marten.Internal.CodeGeneration;
-using Marten.Testing.Harness;
-using Shouldly;
-using Xunit;
-
-namespace CoreTests.Internal.CodeGeneration;
-
-///
-/// Filesystem round-trip + verify tests for the codegen snapshot
-/// (marten#4370 Phase 2). Covers
-/// and end-to-end via a real
-/// temp directory. No Postgres connection required.
-///
-public class MartenSnapshotPersistenceTests : IDisposable
-{
- private readonly string _tempFolder;
-
- public MartenSnapshotPersistenceTests()
- {
- _tempFolder = Path.Combine(
- Path.GetTempPath(),
- "marten-snapshot-tests-" + Guid.NewGuid().ToString("N"));
- Directory.CreateDirectory(_tempFolder);
- }
-
- public void Dispose()
- {
- if (Directory.Exists(_tempFolder)) Directory.Delete(_tempFolder, recursive: true);
- }
-
- private StoreOptions OptionsAtTempFolder()
- {
- var opts = new StoreOptions();
- opts.Connection(ConnectionSource.ConnectionString);
- opts.GeneratedCodeOutputPath = _tempFolder;
- return opts;
- }
-
- // ─── First-boot path ─────────────────────────────────────────────────
-
- [Fact]
- public void verify_at_boot_returns_FirstBoot_when_folder_is_empty()
- {
- // No fingerprint persisted yet → FirstBoot. This is the steady-state
- // result on a fresh deployment, not an error.
- MartenSnapshot.VerifyAtBoot(OptionsAtTempFolder())
- .ShouldBe(SnapshotVerdict.FirstBoot);
- }
-
- [Fact]
- public void persist_then_verify_round_trips_to_Accept()
- {
- // The plumbing's primary contract: PersistFingerprint() followed by
- // VerifyAtBoot() with the same options accepts the snapshot. If this
- // ever stops holding, the boot-time verify path is broken.
- var opts = OptionsAtTempFolder();
-
- MartenSnapshot.PersistFingerprint(opts);
-
- MartenSnapshot.VerifyAtBoot(opts).ShouldBe(SnapshotVerdict.Accept);
- }
-
- [Fact]
- public void persist_writes_fingerprint_json_to_the_generated_folder()
- {
- MartenSnapshot.PersistFingerprint(OptionsAtTempFolder());
-
- var path = Path.Combine(_tempFolder, SnapshotGate.FingerprintFileName);
- File.Exists(path).ShouldBeTrue();
- }
-
- // ─── Mutation invalidates ───────────────────────────────────────────
-
- [Fact]
- public void mutation_after_persist_yields_RejectAndRegenerate()
- {
- // Establish a baseline snapshot on disk.
- var baseline = OptionsAtTempFolder();
- MartenSnapshot.PersistFingerprint(baseline);
-
- // Live boot with a mutated config — same temp folder, different inputs.
- var mutated = OptionsAtTempFolder();
- mutated.Schema.For();
-
- MartenSnapshot.VerifyAtBoot(mutated)
- .ShouldBe(SnapshotVerdict.RejectAndRegenerate);
- }
-
- [Fact]
- public void rewriting_with_mutated_options_overwrites_the_baseline()
- {
- var baseline = OptionsAtTempFolder();
- MartenSnapshot.PersistFingerprint(baseline);
-
- var mutated = OptionsAtTempFolder();
- mutated.Schema.For();
- MartenSnapshot.PersistFingerprint(mutated);
-
- // After overwrite the mutated options should now Accept (the persisted
- // fingerprint is the mutated one). This is the steady-state of the
- // "fall back to live, then re-persist" flow on the next boot.
- MartenSnapshot.VerifyAtBoot(mutated).ShouldBe(SnapshotVerdict.Accept);
-
- // And the original baseline should now be rejected because the
- // persisted fingerprint reflects the mutation.
- MartenSnapshot.VerifyAtBoot(baseline)
- .ShouldBe(SnapshotVerdict.RejectAndRegenerate);
- }
-
- // ─── Defensive behaviour ────────────────────────────────────────────
-
- [Fact]
- public void verify_at_boot_with_malformed_fingerprint_treats_as_FirstBoot()
- {
- // SnapshotGate.Read returns null on malformed JSON (soft-fallback policy).
- // From MartenSnapshot's perspective that's indistinguishable from no
- // fingerprint — both return FirstBoot. Pin this so a corrupt file in
- // the generated folder doesn't crash boot.
- File.WriteAllText(
- Path.Combine(_tempFolder, SnapshotGate.FingerprintFileName),
- "{ corrupted");
-
- MartenSnapshot.VerifyAtBoot(OptionsAtTempFolder())
- .ShouldBe(SnapshotVerdict.FirstBoot);
- }
-
- public class TestDoc
- {
- public Guid Id { get; set; }
- }
-}
diff --git a/src/CoreTests/SessionOptionsTests.cs b/src/CoreTests/SessionOptionsTests.cs
index a86c92f10e..d524cf6c3a 100644
--- a/src/CoreTests/SessionOptionsTests.cs
+++ b/src/CoreTests/SessionOptionsTests.cs
@@ -4,7 +4,6 @@
using System.Linq;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using Marten;
using Marten.Internal.OpenTelemetry;
@@ -157,7 +156,6 @@ public async Task default_timeout_should_be_npgsql_default_ie_30()
{
var connectionString = ConnectionSource.ConnectionString.Replace(";Command Timeout=5", "");
opts.Connection(connectionString);
- opts.GeneratedCodeMode = TypeLoadMode.Auto;
});
var options = new SessionOptions();
diff --git a/src/CoreTests/StoreOptionsTests.cs b/src/CoreTests/StoreOptionsTests.cs
index 0ef14c26fd..c1193924ae 100644
--- a/src/CoreTests/StoreOptionsTests.cs
+++ b/src/CoreTests/StoreOptionsTests.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Text.Json;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Descriptors;
using JasperFx.MultiTenancy;
using Marten;
@@ -314,13 +313,6 @@ public void
storeOptions.Advanced.DuplicatedFieldEnumStorage.ShouldBe(EnumStorage.AsInteger);
}
- [Fact]
- public void default_code_generation_is_dynamic()
- {
- var storeOptions = new StoreOptions();
- storeOptions.GeneratedCodeMode.ShouldBe(TypeLoadMode.Dynamic);
- }
-
public void set_the_maximum_name_length()
{
#region sample_setting-name-data-length
diff --git a/src/CoreTests/all_exceptions_should_derive_from_MartenException.cs b/src/CoreTests/all_exceptions_should_derive_from_MartenException.cs
index 29bf9783fa..b0704cd9dd 100644
--- a/src/CoreTests/all_exceptions_should_derive_from_MartenException.cs
+++ b/src/CoreTests/all_exceptions_should_derive_from_MartenException.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using JasperFx.Core;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using Marten.Events.TestSupport;
using Marten.Exceptions;
diff --git a/src/CoreTests/bootstrapping_with_service_collection_extensions.cs b/src/CoreTests/bootstrapping_with_service_collection_extensions.cs
index 48f3a11d7b..e2fe233478 100644
--- a/src/CoreTests/bootstrapping_with_service_collection_extensions.cs
+++ b/src/CoreTests/bootstrapping_with_service_collection_extensions.cs
@@ -4,7 +4,6 @@
using System.Reflection;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using Lamar;
@@ -51,7 +50,7 @@ public void add_marten_with_just_connection_string()
}
[Fact]
- public async Task use_jasper_fx_defaults_for_type_load_and_auto_create()
+ public async Task use_jasper_fx_defaults_for_auto_create()
{
using var host = await Host.CreateDefaultBuilder()
.ConfigureServices(services =>
@@ -61,19 +60,12 @@ public async Task use_jasper_fx_defaults_for_type_load_and_auto_create()
services.AddJasperFx(opts =>
{
opts.Development.ResourceAutoCreate = AutoCreate.None;
- opts.GeneratedCodeOutputPath = "/";
- opts.Development.GeneratedCodeMode = TypeLoadMode.Static;
-
- // Default is true
- opts.Development.SourceCodeWritingEnabled = false;
});
})
.UseEnvironment("Development").StartAsync();
var store = (DocumentStore)host.DocumentStore();
store.Options.AutoCreateSchemaObjects.ShouldBe(AutoCreate.None);
- store.Options.SourceCodeWritingEnabled.ShouldBeFalse();
- store.Options.GeneratedCodeMode.ShouldBe(TypeLoadMode.Static);
}
[Fact]
@@ -118,49 +110,6 @@ public void add_marten_by_configure_lambda()
ShouldHaveAllTheExpectedRegistrations(container);
}
- [Fact]
- public void picks_up_application_assembly_and_content_directory_from_IHostEnvironment()
- {
- var environment = new MartenHostEnvironment();
-
- using var host = Host.CreateDefaultBuilder(Array.Empty())
- .ConfigureServices(services =>
- {
- services.AddMarten(ConnectionSource.ConnectionString);
-
- services.AddSingleton(environment);
- }).Build();
-
- var store = host.Services.GetRequiredService().As();
- store.Options.ApplicationAssembly.ShouldBe(GetType().Assembly);
- var projectPath = AppContext.BaseDirectory.ParentDirectory().ParentDirectory().ParentDirectory();
- var expectedGeneratedCodeOutputPath = projectPath.ToFullPath().AppendPath("Internal", "Generated");
- store.Options.GeneratedCodeOutputPath.ShouldBe(expectedGeneratedCodeOutputPath);
-
- var rules = store.Options.CreateGenerationRules();
- rules.ApplicationAssembly.ShouldBe(store.Options.ApplicationAssembly);
- rules.GeneratedCodeOutputPath.ShouldBe(store.Options.GeneratedCodeOutputPath);
- }
-
- [Fact]
- public void application_assembly_and_content_directory_from_StoreOptions()
- {
- using var host = Host.CreateDefaultBuilder(Array.Empty())
- .ConfigureServices(services =>
- {
- services.AddMarten(opts =>
- {
- opts.Connection(ConnectionSource.ConnectionString);
- opts.SetApplicationProject(GetType().Assembly);
- });
- }).Build();
-
- var store = host.Services.GetRequiredService().As();
- store.Options.ApplicationAssembly.ShouldBe(GetType().Assembly);
- var projectPath = AppContext.BaseDirectory.ParentDirectory().ParentDirectory().ParentDirectory();
- var expectedGeneratedCodeOutputPath = projectPath.ToFullPath().AppendPath("Internal", "Generated");
- store.Options.GeneratedCodeOutputPath.ShouldBe(expectedGeneratedCodeOutputPath);
- }
[Fact]
public void no_error_if_IHostEnvironment_does_not_exist()
@@ -171,13 +120,7 @@ public void no_error_if_IHostEnvironment_does_not_exist()
services.AddMarten(ConnectionSource.ConnectionString);
}).Build();
- var store = host.Services.GetRequiredService().As();
- store.Options.ApplicationAssembly.ShouldBe(GetType().Assembly);
- store.Options.GeneratedCodeOutputPath.TrimEnd(Path.DirectorySeparatorChar).ShouldBe(AppContext.BaseDirectory
- .AppendPath("Internal", "Generated").TrimEnd(Path.DirectorySeparatorChar));
-
- var rules = store.Options.CreateGenerationRules();
- rules.ApplicationAssembly.ShouldBe(store.Options.ApplicationAssembly);
+ host.Services.GetRequiredService().As().ShouldNotBeNull();
}
[Fact]
@@ -630,8 +573,6 @@ private static void ShouldHaveAllTheExpectedRegistrations(Container container,
container.GetInstance().ShouldBeSameAs(store.As().Tenancy);
- container.GetAllInstances().OfType().Count().ShouldBe(1);
-
container.Model.For>().Default.ShouldNotBeNull();
container.GetInstance()
diff --git a/src/CoreTests/document_store_usage_tests.cs b/src/CoreTests/document_store_usage_tests.cs
index 4157bc0894..716e9c25ba 100644
--- a/src/CoreTests/document_store_usage_tests.cs
+++ b/src/CoreTests/document_store_usage_tests.cs
@@ -146,22 +146,6 @@ public async Task usage_carries_flat_option_values_for_secondary_settings()
usage.PropertyFor("WriteSessionPreference").ShouldNotBeNull();
}
- [Fact]
- public async Task usage_includes_code_generation_child_descriptor()
- {
- using var host = await BuildHost(opts =>
- {
- opts.Connection(ConnectionSource.ConnectionString);
- opts.DatabaseSchemaName = "doc_usage_codegen";
- opts.Schema.For();
- });
-
- var usage = await GetUsageAsync(host);
-
- usage.CodeGeneration.ShouldNotBeNull();
- usage.CodeGeneration.GeneratedCodeMode.ShouldNotBeNullOrEmpty();
- }
-
[Fact]
public async Task event_store_usage_includes_global_aggregates_when_present()
{
diff --git a/src/CoreTests/jasper_fx_mechanics.cs b/src/CoreTests/jasper_fx_mechanics.cs
index 17c64898c2..ecee3a6f39 100644
--- a/src/CoreTests/jasper_fx_mechanics.cs
+++ b/src/CoreTests/jasper_fx_mechanics.cs
@@ -3,7 +3,6 @@
using System.Threading;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.CommandLine.Descriptions;
using JasperFx.Core.Reflection;
using JasperFx.Events;
@@ -140,39 +139,6 @@ public async Task build_system_parts_for_ancillary_document_stores_and_single_te
usage2.SubjectUri.ShouldBe(new Uri("marten://isecondstore"));
}
- [Fact]
- public async Task add_marten_store_for_ancillary_stores_respects_JasperFxOptions()
- {
- using var host = await Host.CreateDefaultBuilder()
- .ConfigureServices(services =>
- {
- services.AddMartenStore(opts =>
- {
- opts.Connection(ConnectionSource.ConnectionString);
- opts.DatabaseSchemaName = "first_store";
- });
-
- services.AddMartenStore(services =>
- {
- var opts = new StoreOptions();
- opts.Connection(ConnectionSource.ConnectionString);
- opts.DatabaseSchemaName = "second_store";
-
- return opts;
- });
-
- services.CritterStackDefaults(opts =>
- {
- opts.Development.GeneratedCodeMode = TypeLoadMode.Auto;
- opts.Production.GeneratedCodeMode = TypeLoadMode.Auto;
-
- });
- }).StartAsync();
-
- host.Services.GetRequiredService().Options.As().GeneratedCodeMode.ShouldBe(TypeLoadMode.Auto);
- host.Services.GetRequiredService().Options.As().GeneratedCodeMode.ShouldBe(TypeLoadMode.Auto);
- }
-
[Fact]
public async Task integration_with_describe_command_line()
{
diff --git a/src/CoreTests/reading_configuration_from_jasperfxoptions.cs b/src/CoreTests/reading_configuration_from_jasperfxoptions.cs
index b3b1d43309..23c0a1f2ca 100644
--- a/src/CoreTests/reading_configuration_from_jasperfxoptions.cs
+++ b/src/CoreTests/reading_configuration_from_jasperfxoptions.cs
@@ -1,14 +1,10 @@
-using System.Threading.Tasks;
using JasperFx;
-using JasperFx.Core;
-using Lamar;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using JasperFx.MultiTenancy;
+using Lamar;
using Marten;
using Marten.Testing.Harness;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
using Shouldly;
using Weasel.Core;
using Xunit;
@@ -28,14 +24,7 @@ public void all_the_defaults()
var store = container.GetInstance().As();
- var rules = store.Options.CreateGenerationRules();
-
store.Options.AutoCreateSchemaObjects.ShouldBe(AutoCreate.CreateOrUpdate);
- store.Options.GeneratedCodeMode.ShouldBe(TypeLoadMode.Dynamic);
-
- rules.GeneratedNamespace.ShouldBe("Marten.Generated");
- rules.SourceCodeWritingEnabled.ShouldBeTrue();
-
}
[Fact]
@@ -63,7 +52,6 @@ public void use_default_tenancy_id_style()
services.AddMarten(opts =>
{
opts.Connection(ConnectionSource.ConnectionString);
- // opts.TenantIdStyle = TenantIdStyle.ForceLowerCase;
});
services.CritterStackDefaults(x => x.TenantIdStyle = TenantIdStyle.ForceUpperCase);
@@ -71,233 +59,4 @@ public void use_default_tenancy_id_style()
container.GetInstance().As().Options.TenantIdStyle.ShouldBe(TenantIdStyle.ForceUpperCase);
}
-
- public static async Task bootstrapping_example()
- {
- #region sample_using_optimized_artifact_workflow
-
- using var host = await Host.CreateDefaultBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten("connection string");
-
- // In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
- services.CritterStackDefaults(x =>
- {
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
- x.Production.ResourceAutoCreate = AutoCreate.None;
- });
- }).StartAsync();
-
- #endregion
- }
-
- public static async Task bootstrapping_example_with_static()
- {
- #region sample_using_optimized_artifact_workflow_static
-
- using var host = await Host.CreateDefaultBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten("connection string");
-
- // In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
- services.CritterStackDefaults(x =>
- {
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
- x.Production.ResourceAutoCreate = AutoCreate.None;
- });
- }).StartAsync();
- #endregion
- }
-
- [Fact]
- public void using_optimized_mode_in_development()
- {
- using var host = new HostBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten(ConnectionSource.ConnectionString);
-
- // In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
- services.CritterStackDefaults(x =>
- {
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
- x.Production.ResourceAutoCreate = AutoCreate.None;
-
- x.Development.GeneratedCodeMode = TypeLoadMode.Auto;
- x.Development.ResourceAutoCreate = AutoCreate.CreateOrUpdate;
-
- x.TenantIdStyle = TenantIdStyle.ForceLowerCase;
- });
- })
- .UseEnvironment("Development")
- .Start();
-
-
- var store = host.Services.GetRequiredService().As();
-
- var rules = store.Options.CreateGenerationRules();
-
- store.Options.TenantIdStyle.ShouldBe(TenantIdStyle.ForceLowerCase);
-
- store.Options.AutoCreateSchemaObjects.ShouldBe(AutoCreate.CreateOrUpdate);
- store.Options.GeneratedCodeMode.ShouldBe(TypeLoadMode.Auto);
-
- rules.GeneratedNamespace.ShouldBe("Marten.Generated");
- rules.SourceCodeWritingEnabled.ShouldBeTrue();
- }
-
- [Fact]
- public void using_optimized_mode_in_production()
- {
- using var host = new HostBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten(ConnectionSource.ConnectionString);
-
- // In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
- services.CritterStackDefaults(x =>
- {
- x.Production.GeneratedCodeMode = TypeLoadMode.Auto;
- x.Production.ResourceAutoCreate = AutoCreate.None;
- x.Production.SourceCodeWritingEnabled = false;
- });
- })
- .UseEnvironment("Production")
- .Start();
-
-
- var store = host.Services.GetRequiredService().As();
-
- var rules = store.Options.CreateGenerationRules();
-
- store.Options.AutoCreateSchemaObjects.ShouldBe(AutoCreate.None);
- store.Options.GeneratedCodeMode.ShouldBe(TypeLoadMode.Auto);
-
- rules.GeneratedNamespace.ShouldBe("Marten.Generated");
- rules.SourceCodeWritingEnabled.ShouldBeFalse();
- }
-
- [Fact]
- public void application_assembly_from_critter_stack_defaults_flows_to_store_options()
- {
- var expectedAssembly = typeof(JasperFxOptions).Assembly;
-
- using var container = Container.For(services =>
- {
- services.AddMarten(ConnectionSource.ConnectionString);
- services.CritterStackDefaults(x => x.ApplicationAssembly = expectedAssembly);
- });
-
- var store = container.GetInstance().As();
-
- #pragma warning disable CS0618
- store.Options.ApplicationAssembly.ShouldBe(expectedAssembly);
- #pragma warning restore CS0618
- }
-
- [Fact]
- public void explicit_store_options_application_assembly_takes_precedence_over_critter_stack_defaults()
- {
- var critterStackAssembly = typeof(JasperFxOptions).Assembly;
- var explicitAssembly = typeof(StoreOptions).Assembly;
-
- using var container = Container.For(services =>
- {
- services.AddMarten(opts =>
- {
- opts.Connection(ConnectionSource.ConnectionString);
- #pragma warning disable CS0618
- opts.ApplicationAssembly = explicitAssembly;
- #pragma warning restore CS0618
- });
- services.CritterStackDefaults(x => x.ApplicationAssembly = critterStackAssembly);
- });
-
- var store = container.GetInstance().As();
-
- #pragma warning disable CS0618
- store.Options.ApplicationAssembly.ShouldBe(explicitAssembly);
- #pragma warning restore CS0618
- }
-
- public static void default_setup()
- {
- #region sample_simplest_possible_setup
-
- var store = DocumentStore.For("connection string");
-
- #endregion
- }
-
- [Fact]
- public void using_optimized_mode_in_production_override_type_load_mode()
- {
- using var host = new HostBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten(ConnectionSource.ConnectionString);
-
- // In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
- services.CritterStackDefaults(x =>
- {
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
- x.Production.ResourceAutoCreate = AutoCreate.None;
- x.Production.SourceCodeWritingEnabled = false;
- });
- })
- .UseEnvironment("Production")
- .Start();
-
-
- var store = host.Services.GetRequiredService().As();
-
- var rules = store.Options.CreateGenerationRules();
-
- store.Options.AutoCreateSchemaObjects.ShouldBe(AutoCreate.None);
- store.Options.GeneratedCodeMode.ShouldBe(TypeLoadMode.Static);
-
- rules.GeneratedNamespace.ShouldBe("Marten.Generated");
- rules.SourceCodeWritingEnabled.ShouldBeFalse();
- }
-
- [Fact]
- public void using_optimized_mode_in_production_override_environment_name()
- {
- using var host = new HostBuilder()
- .ConfigureServices(services =>
- {
- services.AddMarten(ConnectionSource.ConnectionString);
-
- // In a "Production" environment, we're turning off the
- // automatic database migrations and dynamic code generation
- services.CritterStackDefaults(x =>
- {
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
- x.Production.ResourceAutoCreate = AutoCreate.CreateOrUpdate;
-
- x.Development.GeneratedCodeMode = TypeLoadMode.Auto;
-
- x.DevelopmentEnvironmentName = "Local";
- });
- })
- .UseEnvironment("Local")
- .Start();
-
- var store = host.Services.GetRequiredService().As();
-
- var rules = store.Options.CreateGenerationRules();
-
- store.Options.AutoCreateSchemaObjects.ShouldBe(AutoCreate.CreateOrUpdate);
- store.Options.GeneratedCodeMode.ShouldBe(TypeLoadMode.Auto);
-
- rules.GeneratedNamespace.ShouldBe("Marten.Generated");
- rules.SourceCodeWritingEnabled.ShouldBeTrue();
- }
}
diff --git a/src/DaemonTests/Bugs/Bug_2177_query_session_tenancy_in_daemon.cs b/src/DaemonTests/Bugs/Bug_2177_query_session_tenancy_in_daemon.cs
index 80de61dbb9..b583b30a59 100644
--- a/src/DaemonTests/Bugs/Bug_2177_query_session_tenancy_in_daemon.cs
+++ b/src/DaemonTests/Bugs/Bug_2177_query_session_tenancy_in_daemon.cs
@@ -7,7 +7,6 @@
using Marten.Testing.Harness;
using Xunit;
using Bug2177;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Events;
using JasperFx.Events.Projections;
@@ -29,7 +28,6 @@ public async Task should_have_tenancy_set_correctly()
options.Events.MetadataConfig.EnableAll();
options.Projections.Add(ProjectionLifecycle.Async);
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Schema.For().MultiTenanted();
});
diff --git a/src/DaemonTests/TestingSupport/TestLogger.cs b/src/DaemonTests/TestingSupport/TestLogger.cs
index 2dd7597335..cbf3ed2889 100644
--- a/src/DaemonTests/TestingSupport/TestLogger.cs
+++ b/src/DaemonTests/TestingSupport/TestLogger.cs
@@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
diff --git a/src/DocumentDbTests/Concurrency/numeric_revisioning.cs b/src/DocumentDbTests/Concurrency/numeric_revisioning.cs
index 9eb1fb0d9f..cd64c0df3a 100644
--- a/src/DocumentDbTests/Concurrency/numeric_revisioning.cs
+++ b/src/DocumentDbTests/Concurrency/numeric_revisioning.cs
@@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using Marten;
using Marten.Exceptions;
@@ -387,13 +386,6 @@ public async Task load_and_update_revisioned_document_by_revision_from_dirty_ses
[Fact]
public async Task optimistic_concurrency_failure_with_update_revision_when_revision_number_equal_in_new_doc_and_db()
{
- StoreOptions(opts =>
- {
- opts.GeneratedCodeMode = TypeLoadMode.Auto;
- opts.GeneratedCodeOutputPath = AppContext.BaseDirectory.ParentDirectory().ParentDirectory()
- .ParentDirectory().AppendPath("Internal", "Generated");
- });
-
var doc1 = new RevisionedDoc { Name = "Tim" };
theSession.Store(doc1);
await theSession.SaveChangesAsync();
diff --git a/src/DocumentDbTests/Configuration/DocumentMappingTests.cs b/src/DocumentDbTests/Configuration/DocumentMappingTests.cs
index cbffd44984..314091704c 100644
--- a/src/DocumentDbTests/Configuration/DocumentMappingTests.cs
+++ b/src/DocumentDbTests/Configuration/DocumentMappingTests.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using JasperFx.Events;
using JasperFx.Events.Projections;
@@ -758,11 +757,6 @@ public class Organization
public class CustomIdGeneration: IIdGeneration
{
public bool IsNumeric { get; } = false;
-
- public void GenerateCode(GeneratedMethod assign, DocumentMapping mapping)
- {
- throw new NotSupportedException();
- }
}
diff --git a/src/DocumentDbTests/Writing/Identity/Sequences/CustomKeyGenerationTests.cs b/src/DocumentDbTests/Writing/Identity/Sequences/CustomKeyGenerationTests.cs
index 40d79aaaf9..f16e786339 100644
--- a/src/DocumentDbTests/Writing/Identity/Sequences/CustomKeyGenerationTests.cs
+++ b/src/DocumentDbTests/Writing/Identity/Sequences/CustomKeyGenerationTests.cs
@@ -1,10 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using JasperFx.Core;
-using JasperFx.CodeGeneration;
-using JasperFx.CodeGeneration.Frames;
using JasperFx.Core.Reflection;
using Marten;
using Marten.Schema;
@@ -19,13 +12,6 @@ namespace DocumentDbTests.Writing.Identity.Sequences;
public class CustomIdGeneration : IIdGeneration
{
public bool IsNumeric { get; } = false;
- public void GenerateCode(GeneratedMethod assign, DocumentMapping mapping)
- {
- var document = new Use(mapping.DocumentType);
- assign.Frames.Code($"_setter({{0}}, \"newId\");", document);
- assign.Frames.Code($"return {{0}}.{mapping.CodeGen.AccessId};", document);
- }
-
}
#endregion
diff --git a/src/EventSourcingTests/Aggregation/AggregationContext.cs b/src/EventSourcingTests/Aggregation/AggregationContext.cs
index 5d357c6347..2f3996c84e 100644
--- a/src/EventSourcingTests/Aggregation/AggregationContext.cs
+++ b/src/EventSourcingTests/Aggregation/AggregationContext.cs
@@ -3,7 +3,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using JasperFx.Events;
using JasperFx.Events.Aggregation;
@@ -32,19 +31,12 @@ protected override Task fixtureSetup()
public void UsingDefinition() where T : SingleStreamProjection, new()
{
_projection = new T();
-
- var rules = theStore.Options.CreateGenerationRules();
- rules.TypeLoadMode = TypeLoadMode.Dynamic;
}
public void UsingDefinition(Action> configure)
{
_projection = new SingleStreamProjection();
configure(_projection);
-
-
- var rules = theStore.Options.CreateGenerationRules();
- rules.TypeLoadMode = TypeLoadMode.Dynamic;
}
diff --git a/src/EventSourcingTests/Aggregation/aggregation_projection_validation_rules.cs b/src/EventSourcingTests/Aggregation/aggregation_projection_validation_rules.cs
index 88cd119248..447f0a89a4 100644
--- a/src/EventSourcingTests/Aggregation/aggregation_projection_validation_rules.cs
+++ b/src/EventSourcingTests/Aggregation/aggregation_projection_validation_rules.cs
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using JasperFx.Events;
using JasperFx.Events.Grouping;
diff --git a/src/EventSourcingTests/Bugs/Bug_2865_configuration_assertion_with_flat_table_projections.cs b/src/EventSourcingTests/Bugs/Bug_2865_configuration_assertion_with_flat_table_projections.cs
index d937c8933a..e92d56fee3 100644
--- a/src/EventSourcingTests/Bugs/Bug_2865_configuration_assertion_with_flat_table_projections.cs
+++ b/src/EventSourcingTests/Bugs/Bug_2865_configuration_assertion_with_flat_table_projections.cs
@@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Events.Daemon;
using JasperFx.Events.Projections;
using Marten;
@@ -39,9 +38,7 @@ public async Task should_be_able_to_assert_on_existence_of_flat_table_functions(
appBuilder.Services.CritterStackDefaults(x =>
{
- x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
- x.Production.SourceCodeWritingEnabled = false;
});
var app = appBuilder.Build();
diff --git a/src/EventSourcingTests/Bugs/Bug_3791_migrating_from_no_partitioning_to_having_partitioning.cs b/src/EventSourcingTests/Bugs/Bug_3791_migrating_from_no_partitioning_to_having_partitioning.cs
index 192f89c2c7..eb7986c73f 100644
--- a/src/EventSourcingTests/Bugs/Bug_3791_migrating_from_no_partitioning_to_having_partitioning.cs
+++ b/src/EventSourcingTests/Bugs/Bug_3791_migrating_from_no_partitioning_to_having_partitioning.cs
@@ -1,5 +1,4 @@
using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
using JasperFx.Events;
using Marten;
using Marten.Testing.Harness;
@@ -18,7 +17,6 @@ public async Task try_it_out()
//o.Events.UseArchivedStreamPartitioning = true;
o.DisableNpgsqlLogging = true;
o.Events.UseOptimizedProjectionRebuilds = true;
- o.GeneratedCodeMode = TypeLoadMode.Auto;
o.Events.AppendMode = EventAppendMode.Quick;
o.Events.UseIdentityMapForAggregates = true;
o.DatabaseSchemaName = "some_custom_schema";
@@ -35,7 +33,6 @@ public async Task try_it_out()
o.Events.UseArchivedStreamPartitioning = true;
o.DisableNpgsqlLogging = true;
o.Events.UseOptimizedProjectionRebuilds = true;
- o.GeneratedCodeMode = TypeLoadMode.Auto;
o.Events.AppendMode = EventAppendMode.Quick;
o.Events.UseIdentityMapForAggregates = true;
o.DatabaseSchemaName = "some_custom_schema";
diff --git a/src/EventSourcingTests/Projections/CodeGeneration/aggregation_with_event_type_hierarchy.cs b/src/EventSourcingTests/Projections/CodeGeneration/aggregation_with_event_type_hierarchy.cs
index 2009095895..8328ab3ad2 100644
--- a/src/EventSourcingTests/Projections/CodeGeneration/aggregation_with_event_type_hierarchy.cs
+++ b/src/EventSourcingTests/Projections/CodeGeneration/aggregation_with_event_type_hierarchy.cs
@@ -2,7 +2,6 @@
using System.Linq;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten.Events.Projections;
using Marten.Testing.Harness;
using Shouldly;
@@ -17,7 +16,6 @@ public aggregation_with_event_type_hierarchy()
{
StoreOptions(x =>
{
- x.GeneratedCodeMode = TypeLoadMode.Auto;
x.AutoCreateSchemaObjects = AutoCreate.All;
x.Schema.For().Identity(something => something.Id);
diff --git a/src/EventSourcingTests/SchemaChange/MultipleVersions/MultipleSchemaVersions.cs b/src/EventSourcingTests/SchemaChange/MultipleVersions/MultipleSchemaVersions.cs
index 78393ebc8e..c7140389dd 100644
--- a/src/EventSourcingTests/SchemaChange/MultipleVersions/MultipleSchemaVersions.cs
+++ b/src/EventSourcingTests/SchemaChange/MultipleVersions/MultipleSchemaVersions.cs
@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
using JasperFx.Events;
using Marten;
using Marten.Events;
@@ -32,7 +31,6 @@ Action configureV3Upcasters
StoreOptions(options =>
{
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Projections.Snapshot(SnapshotLifecycle.Inline);
});
await theStore.EnsureStorageExistsAsync(typeof(StreamAction));
@@ -79,7 +77,6 @@ Action configureV3Upcasters
StoreOptions(options =>
{
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Projections.Snapshot(SnapshotLifecycle.Inline);
});
await theStore.EnsureStorageExistsAsync(typeof(StreamAction));
@@ -131,7 +128,6 @@ private async Task CheckV2WithTheSameNameUpcasting(
{
using var storeV2 = SeparateStore(options =>
{
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Projections.Snapshot(SnapshotLifecycle.Inline);
////////////////////////////////////////////////////////
// 2.1. Define Upcast methods from V1 to V2
@@ -210,7 +206,6 @@ decimal price
{
using var storeV3 = SeparateStore(options =>
{
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Projections.Snapshot(SnapshotLifecycle.Inline);
////////////////////////////////////////////////////////
// 3.1. Define Upcast methods from V1 to V3, and from V2 to V3
@@ -291,7 +286,6 @@ private async Task CheckV2WithDifferentNameUpcasting(
{
using var storeV2 = SeparateStore(options =>
{
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Projections.Snapshot(SnapshotLifecycle.Inline);
////////////////////////////////////////////////////////
// 2.1. Define Upcast methods from V1 to V2
@@ -369,7 +363,6 @@ private async Task CheckV3WithDifferentNameUpcasting(
{
using var storeV3 = SeparateStore(options =>
{
- options.GeneratedCodeMode = TypeLoadMode.Auto;
options.Projections.Snapshot(SnapshotLifecycle.Inline);
////////////////////////////////////////////////////////
// 3.1. Define Upcast methods from V1 to V3, and from V2 to V3
diff --git a/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs b/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs
index c0af123513..0ec58e3624 100644
--- a/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs
+++ b/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs
@@ -5,7 +5,6 @@
using EventSourcingTests.Projections;
using EventSourcingTests.Utils;
using JasperFx;
-using JasperFx.CodeGeneration;
using Marten;
using Marten.Events.Projections;
using Marten.Storage;
diff --git a/src/EventStoreMigrations/Program.cs b/src/EventStoreMigrations/Program.cs
index 4a10afc1df..4ae3148cbc 100644
--- a/src/EventStoreMigrations/Program.cs
+++ b/src/EventStoreMigrations/Program.cs
@@ -1,5 +1,4 @@
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Events;
using Marten;
using Marten.Events;
@@ -26,8 +25,6 @@ public static IHostBuilder CreateHostBuilder(string[] args)
opts.DatabaseSchemaName = "cli";
opts.Connection(ConnectionSource.ConnectionString);
- opts.GeneratedCodeMode = TypeLoadMode.Dynamic;
-
opts.Events.StreamIdentity = StreamIdentity.AsString;
opts.Events.MetadataConfig.HeadersEnabled = true;
opts.Events.AddEventType(typeof(Started));
diff --git a/src/Marten.AotSmoke/Program.cs b/src/Marten.AotSmoke/Program.cs
index db7071ff76..e22d550834 100644
--- a/src/Marten.AotSmoke/Program.cs
+++ b/src/Marten.AotSmoke/Program.cs
@@ -37,8 +37,6 @@
// (The build itself doesn't catch a missing emission — the SG silently
// skips when its preconditions don't hold; the runtime check is the
// sentinel.)
-// - StoreOptions.GeneratedCodeMode = TypeLoadMode.Static — pins the
-// consumer profile that AOT-publishing apps would set.
// - Host.CreateApplicationBuilder + Build + DI resolution of
// IDocumentStore — the boot path consumers actually hit.
//
@@ -55,7 +53,6 @@
// libraries — the static inventory at audit/projections-inventory.md
// covers that. This program is the regression sentinel.
-using JasperFx.CodeGeneration;
using JasperFx.Events;
using JasperFx.Events.Projections;
using Marten;
@@ -72,11 +69,8 @@
{
opts.Connection(placeholderConnectionString);
- // Pin the consumer profile an AOT-publishing app would set. Marten 9
- // retired the runtime-codegen path entirely, so this setting is a
- // documented no-op kept for source-compatibility — exercising it here
- // pins that compile-time contract.
- opts.GeneratedCodeMode = TypeLoadMode.Static;
+ // Marten 9 retired the runtime-codegen path entirely — there's nothing
+ // to pin here for AOT consumers, the closed-shape adapter is always used.
// Exercise the document-mapping surface — registers the closed-shape
// IDocumentStorage path (#4404). DocumentMapping infers the Id member
diff --git a/src/Marten.Testing.OtherAssembly/ShortGuid.cs b/src/Marten.Testing.OtherAssembly/ShortGuid.cs
index b37a38d574..ad80012190 100644
--- a/src/Marten.Testing.OtherAssembly/ShortGuid.cs
+++ b/src/Marten.Testing.OtherAssembly/ShortGuid.cs
@@ -1,9 +1,4 @@
using System;
-using System.Collections.Generic;
-using JasperFx.CodeGeneration;
-using JasperFx.CodeGeneration.Frames;
-using JasperFx.Core.Reflection;
-using Marten.Schema;
using Marten.Schema.Identity;
namespace Marten.Testing.OtherAssembly;
@@ -18,14 +13,5 @@ public static string NewGuid()
public class String2IdGeneration: IIdGeneration
{
- public void GenerateCode(GeneratedMethod method, DocumentMapping mapping)
- {
- var use = new Use(mapping.DocumentType);
- method.Frames.Code(
- "if ({0}." + mapping.IdMember.Name + " == null) _setter({0}, global::" +
- typeof(ShortGuid).FullNameInCode() + ".NewGuid());", use);
- method.Frames.Code("return {0}." + mapping.IdMember.Name + ";", use);
- }
-
public bool IsNumeric => false;
}
diff --git a/src/Marten.Testing/Harness/DefaultStoreFixture.cs b/src/Marten.Testing/Harness/DefaultStoreFixture.cs
index a9001d1e23..627a69464f 100644
--- a/src/Marten.Testing/Harness/DefaultStoreFixture.cs
+++ b/src/Marten.Testing/Harness/DefaultStoreFixture.cs
@@ -1,8 +1,6 @@
using System;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
-using JasperFx.CodeGeneration.Util;
using JasperFx.Events;
using Marten.Events;
using Npgsql;
@@ -36,9 +34,6 @@ public Task InitializeAsync()
{
opts.Connection(ConnectionSource.ConnectionString);
opts.AutoCreateSchemaObjects = AutoCreate.All;
-
- opts.GeneratedCodeMode = TypeLoadMode.Auto;
- opts.ApplicationAssembly = GetType().Assembly;
});
// Do this exactly once and no more.
diff --git a/src/Marten.Testing/Harness/IntegrationContext.cs b/src/Marten.Testing/Harness/IntegrationContext.cs
index cfaff2362f..a8bd5a356e 100644
--- a/src/Marten.Testing/Harness/IntegrationContext.cs
+++ b/src/Marten.Testing/Harness/IntegrationContext.cs
@@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using JasperFx.Events;
using Marten.Events;
@@ -70,9 +69,6 @@ protected IDocumentStore SeparateStore()
{
opts.Connection(ConnectionSource.ConnectionString);
opts.AutoCreateSchemaObjects = AutoCreate.All;
-
- opts.GeneratedCodeMode = TypeLoadMode.Auto;
- opts.ApplicationAssembly = GetType().Assembly;
});
}
diff --git a/src/Marten/DocumentStore.CompiledQueryCollection.cs b/src/Marten/DocumentStore.CompiledQueryCollection.cs
index fc8b42d449..88b69e4de2 100644
--- a/src/Marten/DocumentStore.CompiledQueryCollection.cs
+++ b/src/Marten/DocumentStore.CompiledQueryCollection.cs
@@ -4,7 +4,6 @@
using System.Threading.Tasks;
using ImTools;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using Marten.Exceptions;
@@ -67,9 +66,8 @@ internal ICompiledQuerySource GetCompiledQuerySourceFor(ICompiledQue
// registered a descriptor for this query type (consumer assembly missing
// the [JasperFxAssembly] marker, or a query type registered at runtime via
// reflection) we build the descriptor reflectively from the freshly-walked
- // CompiledQueryPlan and cache it in the registry. Subsequent calls hit the
- // fast registry path. Replaces the previous fallthrough to
- // CompiledQuerySourceBuilder / JasperFx.RuntimeCompiler.
+ // CompiledQueryPlan and cache it in the registry. Subsequent calls hit
+ // the fast registry path.
descriptor = RuntimeCompiledQueryDescriptorFactory.Build(plan);
CompiledQueryHandlerRegistry.Register(query.GetType(), descriptor);
}
@@ -84,29 +82,13 @@ internal ICompiledQuerySource GetCompiledQuerySourceFor(ICompiledQue
}
}
-public partial class DocumentStore: ICodeFileCollection
+public partial class DocumentStore
{
private readonly CompiledQueryCollection _dirtyTrackedCompiledQueries;
private readonly CompiledQueryCollection _identityMapCompiledQueries;
private readonly CompiledQueryCollection _lightweightCompiledQueries;
private readonly CompiledQueryCollection _queryOnlyCompiledQueries;
- public GenerationRules Rules => Options.CreateGenerationRules();
-
- IReadOnlyList ICodeFileCollection.BuildFiles()
- {
- // #4454 Phase 1E: compiled queries no longer emit ICodeFile entries —
- // dispatch runs through CompiledQueryHandlerRegistry / source-gen +
- // RuntimeCompiledQueryDescriptorFactory. The codegen path (and the
- // `dotnet marten codegen` CLI surface that consumed it) is retired
- // entirely in Phase 5. Returning an empty list keeps DocumentStore's
- // ICodeFileCollection contract intact for non-compiled-query consumers
- // until then.
- return Array.Empty();
- }
-
- string ICodeFileCollection.ChildNamespace { get; } = "CompiledQueries";
-
internal ICompiledQuerySource GetCompiledQuerySourceFor(ICompiledQuery query,
QuerySession session) where TDoc : notnull
{
diff --git a/src/Marten/DocumentStore.DocumentStoreUsage.cs b/src/Marten/DocumentStore.DocumentStoreUsage.cs
index 45b74b503d..90d2e03315 100644
--- a/src/Marten/DocumentStore.DocumentStoreUsage.cs
+++ b/src/Marten/DocumentStore.DocumentStoreUsage.cs
@@ -33,19 +33,6 @@ public partial class DocumentStore : IDocumentStoreUsageSource
EnumStorage = Options.EnumStorage.ToString(),
};
- // Code-generation snapshot — wrapped as a child descriptor (rather than
- // flattened) so the four obsolete-on-StoreOptions properties stay
- // cohesive even after they ride out the deprecation window.
-#pragma warning disable CS0618 // intentional: building a diagnostic snapshot of obsolete settings
- usage.CodeGeneration = new CodeGenerationDescriptor
- {
- ApplicationAssembly = Options.ApplicationAssembly?.GetName().FullName,
- SourceCodeWritingEnabled = Options.SourceCodeWritingEnabled,
- GeneratedCodeOutputPath = Options.GeneratedCodeOutputPath,
- GeneratedCodeMode = Options.GeneratedCodeMode.ToString(),
- };
-#pragma warning restore CS0618
-
// Per-document-type mappings — Documents collection. Skip mappings that
// don't emit schema (structural-typed, internal-only) so the snapshot
// matches what an operator would see in the database.
diff --git a/src/Marten/DocumentStore.cs b/src/Marten/DocumentStore.cs
index bdbff84d6e..6a7a0159bc 100644
--- a/src/Marten/DocumentStore.cs
+++ b/src/Marten/DocumentStore.cs
@@ -8,7 +8,6 @@
using System.Threading.Tasks;
using System.Transactions;
using JasperFx;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using JasperFx.Descriptors;
@@ -87,32 +86,13 @@ public DocumentStore(StoreOptions options)
// is called with a type that has [NaturalKey]. Assembly-level scanning was
// removed because it caused spurious InvalidProjectionException failures
// when test projects share compile references with incompatible stream identity types.
- //
- // 9.0: Skip AssertValidity when running in TypeLoadMode.Static (#4305).
- // Static mode means the runtime is loading pre-generated artifacts that
- // would not have been emitted if validation had failed at codegen time —
- // re-running the validation walk on every host start is pure cold-start
- // overhead. Dynamic and Auto modes still validate, so any hot-reload or
- // first-run codegen path keeps the existing fail-fast behavior.
- if (Options.GeneratedCodeMode != TypeLoadMode.Static)
- {
- Options.Projections.AssertValidity(Options);
- }
+ Options.Projections.AssertValidity(Options);
if (Options.LogFactory != null)
{
Options.Projections.AttachLogging(Options.LogFactory);
}
- // marten#4370 Phase 2: compute the codegen snapshot verdict and log
- // any rejection. The verdict is observed but not yet acted on —
- // Phase 2 ships the plumbing so subsequent PRs can add concrete
- // snapshot artifacts (event-name map, document-storage map,
- // projection apply factories) each gated by this verdict.
- MartenSnapshot.VerifyAtBoot(
- Options,
- Options.LogFactory?.CreateLogger("Marten.Snapshot"));
-
Advanced = new AdvancedOperations(this);
Diagnostics = new Diagnostics(this);
@@ -136,12 +116,6 @@ public DocumentStore(StoreOptions options)
}
Identity = new(Options.StoreName.ToLowerInvariant(), "marten");
-
- // marten#4370 Phase 2: persist the fingerprint at the end of
- // construction so the next boot's VerifyAtBoot has a baseline
- // to compare against. Best-effort — persistence failure must not
- // break construction.
- MartenSnapshot.PersistFingerprint(Options);
}
public ITenancy Tenancy => Options.Tenancy;
diff --git a/src/Marten/Events/EventGraph.GeneratesCode.cs b/src/Marten/Events/EventGraph.GeneratesCode.cs
deleted file mode 100644
index 06b5ccb3eb..0000000000
--- a/src/Marten/Events/EventGraph.GeneratesCode.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Reflection;
-using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
-using JasperFx.Events;
-using Marten.Internal.Storage;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Marten.Events;
-
-#nullable enable
-public partial class EventGraph: ICodeFile
-{
- internal DocumentProvider? Provider { get; private set; }
-
- void ICodeFile.AssembleTypes(GeneratedAssembly assembly)
- {
- // #4454 Phase 2: event storage is fully closed-shape — no Roslyn emit
- // for the event-store write path. The ICodeFile contract is preserved
- // for now so DocumentStore's ICodeFileCollection.BuildFiles aggregation
- // still walks EventGraph; Phase 5 retires the contract entirely.
- }
-
- public bool AttachTypesSynchronously(GenerationRules rules, Assembly assembly, IServiceProvider? services,
- string containingNamespace)
- {
- // Closed-shape adapter is constructed directly — no codegen lookup,
- // no JasperFx.RuntimeCompiler fallback. ProviderGraph triggers this
- // path on first IEvent storage request.
- var closedShape = new Marten.EventStorage.ClosedShapeEventDocumentStorage(Options);
- Provider = new DocumentProvider(null, closedShape, closedShape, closedShape, closedShape);
- return true;
- }
-
- Task ICodeFile.AttachTypes(GenerationRules rules, Assembly assembly, IServiceProvider? services,
- string containingNamespace)
- {
- var found = AttachTypesSynchronously(rules, assembly, services, containingNamespace);
- return Task.FromResult(found);
- }
-
- string ICodeFile.FileName => "EventStorage";
-
-}
diff --git a/src/Marten/Events/EventGraph.cs b/src/Marten/Events/EventGraph.cs
index 0059eba24c..a33ed65984 100644
--- a/src/Marten/Events/EventGraph.cs
+++ b/src/Marten/Events/EventGraph.cs
@@ -5,7 +5,6 @@
using System.Threading.Tasks;
using ImTools;
using JasperFx.Blocks;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using JasperFx.Descriptors;
@@ -42,7 +41,7 @@ namespace Marten.Events;
Justification = "Class-level: uses Type.MakeGenericType / MethodInfo.MakeGenericMethod / Activator.CreateInstance / FastExpressionCompiler — runtime code generation. AOT consumers pre-generate codegen artifacts (codegen write) and supply source-generator-backed serializer impls per the AOT publishing guide.")]
public partial class EventGraph: EventRegistry, IEventStoreOptions, IReadOnlyEventStoreOptions,
IDisposable, IAsyncDisposable,
- IAggregationSourceFactory, IDescribeMyself, ICodeFileCollection
+ IAggregationSourceFactory, IDescribeMyself
{
private readonly Cache _aggregateNameByType =
new(type => type.IsGenericType ? type.ShortNameInCode() : type.Name.ToTableAlias());
@@ -777,13 +776,19 @@ private void autoDiscoverTagTypesFromProjections()
}
}
- IReadOnlyList ICodeFileCollection.BuildFiles()
- {
- return [this];
- }
+ public List GlobalAggregates { get; } = new();
- string ICodeFileCollection.ChildNamespace => "EventStore";
+ internal Marten.Internal.Storage.DocumentProvider? Provider { get; private set; }
- GenerationRules ICodeFileCollection.Rules => Options.CreateGenerationRules();
- public List GlobalAggregates { get; } = new();
+ ///
+ /// Constructs the closed-shape event document storage adapter for this
+ /// EventGraph and caches it as . The closed-shape
+ /// adapter is built reflectively at runtime — no codegen is involved.
+ /// ProviderGraph invokes this on the first IEvent storage request.
+ ///
+ internal void AttachTypesSynchronously()
+ {
+ var closedShape = new Marten.EventStorage.ClosedShapeEventDocumentStorage(Options);
+ Provider = new Marten.Internal.Storage.DocumentProvider(null!, closedShape, closedShape, closedShape, closedShape);
+ }
}
diff --git a/src/Marten/Events/Projections/Flattened/DecrementMap.cs b/src/Marten/Events/Projections/Flattened/DecrementMap.cs
index 4351288d40..df671d7ef4 100644
--- a/src/Marten/Events/Projections/Flattened/DecrementMap.cs
+++ b/src/Marten/Events/Projections/Flattened/DecrementMap.cs
@@ -1,5 +1,4 @@
using System;
-using JasperFx.CodeGeneration.Model;
using Weasel.Postgresql.Tables;
namespace Marten.Events.Projections.Flattened;
diff --git a/src/Marten/Events/Projections/Flattened/IColumnMap.cs b/src/Marten/Events/Projections/Flattened/IColumnMap.cs
index 6145e13732..420ef095c9 100644
--- a/src/Marten/Events/Projections/Flattened/IColumnMap.cs
+++ b/src/Marten/Events/Projections/Flattened/IColumnMap.cs
@@ -1,4 +1,3 @@
-using JasperFx.CodeGeneration.Model;
using Weasel.Postgresql.Tables;
namespace Marten.Events.Projections.Flattened;
diff --git a/src/Marten/Events/Projections/Flattened/IncrementMap.cs b/src/Marten/Events/Projections/Flattened/IncrementMap.cs
index 78c4547a63..ac755dabdf 100644
--- a/src/Marten/Events/Projections/Flattened/IncrementMap.cs
+++ b/src/Marten/Events/Projections/Flattened/IncrementMap.cs
@@ -1,5 +1,4 @@
using System;
-using JasperFx.CodeGeneration.Model;
using Weasel.Postgresql.Tables;
namespace Marten.Events.Projections.Flattened;
diff --git a/src/Marten/Events/Projections/Flattened/MemberMap.cs b/src/Marten/Events/Projections/Flattened/MemberMap.cs
index 74f90e57d2..d08183342e 100644
--- a/src/Marten/Events/Projections/Flattened/MemberMap.cs
+++ b/src/Marten/Events/Projections/Flattened/MemberMap.cs
@@ -3,7 +3,6 @@
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
-using JasperFx.CodeGeneration.Model;
using JasperFx.Core;
using Marten.Linq.Parsing;
using Marten.Util;
diff --git a/src/Marten/Events/Projections/Flattened/SetValueMap.cs b/src/Marten/Events/Projections/Flattened/SetValueMap.cs
index 6d08ac0f51..e83fc7ffaa 100644
--- a/src/Marten/Events/Projections/Flattened/SetValueMap.cs
+++ b/src/Marten/Events/Projections/Flattened/SetValueMap.cs
@@ -1,5 +1,4 @@
using System;
-using JasperFx.CodeGeneration.Model;
using Weasel.Postgresql.Tables;
namespace Marten.Events.Projections.Flattened;
diff --git a/src/Marten/Events/Schema/VersionColumn.cs b/src/Marten/Events/Schema/VersionColumn.cs
index b11264cd1f..0242840be0 100644
--- a/src/Marten/Events/Schema/VersionColumn.cs
+++ b/src/Marten/Events/Schema/VersionColumn.cs
@@ -1,8 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
-using JasperFx.CodeGeneration;
-using JasperFx.CodeGeneration.Frames;
-using Npgsql;
-
namespace Marten.Events.Schema;
internal class VersionColumn: EventTableColumn
diff --git a/src/Marten/Events/TestSupport/ProjectionScenario.EventOperations.cs b/src/Marten/Events/TestSupport/ProjectionScenario.EventOperations.cs
index 1c40cd54f7..dbb274478f 100644
--- a/src/Marten/Events/TestSupport/ProjectionScenario.EventOperations.cs
+++ b/src/Marten/Events/TestSupport/ProjectionScenario.EventOperations.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using JasperFx.Events;
diff --git a/src/Marten/Exceptions/EventDeserializationFailureException.cs b/src/Marten/Exceptions/EventDeserializationFailureException.cs
index 961c81e24e..244cc20ce6 100644
--- a/src/Marten/Exceptions/EventDeserializationFailureException.cs
+++ b/src/Marten/Exceptions/EventDeserializationFailureException.cs
@@ -1,5 +1,4 @@
using System;
-using JasperFx.CodeGeneration;
using JasperFx.Core.Reflection;
using JasperFx.Events;
using JasperFx.Events.Daemon;
diff --git a/src/Marten/Exceptions/InvalidCompiledQueryException.cs b/src/Marten/Exceptions/InvalidCompiledQueryException.cs
index e2abf8bb2e..9b9a406e3a 100644
--- a/src/Marten/Exceptions/InvalidCompiledQueryException.cs
+++ b/src/Marten/Exceptions/InvalidCompiledQueryException.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.Serialization;
-using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
diff --git a/src/Marten/Internal/CodeGeneration/FrameCollectionExtensions.cs b/src/Marten/Internal/CodeGeneration/FrameCollectionExtensions.cs
deleted file mode 100644
index 30758c74cb..0000000000
--- a/src/Marten/Internal/CodeGeneration/FrameCollectionExtensions.cs
+++ /dev/null
@@ -1,314 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Threading;
-using JasperFx.CodeGeneration;
-using JasperFx.CodeGeneration.Frames;
-using JasperFx.CodeGeneration.Model;
-using JasperFx.Core;
-using JasperFx.Core.Reflection;
-using Marten.Events.CodeGeneration;
-using Marten.Linq.Parsing;
-using Marten.Schema;
-using Marten.Util;
-using Weasel.Postgresql;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Marten.Internal.CodeGeneration;
-
-[UnconditionalSuppressMessage("Trimming", "IL2026",
- Justification = "Class-level: consumes RUC-annotated members (ISerializer, JasperFx.Events aggregator graph, CloseAndBuildAs / GenericFactoryCache fallbacks, FastExpressionCompiler). Document/event/projection types flow in from StoreOptions / Schema.For() / projection registration and are preserved per the AOT publishing guide; AOT consumers supply a source-generator-backed serializer + pre-generated codegen artifacts.")]
-[UnconditionalSuppressMessage("Trimming", "IL2070",
- Justification = "Class-level: reflects PublicMethods/PublicProperties on a Type whose runtime instance is preserved at the StoreOptions / projection-registration boundary.")]
-[UnconditionalSuppressMessage("AOT", "IL3050",
- Justification = "Class-level: uses Type.MakeGenericType / MethodInfo.MakeGenericMethod / Activator.CreateInstance / FastExpressionCompiler — runtime code generation. AOT consumers pre-generate codegen artifacts (codegen write) and supply source-generator-backed serializer impls per the AOT publishing guide.")]
-internal static class FrameCollectionExtensions
-{
- public const string DocumentVariableName = "document";
-
- public static void StoreInIdentityMap(this FramesCollection frames, DocumentMapping mapping)
- {
- frames.Code("_identityMap[id] = document;");
- }
-
- public static void StoreTracker(this FramesCollection frames)
- {
- frames.Code("StoreTracker({0}, document);", Use.Type());
- }
-
- public static void DeserializeDocument(this FramesCollection frames, DocumentMapping mapping, int index)
- {
- var documentType = mapping.DocumentType;
- var document = new Variable(documentType, DocumentVariableName);
- if (mapping is DocumentMapping d)
- {
- if (!d.IsHierarchy())
- {
- frames.Code($@"
-{documentType.FullNameInCode()} document;
-document = _serializer.FromJson<{documentType.FullNameInCode()}>(reader, {index});
-").Creates(document);
- }
- else
- {
- // Hierarchy path is different
- frames.Code($@"
-{documentType.FullNameInCode()} document;
-var typeAlias = reader.GetFieldValue({index + 1});
-document = ({documentType.FullNameInCode()}) _serializer.FromJson(_mapping.TypeFor(typeAlias), reader, {index});
-").Creates(document);
- }
- }
- }
-
- public static void MarkAsLoaded(this FramesCollection frames)
- {
- frames.Code($"{{0}}.{nameof(IMartenSession.MarkAsDocumentLoaded)}(id, document);",
- Use.Type());
- }
-
- public static void DeserializeDocumentAsync(this FramesCollection frames, DocumentMapping mapping, int index)
- {
- var documentType = mapping.DocumentType;
- var document = new Variable(documentType, DocumentVariableName);
-
- if (!mapping.IsHierarchy())
- {
- frames.CodeAsync($@"
-{documentType.FullNameInCode()} document;
-document = await _serializer.FromJsonAsync<{documentType.FullNameInCode()}>(reader, {index}, {{0}}).ConfigureAwait(false);
-", Use.Type()).Creates(document);
- }
- else
- {
- frames.CodeAsync($@"
-{documentType.FullNameInCode()} document;
-var typeAlias = await reader.GetFieldValueAsync({index + 1}, {{0}}).ConfigureAwait(false);
-document = ({documentType.FullNameInCode()}) (await _serializer.FromJsonAsync(_mapping.TypeFor(typeAlias), reader, {index}, {{0}}).ConfigureAwait(false));
-", Use.Type()).Creates(document);
- }
- }
-
- ///
- /// Generates the necessary setter code to set a value of a document.
- /// Handles internal/private setters
- ///
- ///
- ///
- ///
- ///
- ///
- public static void SetMemberValue(this FramesCollection frames, MemberInfo member, string variableName,
- Type documentType, GeneratedType generatedType)
- {
- if (member is PropertyInfo property)
- {
- if (property.CanWrite)
- {
- if (property.SetMethod.IsPublic)
- {
- frames.SetPublicMemberValue(member, variableName, documentType);
- }
- else
- {
- var setterFieldName = generatedType.InitializeLambdaSetterProperty(member, documentType);
- frames.Code($"{setterFieldName}({{0}}, {variableName});", new Use(documentType));
- }
-
- return;
- }
- }
- else if (member is FieldInfo field)
- {
- if (field.IsPublic)
- {
- frames.SetPublicMemberValue(member, variableName, documentType);
- }
- else
- {
- var setterFieldName = generatedType.InitializeLambdaSetterProperty(member, documentType);
- frames.Code($"{setterFieldName}({{0}}, {variableName});", new Use(documentType));
- }
-
- return;
- }
-
- throw new ArgumentOutOfRangeException(nameof(member), $"MemberInfo {member} is not valid in this usage. ");
- }
-
- public static string InitializeLambdaSetterProperty(this GeneratedType generatedType, MemberInfo member,
- Type documentType)
- {
- var setterFieldName = $"{member.Name}Writer";
-
- if (generatedType.Setters.All(x => x.PropName != setterFieldName))
- {
- var memberType = member.GetRawMemberType()!;
- var actionType = typeof(Action<,>).MakeGenericType(documentType, memberType);
- var expression =
- $"{typeof(LambdaBuilder).FullNameInCode()}.{nameof(LambdaBuilder.Setter)}<{documentType.FullNameInCode()},{memberType.FullNameInCode()}>(typeof({documentType.FullNameInCode()}).GetProperty(\"{member.Name}\"))";
-
- var constant = new Variable(actionType, expression);
-
- var setter = Setter.StaticReadOnly(setterFieldName, constant);
-
- generatedType.Setters.Add(setter);
- }
-
- return setterFieldName;
- }
-
- private static void SetPublicMemberValue(this FramesCollection frames, MemberInfo member, string variableName,
- Type documentType)
- {
- frames.Code($"{{0}}.{member.Name} = {variableName};", new Use(documentType));
- }
-
- public static void AssignMemberFromReader(this GeneratedMethod method, GeneratedType generatedType,
- int index,
- Expression> memberExpression)
- {
- var member = MemberFinder.Determine(memberExpression).Single();
- var variableName = member.Name.ToCamelCase();
- method.Frames.Code(
- $"var {variableName} = reader.GetFieldValue<{member.GetMemberType()!.FullNameInCode()}>({index});");
-
- method.Frames.SetMemberValue(member, variableName, typeof(T), generatedType);
- }
-
- public static void AssignMemberFromReader(this GeneratedMethod method, GeneratedType generatedType, int index,
- Type documentType, string memberName)
- {
- var member = documentType.GetMember(memberName).Single();
- var variableName = member.Name.ToCamelCase();
- method.Frames.Code(
- $"var {variableName} = reader.GetFieldValue<{member.GetMemberType()!.FullNameInCode()}>({index});");
-
- method.Frames.SetMemberValue(member, variableName, documentType, generatedType);
- }
-
- public static void AssignMemberFromReader(this GeneratedMethod method, GeneratedType generatedType,
- int index,
- Expression>> memberExpression)
- {
- var member = FindMembers.Determine(memberExpression).Single();
- var variableName = member.Name.ToCamelCase();
-
- method.Frames.Code(
- $"var {variableName} = _options.Serializer().FromJson<{member.GetMemberType()!.FullNameInCode()}>(reader, {index});");
-
- method.Frames.SetMemberValue(member, variableName, typeof(T), generatedType);
- }
-
- public static void AssignMemberFromReaderAsync(this GeneratedMethod method, GeneratedType generatedType,
- int index,
- Expression> memberExpression)
- {
- var member = MemberFinder.Determine(memberExpression).Single();
- var variableName = member.Name.ToCamelCase();
- method.Frames.Code(
- $"var {variableName} = await reader.GetFieldValueAsync<{member.GetMemberType()!.FullNameInCode()}>({index}, {{0}}).ConfigureAwait(false);",
- Use.Type());
-
- method.Frames.SetMemberValue(member, variableName, typeof(T), generatedType);
- }
-
- public static void AssignMemberFromReaderAsync(this GeneratedMethod method, GeneratedType generatedType,
- int index,
- Expression>> memberExpression)
- {
- var member = FindMembers.Determine(memberExpression).Single();
- var variableName = member.Name.ToCamelCase();
-
- method.Frames.Code(
- $"var {variableName} = await _options.Serializer().FromJsonAsync<{member.GetMemberType()!.FullNameInCode()}>(reader, {index}, {{0}}).ConfigureAwait(false);",
- Use.Type());
-
- method.Frames.SetMemberValue(member, variableName, typeof(T), generatedType);
- }
-
- public static void AssignMemberFromReaderAsync(this GeneratedMethod method, GeneratedType generatedType,
- int index,
- Type documentType, string memberName)
- {
- var member = documentType.GetMember(memberName).Single();
- var variableName = member.Name.ToCamelCase();
- method.Frames.Code(
- $"var {variableName} = await reader.GetFieldValueAsync<{member.GetMemberType()!.FullNameInCode()}>({index}, {{0}}).ConfigureAwait(false);",
- Use.Type());
-
- method.Frames.SetMemberValue(member, variableName, documentType, generatedType);
- }
-
- public static void IfDbReaderValueIsNotNull(this GeneratedMethod method, int index, Action action)
- {
- method.Frames.Code($"if (!reader.IsDBNull({index}))");
- method.Frames.Code("{{");
-
- action();
-
- method.Frames.Code("}}");
- }
-
- public static void IfDbReaderValueIsNotNullAsync(this GeneratedMethod method, int index, Action action)
- {
- method.Frames.CodeAsync($"if (!(await reader.IsDBNullAsync({index}, token).ConfigureAwait(false)))");
- method.Frames.Code("{{");
-
- action();
-
- method.Frames.Code("}}");
- }
-
- public static void SetParameterFromMemberNonNullableString(this GeneratedMethod method, int index,
- Expression> memberExpression)
- {
- var member = MemberFinder.Determine(memberExpression).Single();
- method.Frames.Code($"var parameter{index} = parameterBuilder.{nameof(IGroupedParameterBuilder.AppendParameter)}({{1}}.{member.Name});", Use.Type());
- method.Frames.Code($"parameter{index}.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text;");
- }
-
- public static void SetParameterFromMember(this GeneratedMethod method, int index,
- Expression> memberExpression)
- {
- var member = MemberFinder.Determine(memberExpression).Single();
- var memberType = member.GetMemberType();
- var pgType = PostgresqlProvider.Instance.ToParameterType(memberType!);
-
- if (memberType == typeof(string))
- {
- method.Frames.Code(
- $"var parameter{index} = {{0}}.{member.Name} != null ? parameterBuilder.{nameof(IGroupedParameterBuilder.AppendParameter)}({{0}}.{member.Name}) : parameterBuilder.{nameof(IGroupedParameterBuilder.AppendParameter)}