dotnet-architecture / News

News on .NET Architecture Guidance, eShopOnContainers and all the reference apps in dotnet-architecture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mobile app: Autofac replaced with TinyIoC

davidbritch opened this issue · comments

The eShopOnContainers mobile app, which now uses .NET Standard, has recently received some updates. One of the important updates is that the Autofac IoC container has been replaced by TinyIoC.

Dedicated IoC frameworks, such as Autofac, are feature and capability heavy. However, in a typical mobile application it's unlikely that you'll use most of these features and capabilities. Therefore, swapping to a less heavyweight IoC container should offer some benefits.

TinyIoC is an IoC container that's distributed as a CS file that you add to your project, and offers excellent performance for mobile apps. When comparing TinyIoC to Autofac, type registration is typically 35 times quicker, with type resolution typically being 5 times quicker. This results in the eShopOnContainers mobile app being noticeably more performant on all three platforms, but particularly on Android where the app startup time has been reduced by approximately 2 seconds.

As well as performance, replacing Autofac with TinyIoC has resulted in a number of other advantages:

  • The unit tests run more quickly.
  • The unit tests are more reliable (issues to do with Autofac disposing of objects have been instantly eliminated).
  • There's one less NuGet package distributed with the app, resulting in smaller app package sizes.

This change is just one of many planned for the eShopOnContainers mobile app in the coming months. Check out the latest source in the DEV branch.

Once all the updates are made to the app we'll release a v2 of the eBook, but that'll be a few months away yet.