mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-10 18:58:19 +00:00
- Replaced Console.WriteLine with System.Diagnostics.Debug.WriteLine in: * LaunchOrderDetector (probe scoring) * UnpackagedDetector (probe scoring) * ElectronProcessActive (StartInternal traces) - Removed '[StartInternal]: after run:' trace - Debug.WriteLine only outputs when debugger is attached These were the noisiest debugging traces. Other Console.WriteLine usage in StartupManager, ProcessRunner, etc. would require ILogger injection which is a larger architectural change deferred for now.
73 lines
1.9 KiB
C#
73 lines
1.9 KiB
C#
namespace ElectronNET.Runtime.Helpers
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
|
|
internal class LaunchOrderDetector
|
|
{
|
|
public static bool CheckIsLaunchedByDotNet()
|
|
{
|
|
var tests = new List<Func<bool?>>();
|
|
|
|
tests.Add(CheckIsDotNetStartup1);
|
|
tests.Add(CheckIsDotNetStartup2);
|
|
tests.Add(CheckIsDotNetStartup3);
|
|
|
|
int scoreDotNet = 0, scoreElectron = 0;
|
|
|
|
foreach (var test in tests)
|
|
{
|
|
var res = test();
|
|
|
|
if (res == true)
|
|
{
|
|
scoreDotNet++;
|
|
}
|
|
|
|
if (res == false)
|
|
{
|
|
scoreElectron++;
|
|
}
|
|
}
|
|
|
|
// Debug trace - useful for diagnostics
|
|
System.Diagnostics.Debug.WriteLine($"Probe scored for launch origin: DotNet {scoreDotNet} vs. {scoreElectron} Electron");
|
|
return scoreDotNet > scoreElectron;
|
|
}
|
|
|
|
private static bool? CheckIsDotNetStartup1()
|
|
{
|
|
var hasPortArg = ElectronNetRuntime.ProcessArguments.Any(e => e.Contains(ElectronNetRuntime.ElectronPortArgumentName, StringComparison.OrdinalIgnoreCase));
|
|
if (hasPortArg)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
private static bool? CheckIsDotNetStartup2()
|
|
{
|
|
var hasPidArg = ElectronNetRuntime.ProcessArguments.Any(e => e.Contains(ElectronNetRuntime.ElectronPidArgumentName, StringComparison.OrdinalIgnoreCase));
|
|
if (hasPidArg)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private static bool? CheckIsDotNetStartup3()
|
|
{
|
|
if (DebuggerHelper.IsAttached)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |