diff --git a/eng/pipelines/runtime-staging.yml b/eng/pipelines/runtime-staging.yml index f3d39704bef680..2a1591a398201b 100644 --- a/eng/pipelines/runtime-staging.yml +++ b/eng/pipelines/runtime-staging.yml @@ -99,6 +99,51 @@ jobs: eq(variables['monoContainsChange'], true), eq(variables['isFullMatrix'], true)) +# +# MacCatalyst interp - requires AOT Compilation and Interp flags +# Build the whole product using Mono and run libraries tests +# The test app is built with the App Sandbox entitlement +# +- template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml + buildConfig: Release + runtimeFlavor: mono + platforms: + - MacCatalyst_x64 + # don't run tests on arm64 PRs until we can get significantly more devices + - ${{ if eq(variables['isFullMatrix'], true) }}: + - MacCatalyst_arm64 + variables: + # map dependencies variables to local variables + - name: librariesContainsChange + value: $[ dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ] + - name: monoContainsChange + value: $[ dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'] ] + jobParameters: + testGroup: innerloop + nameSuffix: AllSubsets_Mono_AppSandbox + buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=adhoc /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildDarwinFrameworks=true /p:EnableAppSandbox=true + timeoutInMinutes: 180 + condition: >- + or( + eq(dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'], true), + eq(dependencies.evaluate_paths.outputs['SetPathVars_installer.containsChange'], true), + eq(variables['isFullMatrix'], true)) + # extra steps, run tests + extraStepsTemplate: /eng/pipelines/libraries/helix.yml + extraStepsParameters: + creator: dotnet-bot + interpreter: true + testRunNamePrefixSuffix: Mono_$(_BuildConfig) + condition: >- + or( + eq(variables['librariesContainsChange'], true), + eq(variables['monoContainsChange'], true), + eq(variables['isFullMatrix'], true)) + # # MacCatalyst interp - requires AOT Compilation and Interp flags # Build the whole product using Mono and run libraries tests diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index db5e7c63644d25..f48c16f511fe5d 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -219,6 +219,7 @@ MainLibraryFileName="$(MainLibraryFileName)" ForceAOT="$(RunAOTCompilation)" ForceInterpreter="$(MonoForceInterpreter)" + EnableAppSandbox="$(EnableAppSandbox)" InvariantGlobalization="$(InvariantGlobalization)" UseConsoleUITemplate="True" GenerateXcodeProject="$(GenerateXcodeProject)" diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs index fd4b968c132ea8..af75653dd2f3c4 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs @@ -25,6 +25,9 @@ internal static partial class libproc // Constants from sys\resource.h private const int RUSAGE_INFO_V3 = 3; + // Constants from sys/errno.h + private const int EPERM = 1; + // Defines from proc_info.h internal enum ThreadRunState { @@ -120,7 +123,14 @@ internal static unsafe int[] proc_listallpids() { // Get the number of processes currently running to know how much data to allocate int numProcesses = proc_listallpids(null, 0); - if (numProcesses <= 0) + if (numProcesses == 0 && Marshal.GetLastPInvokeError() == EPERM) + { + // An app running in App Sandbox does not have permissions to list other running processes + // and so the `proc_listallpids` function returns 0 and sets errno to 1. As a fallback + // we return at least an array with the PID of the current process which we always know. + return new[] { Environment.ProcessId }; + } + else if (numProcesses <= 0) { throw new Win32Exception(SR.CantGetAllPids); } diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs index 99492706f7ec99..ecd41c64698324 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs @@ -41,6 +41,8 @@ public static partial class PlatformDetection public static bool IsMacOsCatalinaOrHigher => IsOSX && Environment.OSVersion.Version >= new Version(10, 15); public static bool IsMacOsAppleSilicon => IsOSX && IsArm64Process; public static bool IsNotMacOsAppleSilicon => !IsMacOsAppleSilicon; + public static bool IsAppSandbox => Environment.GetEnvironmentVariable("APP_SANDBOX_CONTAINER_ID") != null; + public static bool IsNotAppSandbox => !IsAppSandbox; // RedHat family covers RedHat and CentOS public static bool IsRedHatFamily => IsRedHatFamilyAndVersion(); diff --git a/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs b/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs index 53a49f897c1a2e..7e1f6d5d77adec 100644 --- a/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs +++ b/src/libraries/System.Diagnostics.Process/ref/System.Diagnostics.Process.cs @@ -43,8 +43,8 @@ public Process() { } public System.Diagnostics.ProcessModule? MainModule { get { throw null; } } public System.IntPtr MainWindowHandle { get { throw null; } } public string MainWindowTitle { get { throw null; } } - public System.IntPtr MaxWorkingSet { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("freebsd"), System.Runtime.Versioning.SupportedOSPlatformAttribute("macos"), System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } - public System.IntPtr MinWorkingSet { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("freebsd"), System.Runtime.Versioning.SupportedOSPlatformAttribute("macos"), System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public System.IntPtr MaxWorkingSet { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos"), System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("freebsd"), System.Runtime.Versioning.SupportedOSPlatformAttribute("macos"), System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst"), System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } + public System.IntPtr MinWorkingSet { [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios"), System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos"), System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("freebsd"), System.Runtime.Versioning.SupportedOSPlatformAttribute("macos"), System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst"), System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } public System.Diagnostics.ProcessModuleCollection Modules { get { throw null; } } [System.ObsoleteAttribute("Process.NonpagedSystemMemorySize has been deprecated because the type of the property can't represent all valid results. Use System.Diagnostics.Process.NonpagedSystemMemorySize64 instead.")] public int NonpagedSystemMemorySize { get { throw null; } } @@ -86,9 +86,11 @@ public Process() { } public System.Diagnostics.ProcessThreadCollection Threads { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public System.TimeSpan TotalProcessorTime { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public System.TimeSpan UserProcessorTime { get { throw null; } } [System.ObsoleteAttribute("Process.VirtualMemorySize has been deprecated because the type of the property can't represent all valid results. Use System.Diagnostics.Process.VirtualMemorySize64 instead.")] public int VirtualMemorySize { get { throw null; } } @@ -112,39 +114,50 @@ public static void EnterDebugMode() { } public static System.Diagnostics.Process GetProcessById(int processId, string machineName) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process[] GetProcesses() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process[] GetProcesses(string machineName) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process[] GetProcessesByName(string? processName) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process[] GetProcessesByName(string? processName, string machineName) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public void Kill() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public void Kill(bool entireProcessTree) { } public static void LeaveDebugMode() { } protected void OnExited() { } public void Refresh() { } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public bool Start() { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process? Start(System.Diagnostics.ProcessStartInfo startInfo) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process Start(string fileName) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process Start(string fileName, string arguments) { throw null; } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public static System.Diagnostics.Process Start(string fileName, System.Collections.Generic.IEnumerable arguments) { throw null; } [System.CLSCompliantAttribute(false)] [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] @@ -247,6 +260,7 @@ public int IdealProcessor { set { } } public System.Diagnostics.ThreadPriorityLevel PriorityLevel { [System.Runtime.Versioning.SupportedOSPlatform("windows")] [System.Runtime.Versioning.SupportedOSPlatform("linux")] [System.Runtime.Versioning.SupportedOSPlatform("freebsd")] get { throw null; } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] set { } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public System.TimeSpan PrivilegedProcessorTime { get { throw null; } } [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")] public System.IntPtr ProcessorAffinity { set { } } @@ -257,9 +271,11 @@ public System.IntPtr ProcessorAffinity { set { } } public System.Diagnostics.ThreadState ThreadState { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public System.TimeSpan TotalProcessorTime { get { throw null; } } [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("ios")] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("tvos")] + [System.Runtime.Versioning.SupportedOSPlatformAttribute("maccatalyst")] public System.TimeSpan UserProcessorTime { get { throw null; } } public System.Diagnostics.ThreadWaitReason WaitReason { get { throw null; } } public void ResetIdealProcessor() { } diff --git a/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj b/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj index 6bdd9f8d69db27..64de4a154066de 100644 --- a/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj +++ b/src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj @@ -2,7 +2,7 @@ $(DefineConstants);FEATURE_REGISTRY true - $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent);$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent);$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS enable $(NoWarn);0649 @@ -309,7 +309,7 @@ - + diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs index 3380481ca5c8e3..70c408cea290bb 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs @@ -15,6 +15,7 @@ public partial class Process /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcessesByName(string? processName, string machineName) { if (processName == null) diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs index 016327ad61ab57..e4b149b84a6d23 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs @@ -20,6 +20,7 @@ public partial class Process : IDisposable /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcessesByName(string? processName, string machineName) { ProcessManager.ThrowIfRemoteMachine(machineName); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs index 0dff87802214e9..2bad9c22c9b6d9 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.NonUap.cs @@ -11,6 +11,7 @@ public partial class Process : IDisposable { [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public void Kill(bool entireProcessTree) { if (!entireProcessTree) diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs index 69b4481ae2087b..0cbb98891ab235 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs @@ -58,9 +58,10 @@ public static Process Start(string fileName, string arguments, string userName, /// Terminates the associated process immediately. [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public void Kill() { - if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()) + if (PlatformDoesNotSupportProcessStartAndKill) { throw new PlatformNotSupportedException(); } @@ -372,7 +373,7 @@ private SafeProcessHandle GetProcessHandle() /// The start info with which to start the process. private bool StartCore(ProcessStartInfo startInfo) { - if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()) + if (PlatformDoesNotSupportProcessStartAndKill) { throw new PlatformNotSupportedException(); } @@ -1105,5 +1106,8 @@ private static int OnSigChild(int reapAll, int configureConsole) s_processStartLock.ExitWriteLock(); } } + + private static bool PlatformDoesNotSupportProcessStartAndKill + => (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS(); } } diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs index 897fde77e9a75d..f56acfbbb5e0fa 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.UnknownUnix.cs @@ -9,6 +9,9 @@ public partial class Process : IDisposable /// Creates an array of components that are associated with process resources on a /// remote computer. These process resources share the specified process name. /// + [UnsupportedOSPlatform("ios")] + [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcessesByName(string? processName, string machineName) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs index ad7209a3f198d2..8935edc549ba98 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs @@ -23,6 +23,7 @@ public partial class Process : IDisposable /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcessesByName(string? processName, string machineName) { if (processName == null) @@ -93,6 +94,7 @@ public static void LeaveDebugMode() /// Terminates the associated process immediately. [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public void Kill() { using (SafeProcessHandle handle = GetProcessHandle(Interop.Advapi32.ProcessOptions.PROCESS_TERMINATE | Interop.Advapi32.ProcessOptions.PROCESS_QUERY_LIMITED_INFORMATION, throwIfExited: false)) diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs index fe99dd2786bbab..a1796844b59810 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs @@ -195,6 +195,7 @@ public bool HasExited /// Gets the time the associated process was started. [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public DateTime StartTime { get @@ -264,14 +265,16 @@ public IntPtr MaxWorkingSet { [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] get { EnsureWorkingSetLimits(); return _maxWorkingSet; } - [SupportedOSPlatform("windows")] - [SupportedOSPlatform("macos")] [SupportedOSPlatform("freebsd")] + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("maccatalyst")] + [SupportedOSPlatform("windows")] set { SetWorkingSetLimits(null, value); @@ -286,14 +289,16 @@ public IntPtr MinWorkingSet { [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] get { EnsureWorkingSetLimits(); return _minWorkingSet; } - [SupportedOSPlatform("windows")] - [SupportedOSPlatform("macos")] [SupportedOSPlatform("freebsd")] + [SupportedOSPlatform("macos")] + [SupportedOSPlatform("maccatalyst")] + [SupportedOSPlatform("windows")] set { SetWorkingSetLimits(value, null); @@ -1043,6 +1048,7 @@ public static Process GetProcessById(int processId) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcessesByName(string? processName) { return GetProcessesByName(processName, "."); @@ -1056,6 +1062,7 @@ public static Process[] GetProcessesByName(string? processName) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcesses() { return GetProcesses("."); @@ -1070,6 +1077,7 @@ public static Process[] GetProcesses() /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcesses(string machineName) { bool isRemoteMachine = ProcessManager.IsRemoteMachine(machineName); @@ -1213,6 +1221,7 @@ private void SetProcessId(int processId) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public bool Start() { Close(); @@ -1256,6 +1265,7 @@ public bool Start() /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process Start(string fileName) { // the underlying Start method can only return null on Windows platforms, @@ -1274,6 +1284,7 @@ public static Process Start(string fileName) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process Start(string fileName, string arguments) { // the underlying Start method can only return null on Windows platforms, @@ -1287,6 +1298,7 @@ public static Process Start(string fileName, string arguments) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process Start(string fileName, IEnumerable arguments) { if (fileName == null) @@ -1313,6 +1325,7 @@ public static Process Start(string fileName, IEnumerable arguments) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process? Start(ProcessStartInfo startInfo) { Process process = new Process(); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs index e3fa89f34ccd1c..abbb712d4006ac 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.iOS.cs @@ -11,6 +11,7 @@ public partial class Process : IDisposable { [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public void Kill(bool entireProcessTree) { throw new PlatformNotSupportedException(); @@ -22,6 +23,7 @@ public void Kill(bool entireProcessTree) /// [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static Process[] GetProcessesByName(string? processName, string machineName) { throw new PlatformNotSupportedException(); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs index d9e27a8c542769..1ef579803c622f 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Unix.cs @@ -47,6 +47,7 @@ public static bool IsProcessRunning(int processId) /// An array of process IDs from the specified machine. [UnsupportedOSPlatform("ios")] [UnsupportedOSPlatform("tvos")] + [SupportedOSPlatform("maccatalyst")] public static int[] GetProcessIds(string machineName) { ThrowIfRemoteMachine(machineName); diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs index 63d7f3d6d02b3c..e27e143f75b642 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.Unix.cs @@ -78,6 +78,7 @@ public void ProcessStart_UseShellExecute_OnLinux_ThrowsIfNoProgramInstalled() [Fact] [OuterLoop("Opens program")] + [SkipOnPlatform(TestPlatforms.MacCatalyst, "In App Sandbox mode, the process doesn't have read access to the binary.")] public void ProcessStart_DirectoryNameInCurDirectorySameAsFileNameInExecDirectory_Success() { string fileToOpen = "dotnet"; @@ -157,8 +158,8 @@ public void ProcessStart_UseShellExecute_OnUnix_SuccessWhenProgramInstalled(bool } [Fact] - [SkipOnPlatform(TestPlatforms.OSX, "On OSX, ProcessName returns the script interpreter.")] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] + [SkipOnPlatform(TestPlatforms.OSX | TestPlatforms.MacCatalyst, "On OSX, ProcessName returns the script interpreter.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS or tvOS.")] public void ProcessNameMatchesScriptName() { string scriptName = GetTestFileName(); @@ -379,7 +380,7 @@ public void ProcessStart_OnLinux_UsesSpecifiedProgramUsingArgumentList() } [Theory, InlineData("/usr/bin/open"), InlineData("/usr/bin/nano")] - [PlatformSpecific(TestPlatforms.OSX)] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.MacCatalyst)] [OuterLoop("Opens program")] public void ProcessStart_OpenFileOnOsx_UsesSpecifiedProgram(string programToOpenWith) { @@ -396,7 +397,7 @@ public void ProcessStart_OpenFileOnOsx_UsesSpecifiedProgram(string programToOpen } [Theory, InlineData("Safari"), InlineData("\"Google Chrome\"")] - [PlatformSpecific(TestPlatforms.OSX)] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.MacCatalyst)] [OuterLoop("Opens browser")] public void ProcessStart_OpenUrl_UsesSpecifiedApplication(string applicationToOpenWith) { @@ -410,7 +411,7 @@ public void ProcessStart_OpenUrl_UsesSpecifiedApplication(string applicationToOp } [Theory, InlineData("-a Safari"), InlineData("-a \"Google Chrome\"")] - [PlatformSpecific(TestPlatforms.OSX)] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.MacCatalyst)] [OuterLoop("Opens browser")] public void ProcessStart_UseShellExecuteTrue_OpenUrl_SuccessfullyReadsArgument(string arguments) { @@ -432,7 +433,7 @@ public void ProcessStart_UseShellExecuteTrue_OpenUrl_SuccessfullyReadsArgument(s [Theory, MemberData(nameof(StartOSXProcessWithArgumentList))] - [PlatformSpecific(TestPlatforms.OSX)] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.MacCatalyst)] [OuterLoop("Opens browser")] public void ProcessStart_UseShellExecuteTrue_OpenUrl_SuccessfullyReadsArgumentArray(string[] argumentList) { @@ -502,7 +503,7 @@ public void TestBasePriorityOnUnix() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS or tvOS.")] public void TestStartOnUnixWithBadPermissions() { string path = GetTestFilePath(); @@ -514,7 +515,7 @@ public void TestStartOnUnixWithBadPermissions() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS or tvOS.")] public void TestStartOnUnixWithBadFormat() { string path = GetTestFilePath(); diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs index 19a88989696208..cb4eddc07ce1dd 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs @@ -171,28 +171,28 @@ public void TestExited_SynchronizingObject(bool invokeRequired) } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_TryExitCommandAsFileName_ThrowsWin32Exception() { Assert.Throws(() => Process.Start(new ProcessStartInfo { UseShellExecute = false, FileName = "exit", Arguments = "42" })); } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_UseShellExecuteFalse_FilenameIsUrl_ThrowsWin32Exception() { Assert.Throws(() => Process.Start(new ProcessStartInfo { UseShellExecute = false, FileName = "https://www.github.com/corefx" })); } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_TryOpenFolder_UseShellExecuteIsFalse_ThrowsWin32Exception() { Assert.Throws(() => Process.Start(new ProcessStartInfo { UseShellExecute = false, FileName = Path.GetTempPath() })); } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void TestStartWithBadWorkingDirectory() { string program; @@ -230,7 +230,7 @@ public void TestStartWithBadWorkingDirectory() [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasWindowsShell))] [OuterLoop("Launches File Explorer")] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_UseShellExecute_OnWindows_OpenMissingFile_Throws() { string fileToOpen = Path.Combine(Environment.CurrentDirectory, "_no_such_file.TXT"); @@ -243,7 +243,7 @@ public void ProcessStart_UseShellExecute_OnWindows_OpenMissingFile_Throws() [InlineData(true)] [InlineData(false)] [OuterLoop("Launches File Explorer")] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_UseShellExecute_OnWindows_DoesNotThrow(bool isFolder) { string fileToOpen; @@ -278,10 +278,11 @@ public void ProcessStart_UseShellExecute_OnWindows_DoesNotThrow(bool isFolder) } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsServerCore), - nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotWindowsIoTCore))] + nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotWindowsIoTCore), + nameof(PlatformDetection.IsNotAppSandbox))] [ActiveIssue("https://github.com/dotnet/runtime/issues/34685", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] [InlineData(true), InlineData(false)] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_UseShellExecute_Executes(bool filenameAsUrl) { string filename = WriteScriptFile(TestDirectory, GetTestFileName(), returnValue: 42); @@ -304,7 +305,9 @@ public void ProcessStart_UseShellExecute_Executes(bool filenameAsUrl) PlatformDetection.IsNotWindowsIoTCore && RemoteExecutor.IsSupported; - [ConditionalFact(nameof(UseShellExecuteExecuteOrderIsRunnablePlatform))] + private static bool IsNotAppSandbox => PlatformDetection.IsNotAppSandbox; + + [ConditionalFact(nameof(UseShellExecuteExecuteOrderIsRunnablePlatform), nameof(IsNotAppSandbox))] [ActiveIssue("https://github.com/dotnet/runtime/issues/34685", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] public void ProcessStart_UseShellExecute_ExecuteOrder() { @@ -348,9 +351,10 @@ public void ProcessStart_UseShellExecute_ExecuteOrder() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsServerCore), - nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotWindowsIoTCore))] + nameof(PlatformDetection.IsNotWindowsNanoServer), nameof(PlatformDetection.IsNotWindowsIoTCore), + nameof(PlatformDetection.IsNotAppSandbox))] [ActiveIssue("https://github.com/dotnet/runtime/issues/34685", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void ProcessStart_UseShellExecute_WorkingDirectory() { // Create a directory that will ProcessStartInfo.WorkingDirectory @@ -502,7 +506,7 @@ public void HasExited_GetNotStarted_ThrowsInvalidOperationException() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Not supported on iOS, tvOS, or MacCatalyst.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void Kill_NotStarted_ThrowsInvalidOperationException() { var process = new Process(); @@ -1419,7 +1423,7 @@ public void CanBeFinalized() [Theory] [InlineData(false)] [InlineData(true)] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "Not supported on iOS, MacCatalyst, or tvOS.")] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "Not supported on iOS and tvOS.")] public void TestStartWithMissingFile(bool fullPath) { string path = Guid.NewGuid().ToString("N"); diff --git a/src/libraries/shims/ApiCompatBaseline.PreviousNetCoreApp.txt b/src/libraries/shims/ApiCompatBaseline.PreviousNetCoreApp.txt index 69f17447741d89..740cf4995ce1bb 100644 --- a/src/libraries/shims/ApiCompatBaseline.PreviousNetCoreApp.txt +++ b/src/libraries/shims/ApiCompatBaseline.PreviousNetCoreApp.txt @@ -68,8 +68,8 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerAttribute' on ' CannotRemoveAttribute : Attribute 'System.ComponentModel.DesignerAttribute' exists on 'System.ComponentModel.MarshalByValueComponent' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.ComponentModel.TypeDescriptionProvider.CreateInstance(System.IServiceProvider, System.Type, System.Type[], System.Object[])' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.ComponentModel.TypeDescriptor.CreateInstance(System.IServiceProvider, System.Type, System.Type[], System.Object[])' in the contract but not the implementation. -CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("windows")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. -CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("windows")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. +CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. +CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.AllowNullAttribute' exists on parameter 'value' on member 'System.Net.Cookie.Name.set(System.String)' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Net.HttpListener.ExtendedProtectionPolicy.set(System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy)' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Net.HttpListenerResponse.Abort()' in the contract but not the implementation. @@ -97,8 +97,8 @@ CannotChangeAttribute : Attribute 'System.ComponentModel.DesignerAttribute' on ' CannotRemoveAttribute : Attribute 'System.ComponentModel.DesignerAttribute' exists on 'System.ComponentModel.MarshalByValueComponent' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.ComponentModel.TypeDescriptionProvider.CreateInstance(System.IServiceProvider, System.Type, System.Type[], System.Object[])' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.ComponentModel.TypeDescriptor.CreateInstance(System.IServiceProvider, System.Type, System.Type[], System.Object[])' in the contract but not the implementation. -CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("windows")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. -CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("windows")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. +CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. +CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.AllowNullAttribute' exists on parameter 'value' on member 'System.Net.Cookie.Name.set(System.String)' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Net.HttpListener.ExtendedProtectionPolicy.set(System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy)' in the contract but not the implementation. CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Net.HttpListenerResponse.Abort()' in the contract but not the implementation. @@ -130,8 +130,8 @@ CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatfo CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Console.WindowHeight.get()' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("android")]' in the implementation. CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Console.WindowWidth.get()' changed from '[UnsupportedOSPlatformAttribute("browser")]' in the contract to '[UnsupportedOSPlatformAttribute("android")]' in the implementation. Compat issues with assembly System.Diagnostics.Process: -CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("windows")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. -CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("windows")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. +CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. +CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation. Compat issues with assembly System.Net: CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.AllowNullAttribute' exists on parameter 'value' on member 'System.Net.Cookie.Name.set(System.String)' in the contract but not the implementation. Compat issues with assembly System.Net.HttpListener: diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 6bf5073dbfdee3..160cc413535d93 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -156,6 +156,15 @@ + + + + + + + + + diff --git a/src/mono/sample/iOS/Makefile b/src/mono/sample/iOS/Makefile index 8148d6eeb6cd75..bdfc6c8f854b2b 100644 --- a/src/mono/sample/iOS/Makefile +++ b/src/mono/sample/iOS/Makefile @@ -5,6 +5,7 @@ USE_LLVM=true AOT?=false TARGET?=iOSSimulator DEPLOY_AND_RUN?=true +APP_SANDBOX?=false #If DIAGNOSTIC_PORTS is enabled, RUNTIME_COMPONENTS must also be enabled. #If RUNTIME_COMPONENTS is enabled, DIAGNOSTIC_PORTS is optional. @@ -58,7 +59,8 @@ run-catalyst: /p:TargetArchitecture=$(MONO_ARCH) \ '/p:DeployAndRun="$(DEPLOY_AND_RUN)"' \ /p:UseLLVM=False \ - /p:ForceAOT=True + /p:ForceAOT=True \ + /p:EnableAppSandbox=$(APP_SANDBOX) run-sim-interp: clean appbuilder $(DOTNET) publish \ @@ -80,6 +82,7 @@ run-catalyst-interp: /p:UseLLVM=False \ '/p:DeployAndRun="$(DEPLOY_AND_RUN)"' \ /p:ForceAOT=True \ + /p:EnableAppSandbox=$(APP_SANDBOX) \ /p:MonoForceInterpreter=true clean: diff --git a/src/mono/sample/iOS/Program.csproj b/src/mono/sample/iOS/Program.csproj index 64ffef7e16d545..65f252e7e55221 100644 --- a/src/mono/sample/iOS/Program.csproj +++ b/src/mono/sample/iOS/Program.csproj @@ -18,6 +18,7 @@ adhoc + false @@ -81,6 +82,7 @@ ForceAOT="$(RunAOTCompilation)" ForceInterpreter="$(MonoForceInterpreter)" RuntimeComponents="$(RuntimeComponents)" + EnableAppSandbox="$(EnableAppSandbox)" DiagnosticPorts="$(DiagnosticPorts)" AppDir="$(MSBuildThisFileDirectory)$(PublishDir)"> diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index e1f735efdffa43..bd0a775ce55109 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -158,6 +158,11 @@ public string TargetOS /// public bool EnableRuntimeLogging { get; set; } + /// + /// Enables App Sandbox for Mac Catalyst apps + /// + public bool EnableAppSandbox { get; set; } + public override bool Execute() { bool isDevice = (TargetOS == TargetNames.iOS || TargetOS == TargetNames.tvOS); @@ -229,12 +234,17 @@ public override bool Execute() throw new ArgumentException("Using DiagnosticPorts require diagnostics_tracing runtime component."); } + if (EnableAppSandbox && (string.IsNullOrEmpty(DevTeamProvisioning) || DevTeamProvisioning == "-")) + { + throw new ArgumentException("DevTeamProvisioning must be set to a valid value when App Sandbox is enabled, using '-' is not supported."); + } + var generator = new Xcode(Log, TargetOS, Arch); if (GenerateXcodeProject) { XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, assemblerFilesToLink, - AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, EnableRuntimeLogging, DiagnosticPorts, RuntimeComponents, NativeMainSource); + AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource); if (BuildAppBundle) { @@ -252,7 +262,7 @@ public override bool Execute() else if (GenerateCMakeProject) { generator.GenerateCMake(ProjectName, MainLibraryFileName, assemblerFiles, assemblerFilesToLink, - AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, EnableRuntimeLogging, DiagnosticPorts, RuntimeComponents, NativeMainSource); + AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource); } return true; diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 05a643c3047270..36f9d3ab732acc 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -145,11 +145,12 @@ public string GenerateXCode( bool invariantGlobalization, bool optimized, bool enableRuntimeLogging, + bool enableAppSandbox, string? diagnosticPorts, string? runtimeComponents=null, string? nativeMainSource = null) { - var cmakeDirectoryPath = GenerateCMake(projectName, entryPointLib, asmFiles, asmLinkFiles, workspace, binDir, monoInclude, preferDylibs, useConsoleUiTemplate, forceAOT, forceInterpreter, invariantGlobalization, optimized, enableRuntimeLogging, diagnosticPorts, runtimeComponents, nativeMainSource); + var cmakeDirectoryPath = GenerateCMake(projectName, entryPointLib, asmFiles, asmLinkFiles, workspace, binDir, monoInclude, preferDylibs, useConsoleUiTemplate, forceAOT, forceInterpreter, invariantGlobalization, optimized, enableRuntimeLogging, enableAppSandbox, diagnosticPorts, runtimeComponents, nativeMainSource); CreateXcodeProject(projectName, cmakeDirectoryPath); return Path.Combine(binDir, projectName, projectName + ".xcodeproj"); } @@ -201,6 +202,7 @@ public string GenerateCMake( bool invariantGlobalization, bool optimized, bool enableRuntimeLogging, + bool enableAppSandbox, string? diagnosticPorts, string? runtimeComponents=null, string? nativeMainSource = null) @@ -236,7 +238,8 @@ public string GenerateCMake( var entitlements = new List>(); bool hardenedRuntime = false; - if (Target == TargetNames.MacCatalyst && !forceAOT) { + if (Target == TargetNames.MacCatalyst && !forceAOT) + { hardenedRuntime = true; /* for mmmap MAP_JIT */ @@ -245,6 +248,15 @@ public string GenerateCMake( entitlements.Add (KeyValuePair.Create ("com.apple.security.cs.disable-library-validation", "")); } + if (enableAppSandbox) + { + hardenedRuntime = true; + entitlements.Add (KeyValuePair.Create ("com.apple.security.app-sandbox", "")); + + // the networking entitlement is necessary to enable communication between the test app and xharness + entitlements.Add (KeyValuePair.Create ("com.apple.security.network.client", "")); + } + string cmakeLists = Utils.GetEmbeddedResource("CMakeLists.txt.template") .Replace("%ProjectName%", projectName) .Replace("%AppResources%", string.Join(Environment.NewLine, resources.Where(r => !r.EndsWith("-llvm.o")).Select(r => " " + Path.GetRelativePath(binDir, r)))) diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index 6841b4938e70b2..93868bfab8586b 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -115,7 +115,7 @@ - true + true C# F# IL diff --git a/src/tests/run.proj b/src/tests/run.proj index b7fe57ead80de5..1636171ec28487 100644 --- a/src/tests/run.proj +++ b/src/tests/run.proj @@ -775,6 +775,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackNativeDir)/include/mono-2.0" Assemblies="@(BundleAssemblies)" ForceInterpreter="$(MonoForceInterpreter)" + EnableAppSandbox="$(EnableAppSandbox)" UseConsoleUITemplate="True" GenerateXcodeProject="True" BuildAppBundle="True"