Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSPlatform entries for iOS/tvOS/watchOS/Android #36704

Merged
merged 3 commits into from
Jul 10, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ public enum Architecture
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public static System.Runtime.InteropServices.OSPlatform Android { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform Browser { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform FreeBSD { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform iOS { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform Linux { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform OSX { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform tvOS { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform watchOS { get { throw null; } }
stephentoub marked this conversation as resolved.
Show resolved Hide resolved
public static System.Runtime.InteropServices.OSPlatform Windows { get { throw null; } }
public static System.Runtime.InteropServices.OSPlatform Create(string osPlatform) { throw null; }
public override bool Equals(object? obj) { throw null; }
Expand All @@ -33,11 +37,11 @@ public enum Architecture
}
public static partial class RuntimeInformation
{
public static string RuntimeIdentifier { get { throw null; } }
public static string FrameworkDescription { get { throw null; } }
public static System.Runtime.InteropServices.Architecture OSArchitecture { get { throw null; } }
public static string OSDescription { get { throw null; } }
public static System.Runtime.InteropServices.Architecture ProcessArchitecture { get { throw null; } }
public static string RuntimeIdentifier { get { throw null; } }
public static bool IsOSPlatform(System.Runtime.InteropServices.OSPlatform osPlatform) { throw null; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace System.Runtime.InteropServices
{
private readonly string _osPlatform;

public static OSPlatform Android { get; } = new OSPlatform("ANDROID");

public static OSPlatform Browser { get; } = new OSPlatform("BROWSER");

public static OSPlatform FreeBSD { get; } = new OSPlatform("FREEBSD");
Expand All @@ -15,6 +17,12 @@ namespace System.Runtime.InteropServices

public static OSPlatform OSX { get; } = new OSPlatform("OSX");

public static OSPlatform iOS { get; } = new OSPlatform("IOS");

public static OSPlatform tvOS { get; } = new OSPlatform("TVOS");

public static OSPlatform watchOS { get; } = new OSPlatform("WATCHOS");
stephentoub marked this conversation as resolved.
Show resolved Hide resolved
stephentoub marked this conversation as resolved.
Show resolved Hide resolved

public static OSPlatform Windows { get; } = new OSPlatform("WINDOWS");

private OSPlatform(string osPlatform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,82 @@ public void CheckOSX()
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD));
}

[Fact, PlatformSpecific(TestPlatforms.iOS)] // Tests RuntimeInformation OS platform
public void CheckiOS()
{
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.iOS));
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS")));

Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NetBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("netbsd")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("osx")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("mac")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("DARWIN")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACOSX")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD));
}

[Fact, PlatformSpecific(TestPlatforms.tvOS)] // Tests RuntimeInformation OS platform
public void ChecktvOS()
{
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.tvOS));
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS")));

Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NetBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("netbsd")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("osx")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("mac")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("DARWIN")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACOSX")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD));
}

[Fact, PlatformSpecific(TestPlatforms.Android)] // Tests RuntimeInformation OS platform
public void CheckAndroid()
{
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Android));
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")));

Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NetBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("netbsd")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("osx")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("mac")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("DARWIN")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACOSX")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD));
}

[Fact, PlatformSpecific(TestPlatforms.Browser)] // Tests RuntimeInformation OS platform
public void CheckBrowser()
{
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Browser));
Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")));

Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("NetBSD")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("netbsd")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("osx")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("mac")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("DARWIN")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACOSX")));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD));
}

[Fact, PlatformSpecific(TestPlatforms.Windows)] // Tests RuntimeInformation OS platform
public void CheckWindows()
{
Expand Down