From 87d31ed96a325114f3576f5574510bd74b790b05 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 10 Nov 2025 18:21:12 -0500 Subject: [PATCH] Use mono-gc.h as a marker of mono runtime But also use the symbols as a sanity-check. Related: #93 Assisted-by: Claude Sonnet 4.5 --- Turkey/DotNet.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Turkey/DotNet.cs b/Turkey/DotNet.cs index 677b3b5..5987a65 100644 --- a/Turkey/DotNet.cs +++ b/Turkey/DotNet.cs @@ -142,6 +142,19 @@ private async Task RunDotNetCommandAsync(DirectoryInfo workingDirectory, st } private static bool IsMonoRuntime(string dotnetRoot, Version version) + { + bool usingHeaders = IsMonoRuntimeUsingHeaders(dotnetRoot, version); + bool usingSymbols = IsMonoRuntimeUsingSymbols(dotnetRoot, version); + + if (usingHeaders != usingSymbols) + { + Console.WriteLine($"Warning: Mono runtime detection mismatch for version {version}. Headers: {usingHeaders}, Symbols: {usingSymbols}"); + } + + return usingHeaders || usingSymbols; + } + + private static bool IsMonoRuntimeUsingSymbols(string dotnetRoot, Version version) { var libcoreclrPath = Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App", version.ToString(), "libcoreclr.so"); @@ -173,6 +186,14 @@ private static bool IsMonoRuntime(string dotnetRoot, Version version) return false; } + private static bool IsMonoRuntimeUsingHeaders(string dotnetRoot, Version version) + { + var runtimeDirectory = Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App", version.ToString()); + var monoGcHeaderPath = Path.Combine(runtimeDirectory, "mono-gc.h"); + + return File.Exists(monoGcHeaderPath); + } + #nullable enable private static string? FindProgramInPath(string program) #nullable disable