Autofac: Improve circular dependency handling (general discussion / design)

We have seen issues and PRs come in about changes desired for circular dependency handling. We had every intention of making some improvements in time for 4.0 but, unfortunately, .NET Core “ate our lunch,” as it were.

Much has changed since v4.0 and the .NET Core support was released so we’re closing the following PRs so they can be later reimplemented (if desired) and/or used for ideas for improvement:

  • #579: This PR moved the check for circular dependencies to after where the instance lookup occurs. However, there was no unit test associated that could show the issue that this was intended to fix. It appears innocuous, but without understanding the specific case this fixes we declined to take it.
  • #575: This PR improved circular dependency handling to always work on properties. It also changed the default behavior of PropertyWiringOptions and broke the IComponentRegistration interface.

There are comments in #575 indicating ideas on better ways to handle improvement of the circular dependency handling. It is potentially non-trivial and breaking.

We invite folks interested in improving or changing the circular dependency handling to comment on this issue and let us know challenges they’ve seen or improvements they’d like to see. Note a failing unit test or two would help so we can understand in a more concrete fashion the challenges being seen.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

Yes, I have written code to adjust it via reflection and that is working. We have quite a large list of dependencies and it’s surprising to me that it managed to get that deep also. I will play with the DOT chain tooling to see if I can determine where it’s getting so deep.