Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/BenchmarkDotNet/BenchmarkDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="4.0.726401" />
<PackageReference Include="Perfolizer" Version="[0.6.6]" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.2.4" PrivateAssets="contentfiles;analyzers" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
<PackageReference Include="System.Management" Version="10.0.9" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.9" />
Expand Down
5 changes: 2 additions & 3 deletions src/BenchmarkDotNet/Detectors/OsDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using static System.Runtime.InteropServices.RuntimeInformation;
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;

namespace BenchmarkDotNet.Detectors;

Expand Down Expand Up @@ -53,8 +52,8 @@ private static OsInfo ResolveOs()
}
}

string operatingSystem = RuntimeEnvironment.OperatingSystem;
string operatingSystemVersion = RuntimeEnvironment.OperatingSystemVersion;
string operatingSystem = OSDescription;
string operatingSystemVersion = Environment.OSVersion.ToString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These APIs do not seem to be compatible.

Microsoft.DotNet.PlatformAbstractions APIs returns following outputs.

  • Windows
  • 10.0.26200

In contrast, replaced API returns following outputs.

  • Microsoft Windows 10.0.26200
  • Microsoft Windows NT 6.2.9200.0

if (IsWindows())
{
int? ubr = GetWindowsUbr();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Detectors;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Extensions;
using BenchmarkDotNet.Portability;
using JetBrains.Annotations;
#if NETSTANDARD
using Microsoft.DotNet.PlatformAbstractions;
#endif

namespace BenchmarkDotNet.Toolchains.DotNetCli
{
Expand Down Expand Up @@ -64,7 +61,7 @@ protected string GetTargetFrameworkMoniker()
{
if (targetFrameworkMoniker.IsNotBlank())
return targetFrameworkMoniker;
if (!RuntimeInformation.IsNetCore)
if (!Portability.RuntimeInformation.IsNetCore)
throw new NotSupportedException("You must specify the target framework moniker in explicit way using builder.TargetFrameworkMoniker(tfm) method");

return CoreRuntime.GetCurrentVersion().MsBuildMoniker;
Expand Down Expand Up @@ -130,12 +127,7 @@ internal static string GetPortableRuntimeIdentifier()
// the values taken from https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#macos-rids
string osPart = OsDetector.IsWindows() ? "win" : (OsDetector.IsMacOS() ? "osx" : "linux");

string architecture =
#if NETSTANDARD
RuntimeEnvironment.RuntimeArchitecture;
#else
System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
#endif
string architecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();

return $"{osPart}-{architecture}";
}
Expand Down
Loading