From 83b52cdc310ebd77cddff7efd772a0800a403f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 18 Jan 2022 23:13:58 +0100 Subject: [PATCH] [iOS/tvOS] Remove P/Invokes to libproc from System.Private.CoreLib (#63934) They aren't allowed by Apple when submitting to the App Store. Finishes https://github.com/dotnet/runtime/issues/61265 --- .../src/System.Private.CoreLib.Shared.projitems | 5 +++-- .../src/System/Environment.iOS.cs | 13 +++++++++++++ .../tests/System/EnvironmentTests.cs | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 0a587f37087..59796633cc4 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -2188,12 +2188,13 @@ - + - + + diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs new file mode 100644 index 00000000000..90512ca598b --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.iOS.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; + +namespace System +{ + public static partial class Environment + { + // iOS/tvOS aren't allowed to call libproc APIs so return 0 here, this also matches what we returned in earlier releases + public static long WorkingSet => 0; + } +} diff --git a/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs b/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs index 415cafb9f02..5d2bf278549 100644 --- a/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs +++ b/src/libraries/System.Runtime.Extensions/tests/System/EnvironmentTests.cs @@ -236,7 +236,7 @@ namespace System.Tests [Fact] public void WorkingSet_Valid() { - if (PlatformDetection.IsBrowser) + if (PlatformDetection.IsBrowser || PlatformDetection.IsiOS || PlatformDetection.IstvOS) Assert.Equal(0, Environment.WorkingSet); else Assert.True(Environment.WorkingSet > 0, "Expected positive WorkingSet value");