diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index 26fbb1510a0c3..6fc2f2257fe7b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -150,7 +150,6 @@ public static bool IsBrowser() => false; #endif -/* TODO https://github.com/dotnet/runtime/issues/78389 /// /// Indicates whether the current application is running as WASI. /// @@ -161,7 +160,6 @@ public static bool IsWasi() => #else false; #endif -*/ /// /// Indicates whether the current application is running on Linux. diff --git a/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs b/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs index 3a7e5aaa60f25..adaf447f1fc37 100644 --- a/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs +++ b/src/libraries/System.Runtime.Extensions/tests/System/OperatingSystemTests.cs @@ -18,7 +18,8 @@ public static class OperatingSystemTests "Windows", "Linux", "FreeBSD", - "Browser" + "Browser", + "Wasi", }; [Theory] @@ -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); @@ -191,7 +198,8 @@ private static void TestIsOSPlatform(string currentOSName, Func 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 @@ -208,6 +216,7 @@ private static void TestIsOSPlatform(string currentOSName, Func currentOSC Assert.False(allResults[7]); // IsTvOS() Assert.False(allResults[8]); // IsWatchOS() Assert.False(allResults[9]); // IsWindows() + Assert.False(allResults[10]); // IsWasi() } else { diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 2de21393bbc2b..318cb39b988f5 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -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")]