Skip to content

Commit 87d31ed

Browse files
committed
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 <noreply@anthropic.com>
1 parent 8c6384d commit 87d31ed

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Turkey/DotNet.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ private async Task<int> RunDotNetCommandAsync(DirectoryInfo workingDirectory, st
142142
}
143143

144144
private static bool IsMonoRuntime(string dotnetRoot, Version version)
145+
{
146+
bool usingHeaders = IsMonoRuntimeUsingHeaders(dotnetRoot, version);
147+
bool usingSymbols = IsMonoRuntimeUsingSymbols(dotnetRoot, version);
148+
149+
if (usingHeaders != usingSymbols)
150+
{
151+
Console.WriteLine($"Warning: Mono runtime detection mismatch for version {version}. Headers: {usingHeaders}, Symbols: {usingSymbols}");
152+
}
153+
154+
return usingHeaders || usingSymbols;
155+
}
156+
157+
private static bool IsMonoRuntimeUsingSymbols(string dotnetRoot, Version version)
145158
{
146159
var libcoreclrPath = Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App", version.ToString(), "libcoreclr.so");
147160

@@ -173,6 +186,14 @@ private static bool IsMonoRuntime(string dotnetRoot, Version version)
173186
return false;
174187
}
175188

189+
private static bool IsMonoRuntimeUsingHeaders(string dotnetRoot, Version version)
190+
{
191+
var runtimeDirectory = Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App", version.ToString());
192+
var monoGcHeaderPath = Path.Combine(runtimeDirectory, "mono-gc.h");
193+
194+
return File.Exists(monoGcHeaderPath);
195+
}
196+
176197
#nullable enable
177198
private static string? FindProgramInPath(string program)
178199
#nullable disable

0 commit comments

Comments
 (0)