Skip to content

Commit 6861b62

Browse files
committed
Use RuntimeInformation across corefx for platform detection
This commit deletes our temporary Interop.PlatformDetection.cs mechanism and replaces usage of it with usage of System.Runtime.InteropServices.RuntimeInformation.dll.
1 parent c47d44a commit 6861b62

69 files changed

Lines changed: 583 additions & 524 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Common/src/Interop/Interop.PlatformDetection.cs

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/System.Console/tests/Color.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.IO;
66
using System.Linq;
7+
using System.Runtime.InteropServices;
78
using System.Text;
89
using Xunit;
910

@@ -19,7 +20,7 @@ public static void InvalidColors()
1920
[Fact]
2021
public static void RoundtrippingColor()
2122
{
22-
if (Interop.IsWindows)
23+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
2324
{
2425
Console.BackgroundColor = Console.BackgroundColor;
2526
Console.ForegroundColor = Console.ForegroundColor;

src/System.Console/tests/System.Console.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
<Compile Include="Timeout.cs" />
2727
<Compile Include="ThreadSafety.cs" />
2828
<Compile Include="XunitAssemblyAttributes.cs" />
29-
<Compile Include="$(CommonPath)\Interop\Interop.PlatformDetection.cs">
30-
<Link>Common\Interop\Interop.PlatformDetection.cs</Link>
31-
</Compile>
3229
</ItemGroup>
3330
<ItemGroup>
3431
<ProjectReference Include="..\src\System.Console.csproj">

src/System.Console/tests/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"System.IO.FileSystem": "4.0.0",
77
"System.Runtime": "4.0.20",
88
"System.Runtime.Extensions": "4.0.10",
9+
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-beta-*",
910
"System.Text.Encoding": "4.0.10",
1011
"System.Threading": "4.0.10",
1112
"System.Threading.Overlapped": "4.0.0",

src/System.Console/tests/project.lock.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@
217217
"lib/DNXCore50/System.Runtime.InteropServices.dll": {}
218218
}
219219
},
220+
"System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23127": {
221+
"dependencies": {
222+
"System.Runtime": "4.0.20-beta-23127",
223+
"System.Resources.ResourceManager": "4.0.0-beta-23127"
224+
},
225+
"compile": {
226+
"ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {}
227+
},
228+
"runtime": {
229+
"lib/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {}
230+
}
231+
},
220232
"System.Text.Encoding/4.0.10": {
221233
"dependencies": {
222234
"System.Runtime": "4.0.0"
@@ -926,6 +938,25 @@
926938
"runtimes/win8-aot/lib/netcore50/System.Runtime.InteropServices.dll"
927939
]
928940
},
941+
"System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23127": {
942+
"serviceable": true,
943+
"sha512": "bDj3DiQ5yf6Asf8gxuLo5jpqiNw5JprFIiJvYppE58YXqqvf1TI3XGsg9jezFSuoKl3VsHjVlMvy/poFpwvFXQ==",
944+
"files": [
945+
"System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23127.nupkg",
946+
"System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23127.nupkg.sha512",
947+
"System.Runtime.InteropServices.RuntimeInformation.nuspec",
948+
"lib/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll",
949+
"lib/MonoAndroid10/_._",
950+
"lib/MonoTouch10/_._",
951+
"lib/xamarinios10/_._",
952+
"lib/xamarinmac20/_._",
953+
"ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll",
954+
"ref/MonoAndroid10/_._",
955+
"ref/MonoTouch10/_._",
956+
"ref/xamarinios10/_._",
957+
"ref/xamarinmac20/_._"
958+
]
959+
},
929960
"System.Text.Encoding/4.0.10": {
930961
"sha512": "fNlSFgy4OuDlJrP9SFFxMlaLazq6ipv15sU5TiEgg9UCVnA/OgoVUfymFp4AOk1jOkW5SVxWbeeIUptcM+m/Vw==",
931962
"files": [
@@ -1290,6 +1321,7 @@
12901321
"System.IO.FileSystem >= 4.0.0",
12911322
"System.Runtime >= 4.0.20",
12921323
"System.Runtime.Extensions >= 4.0.10",
1324+
"System.Runtime.InteropServices.RuntimeInformation >= 4.0.0-beta-*",
12931325
"System.Text.Encoding >= 4.0.10",
12941326
"System.Threading >= 4.0.10",
12951327
"System.Threading.Overlapped >= 4.0.0",

src/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/FileVersionInfoTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using System.Globalization;
77
using System.IO;
8+
using System.Runtime.InteropServices;
89
using System.Text;
910
using Xunit;
1011

@@ -150,7 +151,7 @@ public void FileVersionInfo_CustomManagedAssembly()
150151
IsPrivateBuild = false,
151152
IsPreRelease = false,
152153
IsSpecialBuild = false,
153-
Language = Interop.IsWindows ? GetFileVersionLanguage(0x0000) : "Language Neutral", //Language Neutral
154+
Language = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? GetFileVersionLanguage(0x0000) : "Language Neutral",
154155
LegalCopyright = "Copyright, you betcha!",
155156
LegalTrademarks = "TM",
156157
OriginalFilename = TestAssemblyFileName,

src/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
<ItemGroup>
3535
<Compile Include="FileVersionInfoTest.cs" />
3636
<Compile Include="Interop\Interop.Windows.cs" />
37-
<Compile Include="$(CommonPath)\Interop\Interop.PlatformDetection.cs">
38-
<Link>Common\Interop\Interop.PlatformDetection.cs</Link>
39-
</Compile>
4037
</ItemGroup>
4138
<!-- References used -->
4239
<ItemGroup>

src/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"System.Runtime": "4.0.20",
1111
"System.Runtime.Extensions": "4.0.10",
1212
"System.Runtime.InteropServices": "4.0.20",
13+
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-beta-*",
1314
"System.Runtime.Handles": "4.0.0",
1415
"System.Text.Encoding": "4.0.10",
1516
"System.Threading.Tasks": "4.0.10",

src/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/project.lock.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@
260260
"lib/DNXCore50/System.Runtime.InteropServices.dll": {}
261261
}
262262
},
263+
"System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23127": {
264+
"dependencies": {
265+
"System.Runtime": "4.0.20-beta-23127",
266+
"System.Resources.ResourceManager": "4.0.0-beta-23127"
267+
},
268+
"compile": {
269+
"ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {}
270+
},
271+
"runtime": {
272+
"lib/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll": {}
273+
}
274+
},
263275
"System.Text.Encoding/4.0.10": {
264276
"dependencies": {
265277
"System.Runtime": "4.0.0"
@@ -954,6 +966,25 @@
954966
"runtimes/win8-aot/lib/netcore50/System.Runtime.InteropServices.dll"
955967
]
956968
},
969+
"System.Runtime.InteropServices.RuntimeInformation/4.0.0-beta-23127": {
970+
"serviceable": true,
971+
"sha512": "bDj3DiQ5yf6Asf8gxuLo5jpqiNw5JprFIiJvYppE58YXqqvf1TI3XGsg9jezFSuoKl3VsHjVlMvy/poFpwvFXQ==",
972+
"files": [
973+
"System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23127.nupkg",
974+
"System.Runtime.InteropServices.RuntimeInformation.4.0.0-beta-23127.nupkg.sha512",
975+
"System.Runtime.InteropServices.RuntimeInformation.nuspec",
976+
"lib/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll",
977+
"lib/MonoAndroid10/_._",
978+
"lib/MonoTouch10/_._",
979+
"lib/xamarinios10/_._",
980+
"lib/xamarinmac20/_._",
981+
"ref/dotnet/System.Runtime.InteropServices.RuntimeInformation.dll",
982+
"ref/MonoAndroid10/_._",
983+
"ref/MonoTouch10/_._",
984+
"ref/xamarinios10/_._",
985+
"ref/xamarinmac20/_._"
986+
]
987+
},
957988
"System.Text.Encoding/4.0.10": {
958989
"sha512": "fNlSFgy4OuDlJrP9SFFxMlaLazq6ipv15sU5TiEgg9UCVnA/OgoVUfymFp4AOk1jOkW5SVxWbeeIUptcM+m/Vw==",
959990
"files": [
@@ -1232,6 +1263,7 @@
12321263
"System.Runtime >= 4.0.20",
12331264
"System.Runtime.Extensions >= 4.0.10",
12341265
"System.Runtime.InteropServices >= 4.0.20",
1266+
"System.Runtime.InteropServices.RuntimeInformation >= 4.0.0-beta-*",
12351267
"System.Runtime.Handles >= 4.0.0",
12361268
"System.Text.Encoding >= 4.0.10",
12371269
"System.Threading.Tasks >= 4.0.10",

src/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests/ProcessStandardConsoleTests.cs

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

4+
using System.Runtime.InteropServices;
45
using System.Text;
56
using Xunit;
67

@@ -29,7 +30,7 @@ public void TestChangesInConsoleEncoding()
2930
Assert.True(p.WaitForExit(WaitInMS));
3031
};
3132

32-
if (global::Interop.PlatformDetection.OperatingSystem != global::Interop.OperatingSystem.Windows)
33+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
3334
{
3435
run(Encoding.UTF8.CodePage);
3536
return;

0 commit comments

Comments
 (0)