Conversation
c92a0c1 to
2996767
Compare
There was a problem hiding this comment.
Pull Request Overview
This pull request enhances Kodein-DI's multi-binding DSL by adding convenience methods for common binding types and applying the @DIDsl marker annotation to enforce proper receiver scoping. The changes make the DSL safer and more ergonomic for users.
- Added convenience methods (
addSingleton,addProvider,addInstance,addFactory,addMultiton) to reduce nesting when adding bindings to sets - Applied
@DIDslmarker annotation to DSL interfaces to prevent accidental method calls from outer scopes - Updated documentation and added comprehensive tests to verify the new functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| kodein-di/src/commonMain/kotlin/org/kodein/di/DI.kt | Added @DIDsl annotations to builder interfaces and defined new convenience methods in SetBinder and ArgSetBinder interfaces |
| kodein-di/src/commonMain/kotlin/org/kodein/di/internal/DIBuilderImpl.kt | Implemented convenience methods and added explicit scope qualifiers (this@DIBuilderImpl) to avoid ambiguity in nested contexts |
| kodein-di/src/commonTest/kotlin/org/kodein/di/Tests_18_MultiBindings.kt | Added tests verifying DSL scoping enforcement and correct behavior of new convenience methods |
| doc/modules/core/pages/multi-binding.adoc | Updated documentation to showcase new convenience methods with clear examples and explanations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
071b1c6 to
5c1595a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #478
This pull request introduces convenience methods for adding bindings to sets in Kodein-DI, making the DSL more concise and user-friendly. It also applies the
@DIDslmarker to enforce correct receiver scoping in the DSL, preventing accidental misuse of outer-scope methods inside set binding blocks. The documentation and tests are updated to reflect and verify these improvements.Convenience methods for set bindings:
SetBinderandArgSetBinderinterfaces:addSingleton,addProvider,addInstance,addFactory, andaddMultiton, allowing simpler and less nested syntax for common binding types.DIBuilderImplto support these new methods, ensuring they add the correct binding types to the set.DSL correctness and safety:
@DIDslannotation to relevant builder interfaces, includingTypeBinder,DelegateBinder,ConstantBinder,SetBinder, andArgSetBinder, to restrict method visibility and enforce correct DSL scoping.SetBindercontext, preventing accidental calls to outerDI.Buildermethods.Documentation updates:
Testing:
Internal improvements:
this@DIBuilderImplreferences for clarity and to avoid ambiguity in nested DSL contexts.These changes make Kodein-DI's multi-binding DSL safer, more ergonomic, and easier to use for common scenarios.