From 02e0c76edce4fa33fc4fec3738a03f33c435fd12 Mon Sep 17 00:00:00 2001 From: Tarek Mahmoud Sayed Date: Fri, 19 Jul 2024 15:49:38 -0700 Subject: [PATCH] Fix OSX build failures --- .../src/Resources/Strings.resx | 60 ++++++++++--------- .../src/System/Environment.Browser.cs | 1 + .../src/System/Environment.OSX.cs | 3 + .../src/System/Environment.iOS.cs | 2 +- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index ad6476701c3390..a77b8afe3b9c56 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -1,17 +1,17 @@  - @@ -4334,4 +4334,10 @@ Only array or span of primitive or enum types can be initialized from static data. + + Could not get all running Process IDs. + + + Failed to set or retrieve rusage information. See the error code for OS-specific error information. + \ No newline at end of file diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.Browser.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.Browser.cs index 75a2633e67e34e..4815ef73615b0f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Browser.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Browser.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.IO; +using System.Runtime.Versioning; namespace System { diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.OSX.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.OSX.cs index 82b6345ff40e1e..c13a975b198d8d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.OSX.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.OSX.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -26,6 +27,8 @@ public static ProcessCpuUsage CpuUsage } } + private const int NanosecondsTo100NanosecondsFactor = 100; + private static volatile uint s_timeBase_numer, s_timeBase_denom; private static TimeSpan MapTime(ulong sysTime) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs index 58a85227101bc3..b6bd6a16bdb7df 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs @@ -25,7 +25,7 @@ public static partial class Environment [UnsupportedOSPlatform("tvos")] public static ProcessCpuUsage CpuUsage { - get { throw new PlatformNotSupportedException(); } + get => new ProcessCpuUsage { UserTime = TimeSpan.Zero, PrivilegedTime = TimeSpan.Zero }; } #endif