I'm using /eShopOnContainers/src/Mobile/eShopOnContainers/ as an architectural reference and I'm at the spot where I want to introduce IoC into my application. I found this issue: https://github.com/dotnet-architecture/News/issues/6 The question is, was moving away from Autofac to TinyIoC a good decision in retrospect? Are there other alternative IoC containers that you would implement today?
Hi @RedasP, I don't know to what extent the requirements can be satisfied with TinyIoC, but one aspect that could have some weight is that the TinyIoC project doesn't seem to be very active.
Anyway, that's something that perhaps @davidbritch could elaborate further.
Hi @RedasP
In retrospect, moving from Autofac to TinyIoC was a good decision. It resulted in performance improvements in the mobile app on all platforms, but particularly on Android.
After Unity, Autofac is the worst performing well-known IoC container in the mobile space. See IoC Container Performance for benchmarks of some common IoC containers.
Ultimately, not using MVVM frameworks or IoC containers will result in more performant mobile apps, particularly on Android. Choosing to use an IoC container in the mobile space is a trade off between architectural convenience, and performance.
Hey @davidbritch, thanks for the info!
I haven't tried this, and really haven't done anything serious with Xamarin but, out of curiosity, are the .NET Core DI libraries suitable for mobile development?
Thx.
Hi @mvelosop
I've never tried the .NET Core DI libraries with mobile apps. The root issue is essentially this: dynamic code can be problematic in Xamarin mobile apps. While it's often not an issue in Xamarin iOS apps, it can be a big issue in Xamarin Android apps.
With regards to DI, if the startup path of a mobile app resolves several types (which the DI container creates), this will slow down the startup time of a Xamarin Android app. That's why the path to best performance with Xamarin apps is not to use DI. But like I said, it's a trade off.
Thanks @davidbritch,
I think that's an excellent reason! so I think this issue can be considered solved. Do you agree @RedasP?
Anyway @RedasP, if you happen to make a comparison with .NET Core's DI, please post the findings here! 馃槉
Thanks for the answers. We can consider it solved. 馃槉
Closing the issue. Thanks for the discussion! 馃憤