diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/DotnetVersionFile.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/DotnetVersionFile.cs index 1f76067f2f1c..7c95e6665142 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/DotnetVersionFile.cs +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/DotnetVersionFile.cs @@ -18,9 +18,9 @@ internal class DotnetVersionFile /// The runtime identifier (rid) that this CLI was built for. /// /// - /// This is different than RuntimeEnvironment.GetRuntimeIdentifier() because the + /// This is different than RuntimeInformation.RuntimeIdentifier because the /// BuildRid is a RID that is guaranteed to exist and works on the current machine. The - /// RuntimeEnvironment.GetRuntimeIdentifier() may be for a new version of the OS that + /// RuntimeInformation.RuntimeIdentifier may be for a new version of the OS that /// doesn't have full support yet. /// public string BuildRid { get; set; } diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs index 13d47863db3f..e15cd0661ad5 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs @@ -112,7 +112,7 @@ private class DistroInfo public string VersionId; } - public static string GetOSName() + private static string GetOSName() { switch (GetOSPlatform()) { @@ -129,7 +129,7 @@ public static string GetOSName() } } - public static string GetOSVersion() + private static string GetOSVersion() { switch (GetOSPlatform()) { @@ -183,7 +183,7 @@ private static string GetFreeBSDVersion() return string.Empty; } - public static Platform GetOSPlatform() + private static Platform GetOSPlatform() { return _platform.Value; } diff --git a/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAProjectPathCommandResolver.cs b/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAProjectPathCommandResolver.cs index 0c315c30cd79..2f555ff3af56 100644 --- a/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAProjectPathCommandResolver.cs +++ b/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAProjectPathCommandResolver.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Runtime.InteropServices; using FluentAssertions; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.CommandFactory; @@ -243,7 +244,7 @@ private ProjectPathCommandResolver SetupPlatformProjectPathCommandResolver( IPlatformCommandSpecFactory platformCommandSpecFactory = new GenericPlatformCommandSpecFactory(); - if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !forceGeneric) { platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory(); diff --git a/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAnAppBaseCommandResolver.cs b/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAnAppBaseCommandResolver.cs index 74675163b658..f4976ef9ebfa 100644 --- a/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAnAppBaseCommandResolver.cs +++ b/src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAnAppBaseCommandResolver.cs @@ -3,10 +3,11 @@ using System; using System.IO; +using System.Runtime.InteropServices; using FluentAssertions; +using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.CommandFactory; using Xunit; -using Microsoft.DotNet.Cli.Utils; namespace Microsoft.DotNet.Tests { @@ -187,7 +188,7 @@ private AppBaseCommandResolver SetupPlatformAppBaseCommandResolver( IPlatformCommandSpecFactory platformCommandSpecFactory = new GenericPlatformCommandSpecFactory(); - if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !forceGeneric) { platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory(); diff --git a/src/Tests/Microsoft.NET.TestFramework/AssertionHelper.cs b/src/Tests/Microsoft.NET.TestFramework/AssertionHelper.cs index bf66b29cec74..b4584c13a24a 100644 --- a/src/Tests/Microsoft.NET.TestFramework/AssertionHelper.cs +++ b/src/Tests/Microsoft.NET.TestFramework/AssertionHelper.cs @@ -11,7 +11,7 @@ public static string[] AppendApphostOnNonMacOS(string ProjectName, string[] expe { string apphost = $"{ProjectName}{Constants.ExeSuffix}"; // No UseApphost is false by default on macOS - return !RuntimeInformation.IsOSPlatform (OSPlatform.OSX) + return !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? expectedFiles.Append(apphost).ToArray() : expectedFiles; } diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkFactAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkFactAttribute.cs index f1fddad5171f..6ab94e9ef26b 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkFactAttribute.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkFactAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if NETCOREAPP + using Xunit; namespace Microsoft.NET.TestFramework @@ -16,3 +18,5 @@ public RequiresSpecificFrameworkFactAttribute(string framework) } } } + +#endif diff --git a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkTheoryAttribute.cs b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkTheoryAttribute.cs index a0de31f8ea86..0b6b526401a1 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkTheoryAttribute.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkTheoryAttribute.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if NETCOREAPP + using Microsoft.DotNet.Tools.Test.Utilities; using System; using System.Collections.Generic; @@ -20,3 +22,5 @@ public RequiresSpecificFrameworkTheoryAttribute(string framework) } } } + +#endif diff --git a/src/Tests/Microsoft.NET.TestFramework/Commands/ComposeStoreCommand.cs b/src/Tests/Microsoft.NET.TestFramework/Commands/ComposeStoreCommand.cs index e2fc5aa528bf..1a7619baf8b6 100644 --- a/src/Tests/Microsoft.NET.TestFramework/Commands/ComposeStoreCommand.cs +++ b/src/Tests/Microsoft.NET.TestFramework/Commands/ComposeStoreCommand.cs @@ -1,8 +1,11 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if NETCOREAPP + using Microsoft.DotNet.Cli.Utils; using System.IO; +using System.Runtime.InteropServices; using Xunit.Abstractions; namespace Microsoft.NET.TestFramework.Commands @@ -31,10 +34,12 @@ private string BuildRelativeOutputPath(string targetFramework, string configurat { if (runtimeIdentifier.Length == 0) { - runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier(); + runtimeIdentifier = RuntimeInformation.RuntimeIdentifier; } string arch = runtimeIdentifier.Substring(runtimeIdentifier.LastIndexOf("-") + 1); return Path.Combine(configuration, arch, targetFramework, PublishSubfolderName); } } } + +#endif diff --git a/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs b/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs index 689eba5765cf..47a7f73283bc 100644 --- a/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs +++ b/src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if NETCOREAPP + using System; using System.Runtime.InteropServices; using NuGet.Frameworks; @@ -19,7 +21,7 @@ public static string ExecutableExtension public static string GetCompatibleRid(string targetFramework = null) { - string rid = DotNet.Cli.Utils.RuntimeEnvironment.GetRuntimeIdentifier(); + string rid = RuntimeInformation.RuntimeIdentifier; if (targetFramework == null) { @@ -56,7 +58,7 @@ public static string GetCompatibleRid(string targetFramework = null) public static bool SupportsTargetFramework(string targetFramework) { var nugetFramework = NuGetFramework.Parse(targetFramework); - string currentRid = DotNet.Cli.Utils.RuntimeEnvironment.GetRuntimeIdentifier(); + string currentRid = RuntimeInformation.RuntimeIdentifier; string ridOS = currentRid.Split('.')[0]; if (ridOS.Equals("alpine", StringComparison.OrdinalIgnoreCase)) @@ -162,3 +164,5 @@ public static bool SupportsTargetFramework(string targetFramework) } } } + +#endif diff --git a/src/Tests/dotnet.Tests/GivenThatIWantToManageMulticoreJIT.cs b/src/Tests/dotnet.Tests/GivenThatIWantToManageMulticoreJIT.cs index 13f3a6a73346..d80d1f3abf6d 100644 --- a/src/Tests/dotnet.Tests/GivenThatIWantToManageMulticoreJIT.cs +++ b/src/Tests/dotnet.Tests/GivenThatIWantToManageMulticoreJIT.cs @@ -87,7 +87,7 @@ private static string GetUserProfileRoot(string overrideUserProfileRoot = null) private static string GetOptimizationRootPath(string version) { - var rid = DotNet.Cli.Utils.RuntimeEnvironment.GetRuntimeIdentifier(); + var rid = RuntimeInformation.RuntimeIdentifier; return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $@"Microsoft\dotnet\optimizationdata\{version}\{rid}" diff --git a/src/Tests/dotnet.Tests/TelemetryCommonPropertiesTests.cs b/src/Tests/dotnet.Tests/TelemetryCommonPropertiesTests.cs index 3c77cb4651db..4c7d34d8bac4 100644 --- a/src/Tests/dotnet.Tests/TelemetryCommonPropertiesTests.cs +++ b/src/Tests/dotnet.Tests/TelemetryCommonPropertiesTests.cs @@ -109,7 +109,7 @@ public void TelemetryCommonPropertiesShouldContainEmptyLibcReleaseAndVersion2() [LinuxOnlyFact] public void TelemetryCommonPropertiesShouldContainLibcReleaseAndVersion() { - if (!DotNet.Cli.Utils.RuntimeEnvironment.OperatingSystem.Contains("Alpine", StringComparison.OrdinalIgnoreCase)) + if (!RuntimeInformation.RuntimeIdentifier.Contains("alpine", StringComparison.OrdinalIgnoreCase)) { var unitUnderTest = new TelemetryCommonProperties(getMACAddress: () => null, userLevelCacheWriter: new NothingCache()); unitUnderTest.GetTelemetryCommonProperties()["Libc Release"].Should().NotBeEmpty();