Skip to content

Commit 40736e9

Browse files
Remove dependency to Microsoft.DotNet.PlatformAbstractions. (#3190)
1 parent dde87a1 commit 40736e9

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

src/BenchmarkDotNet/BenchmarkDotNet.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="4.0.726401" />
3131
<PackageReference Include="Perfolizer" Version="[0.6.6]" />
3232
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.2.4" PrivateAssets="contentfiles;analyzers" />
33-
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
3433
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
3534
<PackageReference Include="System.Management" Version="10.0.9" />
3635
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.9" />

src/BenchmarkDotNet/Detectors/OsDetector.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Runtime.InteropServices;
66
using System.Runtime.Versioning;
77
using static System.Runtime.InteropServices.RuntimeInformation;
8-
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;
98

109
namespace BenchmarkDotNet.Detectors;
1110

@@ -53,8 +52,8 @@ private static OsInfo ResolveOs()
5352
}
5453
}
5554

56-
string operatingSystem = RuntimeEnvironment.OperatingSystem;
57-
string operatingSystemVersion = RuntimeEnvironment.OperatingSystemVersion;
55+
string operatingSystem = OSDescription;
56+
string operatingSystemVersion = Environment.OSVersion.ToString();
5857
if (IsWindows())
5958
{
6059
int? ubr = GetWindowsUbr();

src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
using System.Diagnostics.CodeAnalysis;
2+
using System.Runtime.InteropServices;
23
using BenchmarkDotNet.Detectors;
34
using BenchmarkDotNet.Environments;
45
using BenchmarkDotNet.Extensions;
5-
using BenchmarkDotNet.Portability;
66
using JetBrains.Annotations;
7-
#if NETSTANDARD
8-
using Microsoft.DotNet.PlatformAbstractions;
9-
#endif
107

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

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

133-
string architecture =
134-
#if NETSTANDARD
135-
RuntimeEnvironment.RuntimeArchitecture;
136-
#else
137-
System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
138-
#endif
130+
string architecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
139131

140132
return $"{osPart}-{architecture}";
141133
}

0 commit comments

Comments
 (0)