ElectronNET/Electron.NET

Add Overloads for `UseElectron`

Fechada

#1.076 aberto em 19 de jun. de 2026

 (2 comentários) (0 reação) (0 responsável)C# (710 forks)batch import
Featureenhancementgood first issuehelp wanted

Métricas do repositório

Stars
 (7.040 estrelas)
Métricas de merge de PR
 (Mesclagem média 4d 13h) (7 fundiu PRs em 30d)

Description

It would be great to have some method overloads for the UseElectron extension method, specifically the following:

UseElectron(string[] args, Func<IServiceProvider, Task> onAppReadyCallback)
UseElectron(string[] args, Func<string[], Task> onAppReadyCallback)
UseElectron(string[] args, Func<IServiceProvider, string[], Task> onAppReadyCallback)

Both, WebApplicationBuilderExtensions and WebHostBuilderExtensions, would need these overloads.

Motivation

The current implementation requires the callback task to be ready before the app is instantiated, i.e., before the service collection is initialized. This can cause issues, especially when the callback comes from a service. For that, it would be great to have an overload that allows access to the IServiceCollection, similarly to how the service collection factory pattern works. This allows the normal dependency injection logic to fully resolve the required services on demand, rather than having it initialized beforehand. Furthermore, having access to the arguments at that stage rather than having to pipe them through yourself would also reduce friction. From what I can tell, the internal ElectronNetRuntime.OnAppReadyCallback is not executed before the app is instantiated which means, the fully initialized service collection would be available at that time.

On a side-note: the argument array has to be provided on the initial UseElectron method, but is never actually used?

Guia do colaborador