XAM-Consulting / FreshMvvm.Maui

MIT License
44 stars 10 forks source link

Do not call BuildServiceProvider in UseFreshMvvm #1

Open ggutschi opened 2 years ago

ggutschi commented 2 years ago

Hi!

The call of BuildServiceProvider in UseFreshMvvm is bad practice (see Microsoft Docs). For example: Nested constructor injections with singletons won't work.

Best regards

ggutschi commented 2 years ago

As a workaround I'm using

var app = builder.Build();

DependancyService.RegisterServiceProvider(app.Services.GetService<IServiceProvider>());

return app;

instead of

services.UseFreshMvvm();