Skip to content

Commit 92b9dce

Browse files
committed
StartupManager: Add support for running under testhost
1 parent c4859b8 commit 92b9dce

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/ElectronNET.API/Runtime/StartupManager.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,21 @@ private BuildInfo GatherBuildInfo()
129129
{
130130
var buildInfo = new BuildInfo();
131131

132-
var attributes = Assembly.GetEntryAssembly()?.GetCustomAttributes<AssemblyMetadataAttribute>().ToList();
132+
var electronAssembly = Assembly.GetEntryAssembly();
133133

134-
if (attributes?.Count > 0)
134+
if (electronAssembly == null)
135+
{
136+
return buildInfo;
137+
}
138+
139+
if (electronAssembly.GetName().Name == "testhost")
140+
{
141+
electronAssembly = AppDomain.CurrentDomain.GetData("ElectronTestAssembly") as Assembly ?? electronAssembly;
142+
}
143+
144+
var attributes = electronAssembly.GetCustomAttributes<AssemblyMetadataAttribute>().ToList();
145+
146+
if (attributes.Count > 0)
135147
{
136148
buildInfo.ElectronExecutable = attributes.FirstOrDefault(e => e.Key == nameof(buildInfo.ElectronExecutable))?.Value;
137149
buildInfo.ElectronVersion = attributes.FirstOrDefault(e => e.Key == nameof(buildInfo.ElectronVersion))?.Value;

0 commit comments

Comments
 (0)