Skip to content

Commit 5b597cc

Browse files
committed
StartupManager: Add support for running under testhost
1 parent 707c0f5 commit 5b597cc

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
@@ -128,9 +128,21 @@ private BuildInfo GatherBuildInfo()
128128
{
129129
var buildInfo = new BuildInfo();
130130

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

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

0 commit comments

Comments
 (0)