Repository navigation
✨ feat!: endpoint modules on IServiceCollection, without Lamar, on core-ddd 7.0 - #6
Conversation
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
left a comment
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
[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
left a comment
There was a problem hiding this comment.
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.
|
🎉 This PR is included in version 6.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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,
AddEndpointModuleson Lamar'sServiceRegistry, which scans forIEndpointModule. The mapping (MapModules) already resolves the modules from the plainIServiceProvider. 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 ownAddEndpointModulesonIServiceCollectioninstead of using ours.What changes.
AddEndpointModulesmoves toIServiceCollection. 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.Apireferences no IoC container.eQuantic.Core.ApplicationandeQuantic.Core.Exceptionsmove to 7.0.0, and the tests'eQuantic.Core.Domaintoo.Tests. Five new ones, passing on net8.0 and net10.0 with the four that were there:
WebApplicationon a TestServer answers on the routes the modules mapDocs. 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
ServiceRegistryoverload, 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