Skip to content
Open
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 @@ -24,7 +24,7 @@ internal static bool IsCaseSensitive
{
get
{
return !(OperatingSystem.IsWindows() || OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS());
return !(OperatingSystem.IsWindows() || OperatingSystem.IsApplePlatform());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static byte[] GetPingPayload(AddressFamily addressFamily)
: Array.Empty<byte>();

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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public unsafe string VersionString
/// <summary>
/// Indicates whether the current application is running on the specified platform.
/// </summary>
/// <param name="platform">Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, watchOS, Windows.</param>
/// <param name="platform">Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, Windows.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsOSPlatform(string platform)
{
Expand All @@ -142,7 +142,7 @@ public static bool IsOSPlatform(string platform)
/// <summary>
/// Check for the OS with a >= version comparison. Used to guard APIs that were added in the given OS release.
/// </summary>
/// <param name="platform">Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, watchOS, Windows.</param>
/// <param name="platform">Case-insensitive platform name. Examples: Browser, Linux, FreeBSD, Android, iOS, macOS, tvOS, Windows.</param>
/// <param name="major">Major OS version number.</param>
/// <param name="minor">Minor OS version number (optional).</param>
/// <param name="build">Build OS version number (optional).</param>
Expand Down Expand Up @@ -287,7 +287,11 @@ public static bool IsMacOS() =>
false;
#endif

internal static bool IsApplePlatform() =>
/// <summary>
/// Indicates whether the current application is running on Apple platforms.
/// </summary>
[NonVersionable]
public static bool IsApplePlatform() =>
Comment thread
jkotas marked this conversation as resolved.
Resolved
Comment on lines +293 to +294
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
true;
#else
Expand Down Expand Up @@ -337,17 +341,16 @@ public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0)
/// <summary>
/// Indicates whether the current application is running on watchOS.
/// </summary>
/// <remarks>watchOS is no longer supported. This method always returns <see langword="false" />.</remarks>
[NonVersionable]
public static bool IsWatchOS() =>
#if TARGET_WATCHOS
true;
#else
// watchOS is no longer supported.
false;
#endif

/// <summary>
/// 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.
/// </summary>
/// <remarks>watchOS is no longer supported. This method always returns <see langword="false" />.</remarks>
public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0)
=> IsWatchOS() && IsOSVersionAtLeast(major, minor, build, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -4978,6 +4978,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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ public static class OperatingSystemTests
"MacCatalyst",
"iOS",
"tvOS",
"watchOS",
"Windows",
"Linux",
"FreeBSD",
"Browser",
"Wasi",
};

private static readonly HashSet<string> AllApplePlatformNames = new()
{
"macOS",
"MacCatalyst",
"iOS",
"tvOS",
};

[Theory]
[InlineData(PlatformID.Other, "1.0.0.0")]
[InlineData(PlatformID.MacOSX, "1.2")]
Expand Down Expand Up @@ -188,6 +195,10 @@ private static void TestIsOSPlatform(string currentOSName, Func<bool> currentOSC

Assert.True(currentOSCheck());

Assert.Equal(
AllApplePlatformNames.Contains(currentOSName),
OperatingSystem.IsApplePlatform());

Dictionary<string, bool> allResults = new()
{
{ "IsBrowser", OperatingSystem.IsBrowser() },
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 0 additions & 2 deletions src/native/eventpipe/ep-event-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/System.Native/pal_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading