Inconsistent base class injection behavior
See original GitHub issuewhile migrating from 4.x to 6.4 I found that injecting base classes does not work as it used to and depending how injection occurs, it’s also inconsistent.
what is the preferred way to handle / resolve class hierarchy instances as outlined below for 6.x?
class KodeinSandbox {
open class Resource1
open class Resource2 : Resource1()
val kodein = Kodein {
bind<Resource1>() with singleton { Resource1() }
bind<Resource2>() with singleton { Resource2() }
}
val instanceLevelResource1: Resource1 by kodein.instance()
@Test
fun testInjection() {
val localResource1: Resource1 by kodein.instance()
// Behaves as expected (as of 4.x) delivers instance explicitly bound to base-class type
println(localResource1)
// Throws due to ambiguity
println(instanceLevelResource1)
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
base class is less accessible than child class - Stack Overflow
So this says that base class should be equally or more accessible than subclass. So if base class is internal then subclass should...
Read more >Automocking and the Dependency Inversion Principle
This is how the error Inconsistent accessibility: base class 'WithSubject<HelloWorld>' is less accessible than class 'When_GetMessage' is solved ...
Read more >how to restrict the access of members of a base class to ...
It would violate the principle of polymorphism[^]: A subclass should behave like the baseclass if it is being used like the baseclass.
Read more >C#–Hide a base class for usage outside an assembly
I created an abstract base class in C# but didn't want it to be used outside the assembly I created it in. How...
Read more >base class 'A' is less accessible than class 'B' - MSDN - Microsoft
public class B : A { } When I am trying to build the solution I am getting the following error: Error: Inconsistent...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
confirming,
6.4.1
fixes this, as well as the overriding issue I presumed was related.6.4.1
fix the bug, I hope this will help. Tell me if you still have issues. (publishing on jcenter may take some minutes)