Lazy cyclic dependencies are no longer possible in v2.0
See original GitHub issueDescription
Since v2.0, it is no longer possible to have a cyclic dependency where one of the dependencies is lazy resolved. this results in the following error:
error DIE001: A cyclic dependency has been found Pure.DI.Example.Dependency <-- System.Lazy<Pure.DI.Example.IDependency2> <-- System.Func<Pure.DI.Example.IDependency2> <-- Pure.DI.Example.Dependency2 <-- Pure.DI.Example.Dependency.
In v1, code was generated to resolve the lazy dependency lazily.
Example
public class Dependency : IDependency
{
public Dependency(Lazy<IDependency2> dependency2) { }
}
public class Dependency2 : IDependency2
{
public Dependency2(IDependency dependency) { }
}
public partial class Composition
{
public static void Setup() =>
DI.Setup(nameof(Composition))
.Bind<IDependency>().To<Dependency>()
.Bind<IDependency2>().To<Dependency2>()
.Bind<IService>().To<Service>().Root<IService>("Root");
}
Repository
Issue Analytics
- State:
- Created a month ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Circular dependencies solutions? - java
I'm trying to work out the uses of lazy initialization, allowing circular dependencies to be true and whether or not I call a...
Read more >Lazy circular dependencies no longer work · Issue #105
Lazy circular dependencies work with Node.js and other CommonJS module loaders/bundlers. I think it is important to maintain parity with the ...
Read more >Circular Dependencies in Spring
When we have a circular dependency, it's likely we have a design problem and that the responsibilities are not well separated.
Read more >Circular Dependencies in Spring
Here as you can see, there is a circular dependency and Spring won't be able to decide which of the beans should be...
Read more >code quality - What's wrong with circular references?
Circular object references can crash naïve recursive algorithms (such as serializers, visitors and pretty-printers) with stack overflows. The ...
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
That seems to work, up until you inject IDependency in the Service. I believe it is good enough for my case though.
Fixed in 2.0.13