diff --git a/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs b/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs index 0e1278fd1a2cab..b6961ccedbe7be 100644 --- a/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs +++ b/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs @@ -24,7 +24,7 @@ internal static bool IsCaseSensitive { get { - return !(OperatingSystem.IsWindows() || OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()); + return !(OperatingSystem.IsWindows() || OperatingSystem.IsApplePlatform()); } } } diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs index 3b78641a006839..b6ce9aa5ee7b19 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor.Tests.cs @@ -100,7 +100,7 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor } catch (UnauthorizedAccessException) { - if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || PlatformDetection.IsInContainer) && + if ((OperatingSystem.IsApplePlatform() || PlatformDetection.IsInContainer) && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute)) { // Containers and OSXlike platforms with SIP enabled do not have execute permissions by default. diff --git a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs index cd1af097e216f4..360092d064122e 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream.Tests.cs @@ -100,7 +100,7 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor } catch (UnauthorizedAccessException) { - if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || PlatformDetection.IsInContainer) && + if ((OperatingSystem.IsApplePlatform() || PlatformDetection.IsInContainer) && (viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute)) { // Containers and OSXlike platforms with SIP enabled do not have execute permissions by default. diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs index 4bbcc24f6ad566..8c74d4a003fc2c 100644 --- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs +++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs @@ -57,9 +57,9 @@ public void IPGlobalProperties_AccessAllMethods_NoErrors() Assert.NotNull(gp.GetTcpIPv6Statistics()); Assert.NotNull(gp.GetUdpIPv6Statistics()); - if (!OperatingSystem.IsMacOS() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS() && !OperatingSystem.IsFreeBSD()) + if (!OperatingSystem.IsApplePlatform() && !OperatingSystem.IsFreeBSD()) { - // OSX and FreeBSD do not provide IPv6 stats. + // OSX and FreeBSD do not provide IPv6 stats. Assert.NotNull(gp.GetIPv6GlobalStatistics()); } } diff --git a/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs b/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs index 27693762f6b025..3b5debc751ddcc 100644 --- a/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs +++ b/src/libraries/System.Net.Ping/tests/FunctionalTests/PingTest.cs @@ -80,7 +80,7 @@ private static byte[] GetPingPayload(AddressFamily addressFamily) : Array.Empty(); public static bool DoesNotUsePingUtility => OperatingSystem.IsWindows() || - OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || + OperatingSystem.IsApplePlatform() || Capability.CanUseRawSockets(TestSettings.GetLocalIPAddress().AddressFamily); public static bool UsesPingUtility => !DoesNotUsePingUtility; diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic.cs index facf6b75afe020..3e78cb8fa7ce85 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic.cs @@ -148,7 +148,7 @@ internal struct QuicAddr [FieldOffset(0)] public QuicAddrFamilyAndLen FamilyLen; - public static bool SockaddrHasLength => OperatingSystem.IsFreeBSD() || OperatingSystem.IsIOS() || OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsTvOS(); + public static bool SockaddrHasLength => OperatingSystem.IsFreeBSD() || OperatingSystem.IsApplePlatform(); public int Family { diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs index 0cdb560aa3b2f1..6d71fad55c37fc 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs @@ -19,7 +19,7 @@ internal static partial class SocketPal public static readonly int MaximumAddressSize = Interop.Sys.GetMaximumAddressSize(); private static readonly bool SupportsDualModeIPv4PacketInfo = GetPlatformSupportsDualModeIPv4PacketInfo(); - private static readonly bool SelectOverPollIsBroken = OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsMacCatalyst(); + private static bool SelectOverPollIsBroken => OperatingSystem.IsApplePlatform(); // IovStackThreshold matches Linux's UIO_FASTIOV, which is the number of 'struct iovec' // that get stackalloced in the Linux kernel. diff --git a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs index a438d13e238881..e54b7286286552 100644 --- a/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs @@ -124,7 +124,7 @@ public unsafe string VersionString /// /// Indicates whether the current application is running on the specified platform. /// - /// Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, watchOS, Windows. + /// Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, Windows. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSPlatform(string platform) { @@ -142,7 +142,7 @@ public static bool IsOSPlatform(string platform) /// /// Check for the OS with a >= version comparison. Used to guard APIs that were added in the given OS release. /// - /// Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, watchOS, Windows. + /// Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, Windows. /// Major OS version number. /// Minor OS version number (optional). /// Build OS version number (optional). @@ -287,7 +287,11 @@ public static bool IsMacOS() => false; #endif - internal static bool IsApplePlatform() => + /// + /// Indicates whether the current application is running on Apple platforms. + /// + [NonVersionable] + public static bool IsApplePlatform() => #if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS true; #else @@ -337,17 +341,16 @@ public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0) /// /// Indicates whether the current application is running on watchOS. /// + /// watchOS is no longer supported. This method always returns . [NonVersionable] public static bool IsWatchOS() => -#if TARGET_WATCHOS - true; -#else + // watchOS is no longer supported. false; -#endif /// /// Check for the watchOS version (returned by 'libobjc.get_operatingSystemVersion') with a >= version comparison. Used to guard APIs that were added in the given watchOS release. /// + /// watchOS is no longer supported. This method always returns . public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0) => IsWatchOS() && IsOSVersionAtLeast(major, minor, build, 0); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs index 30ff7303e7aa76..76d9d56ed852ae 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs @@ -20,8 +20,6 @@ public static partial class RuntimeInformation $"iOS {Environment.OSVersion.Version}"; #elif TARGET_TVOS $"tvOS {Environment.OSVersion.Version}"; -#elif TARGET_WATCHOS - $"watchOS {Environment.OSVersion.Version}"; #elif TARGET_LINUX Interop.OSReleaseFile.GetPrettyName() ?? Interop.Sys.GetUnixVersion(); #else diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 2489f8cd6df48a..c14ce338a1cd58 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -4977,6 +4977,7 @@ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, S public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0) { throw null; } public static bool IsMacOS() { throw null; } public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0) { throw null; } + public static bool IsApplePlatform() { throw null; } public static bool IsOpenBSD() { throw null; } public static bool IsOpenBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0) { throw null; } public static bool IsOSPlatform(string platform) { throw null; } diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/OperatingSystemTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/OperatingSystemTests.cs index 6c2f1867e67d40..bd96a6baf80038 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/OperatingSystemTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/OperatingSystemTests.cs @@ -15,7 +15,6 @@ public static class OperatingSystemTests "MacCatalyst", "iOS", "tvOS", - "watchOS", "Windows", "Linux", "FreeBSD", @@ -23,6 +22,14 @@ public static class OperatingSystemTests "Wasi", }; + private static readonly HashSet AllApplePlatformNames = new() + { + "macOS", + "MacCatalyst", + "iOS", + "tvOS", + }; + [Theory] [InlineData(PlatformID.Other, "1.0.0.0")] [InlineData(PlatformID.MacOSX, "1.2")] @@ -188,6 +195,10 @@ private static void TestIsOSPlatform(string currentOSName, Func currentOSC Assert.True(currentOSCheck()); + Assert.Equal( + AllApplePlatformNames.Contains(currentOSName), + OperatingSystem.IsApplePlatform()); + Dictionary allResults = new() { { "IsBrowser", OperatingSystem.IsBrowser() }, @@ -252,7 +263,6 @@ private static void TestIsOSVersionAtLeast(string currentOSName) AssertVersionChecks(currentOSName.Equals("macOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsMacOSVersionAtLeast); AssertVersionChecks(currentOSName.Equals("MacCatalyst", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsMacCatalystVersionAtLeast); AssertVersionChecks(currentOSName.Equals("tvOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsTvOSVersionAtLeast); - AssertVersionChecks(currentOSName.Equals("watchOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsWatchOSVersionAtLeast); AssertVersionChecks(currentOSName.Equals("Windows", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsWindowsVersionAtLeast); } diff --git a/src/native/eventpipe/ep-event-source.c b/src/native/eventpipe/ep-event-source.c index 7d1f8f57e4ff50..c967aa3eb520af 100644 --- a/src/native/eventpipe/ep-event-source.c +++ b/src/native/eventpipe/ep-event-source.c @@ -18,8 +18,6 @@ const ep_char8_t* _ep_os_info = "Windows"; const ep_char8_t* _ep_os_info = "tvOS"; #elif defined(HOST_IOS) const ep_char8_t* _ep_os_info = "iOS"; -#elif defined(HOST_WATCHOS) -const ep_char8_t* _ep_os_info = "watchOS"; #elif defined(HOST_MACCAT) const ep_char8_t* _ep_os_info = "MacCatalyst"; #elif defined(__APPLE__) diff --git a/src/native/libs/System.Native/pal_time.c b/src/native/libs/System.Native/pal_time.c index edb6dccdfc27fb..2cec732d242273 100644 --- a/src/native/libs/System.Native/pal_time.c +++ b/src/native/libs/System.Native/pal_time.c @@ -65,7 +65,7 @@ int32_t SystemNative_FUTimens(intptr_t fd, TimeSpec* times) while (CheckInterrupted(result = futimens(ToFileDescriptor(fd), updatedTimes))); #else - // Fallback on unsupported platforms (e.g. iOS, tvOS, watchOS) + // Fallback on unsupported platforms (e.g. iOS, tvOS) // to futimes (lower precision) struct timeval updatedTimes[2]; updatedTimes[0].tv_sec = (long)times[0].tv_sec; diff --git a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c index 88898efc9b7b64..200ce888402810 100644 --- a/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c +++ b/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c @@ -578,7 +578,7 @@ int32_t AppleCryptoNative_SslSetEnabledCipherSuites(SSLContextRef sslContext, co else #endif { - // MacCatalyst arm64, iOS, tvOS, watchOS + // MacCatalyst arm64, iOS, tvOS SSLCipherSuite* cipherSuites16 = (SSLCipherSuite*)calloc((size_t)numCipherSuites, sizeof(SSLCipherSuite)); if (cipherSuites16 == NULL)