feat: Added DI overloads for custom config type#199
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughRefactors DI registration into partial classes and adds overloads to register Table and View repositories with custom configuration types; bumps version to 1.11.0, adds CHANGELOG, adjusts test container image usage, and adds unit tests validating custom-config constructor behavior. Changes
Sequence DiagramsequenceDiagram
participant Client as Service Consumer
participant SC as IServiceCollection
participant DI as AddRepository<br/>(with CustomConfig)
participant Validator as Constructor Validator
participant Factory as Registration Factory
participant SP as IServiceProvider
participant Repo as TRepositoryClass<br/>Instance
Client->>SC: Call AddRepository(Action<CustomConfig>)
SC->>DI: Extension method invoked
DI->>Validator: Inspect TRepositoryClass constructors
alt Constructor matches IOptions<TConfig>
Validator->>DI: OK
DI->>SC: Configure options and register factory
SC->>SC: Store registration
else Constructor mismatch
Validator->>DI: Throw ArgumentException
DI-->>Client: Exception with details
end
Client->>SP: Resolve TRepositoryInterface
SP->>Factory: Invoke factory
Factory->>SP: Request IOptions<CustomConfig>, IOptions<DefaultConfiguration>
SP-->>Factory: Return options
Factory->>Repo: Instantiate TRepositoryClass(options, defaultOptions, provider)
Factory-->>SP: Return Repo instance
SP-->>Client: Provide repository
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 8-10: The changelog headers use link-reference labels
"[Unreleased]" and "[1.11.0]" but lack their link definitions; add corresponding
reference definitions at the bottom of CHANGELOG.md such as a definition for
[Unreleased] pointing to the compare URL (e.g. .../compare/v1.11.0...HEAD) and a
definition for [1.11.0] pointing to the release tag URL (e.g.
.../releases/tag/v1.11.0) so the header links resolve correctly in Markdown
viewers.
In
`@src/Dapper.DDD.Repository.DependencyInjection/DapperRepositoryDependencyInjection_Table.cs`:
- Around line 46-57: The XML doc for the Table repository overload incorrectly
references ViewAggregateConfiguration; update the summary/typeparam XML for
TConfiguration so it instructs consumers to use TableAggregateConfiguration (not
ViewAggregateConfiguration) — edit the XML comment in
DapperRepositoryDependencyInjection_Table.cs for the generic overload (the
comment describing TConfiguration on the Add table repository overload / the
method that uses TConfiguration) to mention TableAggregateConfiguration as the
expected constructor/configuration type.
🧹 Nitpick comments (4)
tests/Dapper.DDD.Repository.MySql.IntegrationTests/Configuration/ContainerFixture.cs (1)
73-75: Pin the MySQL image to a specific version for reproducible tests.Using
"mysql:latest"makes test runs non-reproducible—the image tag is mutable and can change without notice, potentially breaking tests on new MySQL releases. Testcontainers best practices recommend using explicit version tags like"mysql:8.0.36"or preferably digest-pinned references for maximum reproducibility.src/Dapper.DDD.Repository.DependencyInjection/DapperRepositoryDependencyInjection_Table.cs (1)
80-93: XML doc is missing the<param>entry for theconstructorparameter.📝 Proposed fix
/// <param name="configureOptions">Used to configure the repository via lambda</param> + /// <param name="constructor">Custom factory function to create the repository instance</param> public static IServiceCollection AddTableRepository<TAggregate, TAggregateId, TRepositoryInterface,src/Dapper.DDD.Repository.DependencyInjection/DapperRepositoryDependencyInjection_View.cs (2)
93-106: XML doc is missing the<param>entry for theconstructorparameter — same as the Table counterpart.📝 Proposed fix
/// <param name="configureOptions">Used to configure the repository via lambda</param> + /// <param name="constructor">Custom factory function to create the repository instance</param> public static IServiceCollection AddViewRepository<TAggregate, TAggregateId, TRepositoryInterface,
141-152: Same missing<param>forconstructorin this overload.📝 Proposed fix
/// <param name="configureOptions">Used to configure the repository via lambda</param> + /// <param name="constructor">Custom factory function to create the repository instance</param> public static IServiceCollection AddViewRepository<TAggregate, TRepositoryInterface, TRepositoryClass>(
Summary by CodeRabbit
New Features
Tests
Chores