Skip to content

Include Startup class - #436

Merged
rmarinho merged 23 commits into
mainfrom
startup
Mar 22, 2021
Merged

rmarinho merged 23 commits into
mainfrom
startup

Conversation

@jsuarezruiz

@jsuarezruiz jsuarezruiz commented Mar 5, 2021 •

Copy link
Copy Markdown
Contributor
  • Add IStartup interface
  • Add opt-in support for constructor DI
  • Attached the IMauiContext to the handlers so there is no need for App.Current internally.

Comment thread src/Core/src/Application.cs Resolved
/// Configure are called by the .NET MAUI Core runtime when the app starts.
/// </summary>
/// <param name="appBuilder">Defines a class that provides the mechanisms to configure an application's dependencies.</param>
void Configure(IAppHostBuilder appBuilder);

@jsuarezruiz jsuarezruiz Mar 5, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmarinho What do you think? Maybe we should create directly the Builder? IAppHostBuilder CreateBuilder()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want both? I think we want to configure it still but have a:

public virtual IAppHostBuilder CreateBuilder() => new DefaultAppHostBuilder();

So we can choose to override it, or let the default implementation be created.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agree with @Redth , we want it virtual that calls the default builder, user can override

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a new Method that is CreateBuilder that returns CreateDefaultBuilder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ASP.NET, the user instantiates the builder in Program.cs and then configures it in Startup.cs. Now this is not quite possible here, but we can have our Startup have a "get builder" method instead of configure? Or maybe we should have an additional IHostBuilderStartup interface that will allow the user top optionally implement it and construct the builder?

What if the user does not want our defaults? For example, not to register all the MAUI views and not to use the fonts. And, this might have future implications. Just as we had launch options in Forms to control what was registered, we may need this so users can not have to pass in some options, but rather control the whole thing,

@jsuarezruiz
jsuarezruiz marked this pull request as ready for review March 8, 2021 13:13
@rmarinho
rmarinho requested review from Redth and rmarinho March 9, 2021 10:03
Comment thread src/Core/src/Core/IApplication.cs Resolved
Comment thread src/Core/src/Window.cs Resolved
@jsuarezruiz

jsuarezruiz commented Mar 12, 2021 •

Copy link
Copy Markdown
Contributor Author

To facilitate the review and feedback about Startup class, native lifecycle events and cross platform lifecycle events (besides being actually related but different functionality) I am going to split this PR into smaller PRs.

@chen495 chen495 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新手求救🆘

Comment thread src/Core/src/Application.cs Resolved
Comment thread src/Core/src/Application.cs Resolved
@jsuarezruiz jsuarezruiz changed the title Implement Startup and basic lifecycle events Include Startup class Mar 15, 2021
Comment thread src/Core/src/App.cs Resolved
@mattleibow mattleibow mentioned this pull request Mar 17, 2021
@mattleibow

Copy link
Copy Markdown
Member

Based on my thoughts and also to play around a bit, I made this PR to this PR :) with what I was thinking. Good thing I did do this as some ideas were a bit out there and actually couldn't work or did not feel nice when using it.

This PR is one thought process I had so maybe it is better or worse and we can either merge and iterate or I can rework it.

#529

/// Create and configure a builder object.
/// </summary>
/// <returns>The new instance of the IAppHostBuilder.</returns>
public IAppHostBuilder CreateHostBuilder();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattleibow I've added IHostBuilderStartup. To create a custom HostBuilder only need to implement this interface in Startup. However, I am thinking in a better approach, use a default interface method: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/default-interface-methods

In IStartup, include the CreateHostBuilder method, with a base implementation.

@mattleibow mattleibow Mar 19, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work in classic Xamarin? I am thinking for local dev purposes until tooling becomes more net6 friendly. But yeah, a default implementation is certainly better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not, is not working for now.

@rmarinho
rmarinho merged commit d4a3de2 into main Mar 22, 2021
@rmarinho
rmarinho deleted the startup branch March 22, 2021 14:45
@samhouts samhouts added legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-core-hosting Extensions / Hosting / AppBuilder / Startup area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter area-controls-button Button, ImageButton area-controls-editor Editor area-controls-entry Entry area-controls-label Label, Span area-controls-progressbar ProgressBar area-controls-slider Slider area-controls-switch Switch platform/android platform/ios labels Jul 11, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 27, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-button Button, ImageButton area-controls-editor Editor area-controls-entry Entry area-controls-label Label, Span area-controls-progressbar ProgressBar area-controls-slider Slider area-controls-switch Switch area-core-hosting Extensions / Hosting / AppBuilder / Startup area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-6.0.100-preview.3.2 platform/android platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants