Skip to content

✨ feat!: endpoint modules on IServiceCollection, without Lamar, on core-ddd 7.0 - #6

Merged
edgarmesquita merged 4 commits into
mainfrom
feat/endpoint-modules-without-lamar
Nov 14, 2026
Merged

edgarmesquita merged 4 commits into
mainfrom
feat/endpoint-modules-without-lamar

Conversation

@edgarmesquita

Copy link
Copy Markdown
Contributor

Next link of the chain after eQuantic/core-ddd#5... core-ddd 7.0.0 took Lamar out of eQuantic.Core.Application, and core-api was the one place still using it.

Why Lamar goes. It served one method, AddEndpointModules on Lamar's ServiceRegistry, which scans for IEndpointModule. The mapping (MapModules) already resolves the modules from the plain IServiceProvider. For that one method every API on core-api carried 2.8 MB of Lamar, JasperFx, Spectre.Console and Polly, and had to run Lamar's container to call it. equantic-auth and equantic-billing each wrote their own AddEndpointModules on IServiceCollection instead of using ours.

What changes.

  • AddEndpointModules moves to IServiceCollection. It takes any number of assemblies, defaults to the entry assembly, skips abstract and open generic types, and registers nothing twice when called again.
  • eQuantic.Core.Api references no IoC container.
  • eQuantic.Core.Application and eQuantic.Core.Exceptions move to 7.0.0, and the tests' eQuantic.Core.Domain too.

Tests. Five new ones, passing on net8.0 and net10.0 with the four that were there:

  • the modules of an assembly get registered, without the abstract base or the open generic
  • calling it again, or with the same assembly twice, registers nothing twice
  • a null assembly is refused
  • a WebApplication on a TestServer answers on the routes the modules map
  • the package's resolved dependencies hold no Lamar or JasperFx. It reads deps.json, so a reference that compiles to nothing is caught too, and I checked it fails with Lamar put back

Docs. The README gets "What's new in v6.0" with what to change when upgrading, and an "Endpoint modules" section, which it never had.

Release. It removes the ServiceRegistry overload, so it has to be 6.0.0. Two of Lamar's behaviours go with it, and the BREAKING CHANGE says so: with no assembly given, 5.x scanned every assembly in the application's directory (6.0 looks in the entry assembly), and its scan also registered every other concrete type against its first interface.

Closes #5

AddEndpointModules moves from Lamar's ServiceRegistry to IServiceCollection, takes any number of assemblies, defaults to the entry assembly, skips abstract and open generic types and registers nothing twice. Tests cover the registration, the mapping through a TestServer, and fail when Lamar reaches the package's dependencies again.

BREAKING CHANGE: the ServiceRegistry overload is gone. With no assembly given, modules are looked for in the entry assembly instead of every assembly in the application's directory, and other concrete types are no longer registered against their first interface as a side effect.

Refs #5
eQuantic.Core.Application and eQuantic.Core.Exceptions, and the tests' eQuantic.Core.Domain. Application 7.0 no longer brings Lamar.

Refs #5
…ing modules

A module nested in a generic class is already a generic type definition, so it was never registered. ContainsGenericParameters says what the filter means, and a test now holds the nested case.

Refs #5

@edgarmesquita edgarmesquita left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Secondary review, round 1 (Antigravity), because Copilot can't be requested on this repository (GitHub accepts the request and drops it).

One finding, not a defect as it stands, but the filter now says what it means. Details on the line.


foreach (var type in assembly.GetTypes())
{
if (type is { IsClass: true, IsAbstract: false, IsGenericTypeDefinition: false }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] A module nested in a generic class (Outer<T>.InnerModule) would pass IsGenericTypeDefinition: false and fail when the container resolves it.

Not a defect: a type nested in a generic class carries the outer T, so it is itself a generic type definition and was already skipped. A test now proves it (Outer<T>.InnerModule is not registered, and the registration test still sees only the two concrete modules). The filter reads ContainsGenericParameters: false anyway, since that is what it means, in 12f4842.

@edgarmesquita edgarmesquita left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Secondary review, round 2 (Antigravity), on the filter change from round 1.

No findings, with every changed file in full in the prompt. The review closes here.

@edgarmesquita
edgarmesquita merged commit bfc7571 into main Nov 14, 2026
10 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Endpoint modules without Lamar, on core-ddd 7.0

2 participants