-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Remove MS.Extensions.Hosting from Maui #4505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove MS.Extensions.Hosting as a dependency. Users can configure DI servcies, Configuration, and Logging without needing the indirection by going through Hosting to build the ServiceProvider. - Remove Logging Providers by default. Libraries can still get ILogger services, as normal. Apps can add the logging providers they care about. Fix dotnet#4393 Fix dotnet#4394
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
While poking around I noticed that our two CreateBuilder
methods seem kind of redundant
maui/src/Core/src/Hosting/MauiApp.cs
Lines 36 to 43 in b1442f0
public static MauiAppBuilder CreateBuilder() => new(); | |
/// <summary> | |
/// Initializes a new instance of the <see cref="MauiAppBuilder"/> class with optional defaults. | |
/// </summary> | |
/// <param name="useDefaults">Whether to create the <see cref="MauiAppBuilder"/> with common defaults.</param> | |
/// <returns>The <see cref="MauiAppBuilder"/>.</returns> | |
public static MauiAppBuilder CreateBuilder(bool useDefaults = true) => new(useDefaults); |
Feels like we should just delete the first one since the second one takes an optional parameter. Not sure if there's an advantage to having both.
I realize you didn't touch those but maybe while we're here :-)
On it. |
Do we have metrics about how it impacts in the startup time? |
@jsuarezruiz you can find the numbers here |
- remove redundant and unusable methods on MauiApp
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
A few questions here: |
1.) As far as I know, no functionality that anyone is using. The pieces that are getting removed are all related to "startup" of the app. Instead of trying to interoperate with the "Generic Host" to build the DI container, we are now doing it ourselves. And we are no longer adding logging providers by default. There shouldn't be any DI functionality removed at all - like the new Constructor Injection for Shell. 2.) It doesn't impact control / component sharing with Blazor at all. The only impact it could have is if someone has extension methods that only take an 3.) I don't think so. I searched for "Extensions.Hosting" in the whole repo, and only this Sample.Server.WebAuthenticator is left after these changes. 4.) The one potential impact on the templates we could consider is conditionally adding a |
@eerhardt LOVELY! Thank you so much for the detailed response, detailed PR, detailed issue! 👏👏👏👏👏 |
* Remove MS.Extensions.Hosting from Maui - Remove MS.Extensions.Hosting as a dependency. Users can configure DI servcies, Configuration, and Logging without needing the indirection by going through Hosting to build the ServiceProvider. - Remove Logging Providers by default. Libraries can still get ILogger services, as normal. Apps can add the logging providers they care about. Fix dotnet#4393 Fix dotnet#4394 * PR feedback - remove redundant and unusable methods on MauiApp Co-authored-by: redth <jondick@gmail.com>
* Remove MS.Extensions.Hosting from Maui - Remove MS.Extensions.Hosting as a dependency. Users can configure DI servcies, Configuration, and Logging without needing the indirection by going through Hosting to build the ServiceProvider. - Remove Logging Providers by default. Libraries can still get ILogger services, as normal. Apps can add the logging providers they care about. Fix #4393 Fix #4394 * PR feedback - remove redundant and unusable methods on MauiApp Co-authored-by: redth <jondick@gmail.com> Co-authored-by: redth <jondick@gmail.com>
So how does one go about adding logging now? i.e. |
@Syed-RI the upcoming update to .NET MAUI will have this by default: https://github.com/dotnet/maui/pull/8180/files But for now, add a NuGet reference to using Microsoft.Extensions.Logging;
...
#if DEBUG
builder.Logging.AddDebug();
#endif |
That doesn't output anything I'm afraid ( |
However, |
@Syed-RI if something isn't working, please log a new issue so that we can investigate. It sounds like in your case some messages are indeed being filtered if some log levels are showing up and some aren't. Lots more info here to get you started: https://docs.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line (though note that some features like setting filters in appsettings.json don't work by default in .NET MAUI). |
Fix #4393
Fix #4394
cc @mattleibow @Redth @PureWeen