I have the impression that Dependency Injection isn't friendly with immutability. I use Microsoft Dependency Injection but I am open to another one and I wanted to have fields / properties read only as much as possible, thus having a construction phase then the init phase it's the best solution. My problem occurred when I need to create a class with data fetched over the internet, I would like something like that:
var services = new ServiceCollection();
services.AddSingleton<IMyWebService, MyWebService>();
services.AddSingleton<IMyOtherService, MyOtherService>(async sp =>
{
var webService = sp.GetService<IMyWebService>();
return new MyOtherService(await webService.GetDataAsync());
});
Making it synchronous will make my app non responsive.