Skip to content

Commit

Permalink
Fix Mono detection in namer (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Apr 26, 2023
1 parent 976568a commit de2374b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/Verify/Naming/Namer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ internal static (string runtime, Version Version) GetRuntimeAndVersion()
return ("Core", new(3, 0));
#elif NETCOREAPP3_1
return ("Core", new(3, 1));
#elif NET462
return ("Net", new(4, 6));
#elif NET472
return ("Net", new(4, 7));
#elif NET48
return ("Net", new(4, 8));
#elif NET5_0
return ("DotNet", new(5, 0));
#elif NET6_0
Expand All @@ -248,6 +242,27 @@ internal static (string runtime, Version Version) GetRuntimeAndVersion()
return ("DotNet", new(7, 0));
#elif NET8_0
return ("DotNet", new(8, 0));
#elif NETFRAMEWORK

// Mono can only be detected at runtime, and will use .NET Framework targets, so we have to check it first.
if (RuntimeInformation.FrameworkDescription.StartsWith("Mono", StringComparison.OrdinalIgnoreCase))
{
return ("Mono", Environment.Version.MajorMinor());
}

// It's one of the .NET Framework versions we're explicitly targeting.
#if NET462
return ("Net", new(4, 6));
#elif NET472
return ("Net", new(4, 7));
#elif NET48
return ("Net", new(4, 8));
#endif

// It's only possible to get here if we've started compiling Verify for a new .NET Framework target
// and forgot to add it to the list above. Thus "not implemented" is appropriate.
throw new NotImplementedException();

#else
var description = RuntimeInformation.FrameworkDescription;

Expand Down

0 comments on commit de2374b

Please sign in to comment.