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

[API] OperatingSystem.IsWasi() #82817

Merged
merged 2 commits into from
Mar 1, 2023
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 @@ -150,7 +150,6 @@ public static bool IsBrowser() =>
false;
#endif

/* TODO https://github.com/dotnet/runtime/issues/78389
/// <summary>
/// Indicates whether the current application is running as WASI.
/// </summary>
Expand All @@ -161,7 +160,6 @@ public static bool IsWasi() =>
#else
false;
#endif
*/

/// <summary>
/// Indicates whether the current application is running on Linux.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public static class OperatingSystemTests
"Windows",
"Linux",
"FreeBSD",
"Browser"
"Browser",
"Wasi",
};

[Theory]
Expand Down Expand Up @@ -80,6 +81,12 @@ public static void IsOSPlatformVersionAtLeast_InvalidArgs_Throws()
[Fact, PlatformSpecific(TestPlatforms.Browser)]
public static void TestIsOSVersionAtLeast_Browser() => TestIsOSVersionAtLeast("BROWSER");

[Fact, PlatformSpecific(TestPlatforms.Wasi)]
public static void TestIsOSPlatform_Wasi() => TestIsOSPlatform("WASI", OperatingSystem.IsWasi);

[Fact, PlatformSpecific(TestPlatforms.Wasi)]
public static void TestIsOSVersionAtLeast_Wasi() => TestIsOSVersionAtLeast("WASI");

[Fact, PlatformSpecific(TestPlatforms.Linux)]
public static void TestIsOSPlatform_Linux() => TestIsOSPlatform("Linux", OperatingSystem.IsLinux);

Expand Down Expand Up @@ -191,7 +198,8 @@ private static void TestIsOSPlatform(string currentOSName, Func<bool> currentOSC
OperatingSystem.IsMacOS(),
OperatingSystem.IsTvOS(),
OperatingSystem.IsWatchOS(),
OperatingSystem.IsWindows()
OperatingSystem.IsWindows(),
OperatingSystem.IsWasi(),
};

// MacCatalyst is a special case since it also returns true for iOS
Expand All @@ -208,6 +216,7 @@ private static void TestIsOSPlatform(string currentOSName, Func<bool> currentOSC
Assert.False(allResults[7]); // IsTvOS()
Assert.False(allResults[8]); // IsWatchOS()
Assert.False(allResults[9]); // IsWindows()
Assert.False(allResults[10]); // IsWasi()
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4334,6 +4334,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S
public static bool IsAndroid() { throw null; }
public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; }
public static bool IsBrowser() { throw null; }
public static bool IsWasi() { throw null; }
public static bool IsFreeBSD() { throw null; }
public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformGuardAttribute("maccatalyst")]
Expand Down