Skip to content

Commit fb7f1be

Browse files
authored
Add Android specific NetCoreVersion. (#2274)
1 parent e2de0ef commit fb7f1be

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/BenchmarkDotNet/Portability/RuntimeInformation.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,21 +278,28 @@ internal static string GetRuntimeVersion()
278278

279279
private static string GetNetCoreVersion()
280280
{
281-
var coreclrAssemblyInfo = FileVersionInfo.GetVersionInfo(typeof(object).GetTypeInfo().Assembly.Location);
282-
var corefxAssemblyInfo = FileVersionInfo.GetVersionInfo(typeof(Regex).GetTypeInfo().Assembly.Location);
283-
284-
if (CoreRuntime.TryGetVersion(out var version) && version >= new Version(5, 0))
281+
if (IsAndroid())
285282
{
286-
// after the merge of dotnet/corefx and dotnet/coreclr into dotnet/runtime the version should always be the same
287-
Debug.Assert(coreclrAssemblyInfo.FileVersion == corefxAssemblyInfo.FileVersion);
288-
289-
return $".NET {version} ({coreclrAssemblyInfo.FileVersion})";
283+
return $".NET {Environment.Version}";
290284
}
291285
else
292286
{
293-
string runtimeVersion = version != default ? version.ToString() : "?";
287+
var coreclrAssemblyInfo = FileVersionInfo.GetVersionInfo(typeof(object).GetTypeInfo().Assembly.Location);
288+
var corefxAssemblyInfo = FileVersionInfo.GetVersionInfo(typeof(Regex).GetTypeInfo().Assembly.Location);
289+
290+
if (CoreRuntime.TryGetVersion(out var version) && version >= new Version(5, 0))
291+
{
292+
// after the merge of dotnet/corefx and dotnet/coreclr into dotnet/runtime the version should always be the same
293+
Debug.Assert(coreclrAssemblyInfo.FileVersion == corefxAssemblyInfo.FileVersion);
294294

295-
return $".NET Core {runtimeVersion} (CoreCLR {coreclrAssemblyInfo.FileVersion}, CoreFX {corefxAssemblyInfo.FileVersion})";
295+
return $".NET {version} ({coreclrAssemblyInfo.FileVersion})";
296+
}
297+
else
298+
{
299+
string runtimeVersion = version != default ? version.ToString() : "?";
300+
301+
return $".NET Core {runtimeVersion} (CoreCLR {coreclrAssemblyInfo.FileVersion}, CoreFX {corefxAssemblyInfo.FileVersion})";
302+
}
296303
}
297304
}
298305

0 commit comments

Comments
 (0)