You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve debugging experience of Microsoft.Extensions.DependencyInjection #86553
I would like something that helps with detecting an attempt to resolve a circular dependency that was not detected on build (eg when using a factory, like services.AddTransient<IService>(sp => sp.GetRequiredService<MyService>())).
I know my codebase needs refactoring, but it's so big (and not created by myself), that I have no idea where those circular dependencies are. Result is now that I have to start the application and see if memory usage will suddenly increase dramatically (result of the circular dependency) and then manually check all code to find where the cause could be.
Logging could help, but detecting on build OR resolve would help even more.
And since I know from my factory-code which types I create, I could even provide it to the TryAdd/Add on the servicecollection, so it could use that information for detection. Something like this: services.AddTransient<IService>(sp => sp.GetRequiredService<MyService>(), new[] { typeof(MyService) }).
Activity
ericstj commentedon May 23, 2023
@steveharter this seems like a nice thing to improve in 8.0.
kwaazaar commentedon Jun 13, 2023
I would like something that helps with detecting an attempt to resolve a circular dependency that was not detected on build (eg when using a factory, like
services.AddTransient<IService>(sp => sp.GetRequiredService<MyService>())).I know my codebase needs refactoring, but it's so big (and not created by myself), that I have no idea where those circular dependencies are. Result is now that I have to start the application and see if memory usage will suddenly increase dramatically (result of the circular dependency) and then manually check all code to find where the cause could be.
Logging could help, but detecting on build OR resolve would help even more.
And since I know from my factory-code which types I create, I could even provide it to the TryAdd/Add on the servicecollection, so it could use that information for detection. Something like this:
services.AddTransient<IService>(sp => sp.GetRequiredService<MyService>(), new[] { typeof(MyService) }).JamesNK commentedon Jul 4, 2023
Fixed by #88082