Skip to content

Commit 0634353

Browse files
committed
Remove as many references to RuntimeEnvironment as possible.
1 parent ac3677c commit 0634353

File tree

11 files changed

+33
-14
lines changed

11 files changed

+33
-14
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/DotnetVersionFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ internal class DotnetVersionFile
1818
/// The runtime identifier (rid) that this CLI was built for.
1919
/// </summary>
2020
/// <remarks>
21-
/// This is different than RuntimeEnvironment.GetRuntimeIdentifier() because the
21+
/// This is different than RuntimeInformation.RuntimeIdentifier because the
2222
/// BuildRid is a RID that is guaranteed to exist and works on the current machine. The
23-
/// RuntimeEnvironment.GetRuntimeIdentifier() may be for a new version of the OS that
23+
/// RuntimeInformation.RuntimeIdentifier may be for a new version of the OS that
2424
/// doesn't have full support yet.
2525
/// </remarks>
2626
public string BuildRid { get; set; }

src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private class DistroInfo
112112
public string VersionId;
113113
}
114114

115-
public static string GetOSName()
115+
private static string GetOSName()
116116
{
117117
switch (GetOSPlatform())
118118
{
@@ -129,7 +129,7 @@ public static string GetOSName()
129129
}
130130
}
131131

132-
public static string GetOSVersion()
132+
private static string GetOSVersion()
133133
{
134134
switch (GetOSPlatform())
135135
{
@@ -183,7 +183,7 @@ private static string GetFreeBSDVersion()
183183
return string.Empty;
184184
}
185185

186-
public static Platform GetOSPlatform()
186+
private static Platform GetOSPlatform()
187187
{
188188
return _platform.Value;
189189
}

src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAProjectPathCommandResolver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.IO;
6+
using System.Runtime.InteropServices;
67
using FluentAssertions;
78
using Microsoft.DotNet.Cli.Utils;
89
using Microsoft.DotNet.CommandFactory;
@@ -243,7 +244,7 @@ private ProjectPathCommandResolver SetupPlatformProjectPathCommandResolver(
243244

244245
IPlatformCommandSpecFactory platformCommandSpecFactory = new GenericPlatformCommandSpecFactory();
245246

246-
if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows
247+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
247248
&& !forceGeneric)
248249
{
249250
platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory();

src/Tests/Microsoft.DotNet.CommandFactory.Tests/GivenAnAppBaseCommandResolver.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
using System;
55
using System.IO;
6+
using System.Runtime.InteropServices;
67
using FluentAssertions;
8+
using Microsoft.DotNet.Cli.Utils;
79
using Microsoft.DotNet.CommandFactory;
810
using Xunit;
9-
using Microsoft.DotNet.Cli.Utils;
1011

1112
namespace Microsoft.DotNet.Tests
1213
{
@@ -187,7 +188,7 @@ private AppBaseCommandResolver SetupPlatformAppBaseCommandResolver(
187188

188189
IPlatformCommandSpecFactory platformCommandSpecFactory = new GenericPlatformCommandSpecFactory();
189190

190-
if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows
191+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
191192
&& !forceGeneric)
192193
{
193194
platformCommandSpecFactory = new WindowsExePreferredCommandSpecFactory();

src/Tests/Microsoft.NET.TestFramework/AssertionHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static string[] AppendApphostOnNonMacOS(string ProjectName, string[] expe
1111
{
1212
string apphost = $"{ProjectName}{Constants.ExeSuffix}";
1313
// No UseApphost is false by default on macOS
14-
return !RuntimeInformation.IsOSPlatform (OSPlatform.OSX)
14+
return !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
1515
? expectedFiles.Append(apphost).ToArray()
1616
: expectedFiles;
1717
}

src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkFactAttribute.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
#if NETCOREAPP
5+
46
using Xunit;
57

68
namespace Microsoft.NET.TestFramework
@@ -16,3 +18,5 @@ public RequiresSpecificFrameworkFactAttribute(string framework)
1618
}
1719
}
1820
}
21+
22+
#endif

src/Tests/Microsoft.NET.TestFramework/Attributes/RequiresSpecificFrameworkTheoryAttribute.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
#if NETCOREAPP
5+
46
using Microsoft.DotNet.Tools.Test.Utilities;
57
using System;
68
using System.Collections.Generic;
@@ -20,3 +22,5 @@ public RequiresSpecificFrameworkTheoryAttribute(string framework)
2022
}
2123
}
2224
}
25+
26+
#endif

src/Tests/Microsoft.NET.TestFramework/Commands/ComposeStoreCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
#if NETCOREAPP
5+
46
using Microsoft.DotNet.Cli.Utils;
57
using System.IO;
8+
using System.Runtime.InteropServices;
69
using Xunit.Abstractions;
710

811
namespace Microsoft.NET.TestFramework.Commands
@@ -31,10 +34,12 @@ private string BuildRelativeOutputPath(string targetFramework, string configurat
3134
{
3235
if (runtimeIdentifier.Length == 0)
3336
{
34-
runtimeIdentifier = RuntimeEnvironment.GetRuntimeIdentifier();
37+
runtimeIdentifier = RuntimeInformation.RuntimeIdentifier;
3538
}
3639
string arch = runtimeIdentifier.Substring(runtimeIdentifier.LastIndexOf("-") + 1);
3740
return Path.Combine(configuration, arch, targetFramework, PublishSubfolderName);
3841
}
3942
}
4043
}
44+
45+
#endif

src/Tests/Microsoft.NET.TestFramework/EnvironmentInfo.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
#if NETCOREAPP
5+
46
using System;
57
using System.Runtime.InteropServices;
68
using NuGet.Frameworks;
@@ -19,7 +21,7 @@ public static string ExecutableExtension
1921

2022
public static string GetCompatibleRid(string targetFramework = null)
2123
{
22-
string rid = DotNet.Cli.Utils.RuntimeEnvironment.GetRuntimeIdentifier();
24+
string rid = RuntimeInformation.RuntimeIdentifier;
2325

2426
if (targetFramework == null)
2527
{
@@ -56,7 +58,7 @@ public static string GetCompatibleRid(string targetFramework = null)
5658
public static bool SupportsTargetFramework(string targetFramework)
5759
{
5860
var nugetFramework = NuGetFramework.Parse(targetFramework);
59-
string currentRid = DotNet.Cli.Utils.RuntimeEnvironment.GetRuntimeIdentifier();
61+
string currentRid = RuntimeInformation.RuntimeIdentifier;
6062

6163
string ridOS = currentRid.Split('.')[0];
6264
if (ridOS.Equals("alpine", StringComparison.OrdinalIgnoreCase))
@@ -162,3 +164,5 @@ public static bool SupportsTargetFramework(string targetFramework)
162164
}
163165
}
164166
}
167+
168+
#endif

src/Tests/dotnet.Tests/GivenThatIWantToManageMulticoreJIT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private static string GetUserProfileRoot(string overrideUserProfileRoot = null)
8787

8888
private static string GetOptimizationRootPath(string version)
8989
{
90-
var rid = DotNet.Cli.Utils.RuntimeEnvironment.GetRuntimeIdentifier();
90+
var rid = RuntimeInformation.RuntimeIdentifier;
9191

9292
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
9393
? $@"Microsoft\dotnet\optimizationdata\{version}\{rid}"

0 commit comments

Comments
 (0)