Skip to content
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

API Proposal: Expose Host.ConfigureDefaults #36003

Closed
davidfowl opened this issue Jan 22, 2020 · 10 comments · Fixed by #50447
Closed

API Proposal: Expose Host.ConfigureDefaults #36003

davidfowl opened this issue Jan 22, 2020 · 10 comments · Fixed by #50447
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-Extensions-Hosting help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@davidfowl
Copy link
Member

This would allow callers to provide the IHostBuilder instance without having to copy all the logic to setup defaults.

@analogrelay
Copy link
Contributor

Do you have more specific details on the proposal? This is pretty low on info/details.

@analogrelay
Copy link
Contributor

:trollface:

@ghost
Copy link

ghost commented Jan 28, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

@davidfowl
Copy link
Member Author

I had to copy the defaults because I wanted to use a different IHostBuilder implementation https://github.com/davidfowl/FeatherHttp/blob/ee5e2a8a701b73b1e57c5d4df5672fda63366779/src/FeatherHttp/WebApplication.cs#L221.

The request is simple, I’d rather not copy this logic 😬

@analogrelay analogrelay transferred this issue from dotnet/extensions May 7, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label May 7, 2020
@analogrelay analogrelay added this to the Future milestone May 7, 2020
@ericstj ericstj removed the untriaged New issue has not been triaged by the area owner label Jun 22, 2020
@maryamariyan maryamariyan added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Oct 1, 2020
@maryamariyan
Copy link
Member

maryamariyan commented Oct 22, 2020

API Proposal Summary:

The ask is to move the IHostBuilder instantiation below out of the new API, so other callers can provide their own IHostBuilder to CreateDefaultBuilder

var builder = new HostBuilder();

namespace Microsoft.Extensions.Hosting
{
    public static partial class Host
    {
        public static Microsoft.Extensions.Hosting.IHostBuilder CreateDefaultBuilder() { throw null; }
        public static Microsoft.Extensions.Hosting.IHostBuilder CreateDefaultBuilder(string[] args) { throw null; }
+       public static Microsoft.Extensions.Hosting.IHostBuilder CreateDefaultBuilder(IHostBuilder builder, string[] args) { throw null; }
    }
}

@maryamariyan maryamariyan added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Oct 22, 2020
@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Jan 21, 2021
@terrajobst
Copy link
Member

terrajobst commented Jan 21, 2021

Video

  • Let's not name it CreateDefaultBuilder() because it doesn't actually create a new builder, it just applies the defaults.
  • Let's make an extension method so that the usage looks less noisy
  • That means we should move it to HostingHostBuilderExtensions instead
namespace Microsoft.Extensions.Hosting
{
    public static partial class HostingHostBuilderExtensions
    {
        public static IHostBuilder ConfigureDefaults(this IHostBuilder builder, string[] args);
    }
}

@davidfowl
Copy link
Member Author

Nice!

@davidfowl davidfowl self-assigned this Mar 25, 2021
@davidfowl davidfowl modified the milestones: Future, 6.0.0 Mar 25, 2021
@maryamariyan maryamariyan added the help wanted [up-for-grabs] Good issue for external contributors label Mar 29, 2021
@IEvangelist
Copy link
Member

If you're okay with it @maryamariyan and @davidfowl, I'd love to work on this?

@davidfowl davidfowl assigned IEvangelist and unassigned davidfowl Mar 30, 2021
@davidfowl
Copy link
Member Author

Do it!

IEvangelist added a commit to IEvangelist/runtime that referenced this issue Mar 30, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 30, 2021
maryamariyan pushed a commit that referenced this issue Mar 31, 2021
…ilder` (#50447)

* Added the ConfigureDefaults API, as an extension method on the IHostBuilder interface. Fix #36003

* Apply suggestions from code review

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>

* Update src/libraries/Microsoft.Extensions.Hosting/src/Host.cs

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 31, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-Extensions-Hosting help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants