ElectronNET/Electron.NET

Add Overloads for `UseElectron`

已关闭

#1,076 创建于 2026年6月19日

 (2 条评论) (0 个反应) (0 位负责人)C# (710 个派生)batch import
Featureenhancementgood first issuehelp wanted

仓库指标

星标
 (7,040 个星标)
PR 合并指标
 (平均合并 4天 13小时) (30 天内合并 7 个 PR)

描述

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?

贡献者指南