Skip to content

Support Process.Start() on MacCatalyst #61507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d1fe014
Modify existing tests
simonrozsival Nov 12, 2021
17c6eec
Enable process start and kill on MacCatalyst
simonrozsival Nov 12, 2021
2d76ff3
Typo
simonrozsival Nov 12, 2021
0d55868
Temporarily enable ProcessTests for MacCatalyst
simonrozsival Nov 15, 2021
b0a1f9a
Temporarily enable ProcessTests for MacCatalyst - attempt 2
simonrozsival Nov 15, 2021
09a520a
Allow running Mac Catalyst builds in App Sandbox
simonrozsival Nov 15, 2021
83fa170
Allow enabling app sandbox for the other Mac Catalyst sample
simonrozsival Nov 15, 2021
9409c8d
Add missing parameter to XCode project generator
simonrozsival Nov 15, 2021
6b25194
Remove unnecessary MacCatalyst detection
simonrozsival Nov 18, 2021
f065754
Enable App Sandbox for Mac Catalyst tests
simonrozsival Nov 18, 2021
aa5bf93
Create a separate test branch for App Sandbox
simonrozsival Nov 22, 2021
320cbe7
Remove the restriction to enable app sandbox just for Mac Catalyst apps
simonrozsival Nov 22, 2021
15108a7
Do not throw PNSE for Mac Catalyst
simonrozsival Nov 22, 2021
2525e79
Clean-up platform-specific conditions
simonrozsival Nov 22, 2021
1a57e88
Build correct Process implementation for MacCatalyst
simonrozsival Nov 23, 2021
da46eca
Merge branch 'main' into simonrozsival/61295-support-process-start-on…
simonrozsival Nov 23, 2021
fc63a37
Try to get more information from CI for further investigation of the …
simonrozsival Nov 24, 2021
f9e4b67
Revert "Try to get more information from CI for further investigation…
simonrozsival Nov 24, 2021
9e4443b
Add MacCatalyst target framework for System.Diagnostics.Process
simonrozsival Nov 24, 2021
20840a5
Merge branch 'main' of https://github.com/dotnet/runtime into simonro…
simonrozsival Nov 24, 2021
5be64c6
Add supported platform annotations for Mac Catalyst
simonrozsival Nov 24, 2021
c620358
Fix annotations
simonrozsival Nov 24, 2021
f027660
Remove incorrectly placed attributes
simonrozsival Nov 24, 2021
ed8e9d8
Update attributes including the reference file
simonrozsival Nov 24, 2021
7119d72
Change platform attributes
simonrozsival Nov 25, 2021
abbe224
Generate app.entitlements in the BuildAppleAppBundles test build target
simonrozsival Nov 25, 2021
ace7d76
Revert "Generate app.entitlements in the BuildAppleAppBundles test bu…
simonrozsival Nov 26, 2021
b805ba2
Enable AppSandbox when generating CMakeLists.txt for libraries tests
simonrozsival Nov 26, 2021
8130507
Try implementing a workaround for app sandbox mode
simonrozsival Nov 29, 2021
9b55d57
Fix app sandbox detection bug
simonrozsival Nov 29, 2021
7a3dc2b
Add explanation comment
simonrozsival Nov 30, 2021
02d4991
Enable more tests for MacCatalyst
simonrozsival Nov 30, 2021
6e18a52
Merge branch 'main' of https://github.com/dotnet/runtime into simonro…
simonrozsival Nov 30, 2021
3273fac
Add apple app builder input validation
simonrozsival Nov 30, 2021
d37da5c
Add Mac Catalyst w/ App Sandbox enabled to runtime-manual test pipeline
simonrozsival Nov 30, 2021
1dad157
Enable networking in App Sandbox mode
simonrozsival Nov 30, 2021
5c82f7c
Skip test which won't work on Mac Catalyst
simonrozsival Nov 30, 2021
6b52a30
Skip some tests in app sandbox mode
simonrozsival Nov 30, 2021
77dcb93
Update src/tasks/AppleAppBuilder/AppleAppBuilder.cs
simonrozsival Dec 1, 2021
38bce10
Add a clarification comment for a networking entitlement
simonrozsival Dec 1, 2021
93944c0
Simplify supported platform condition
simonrozsival Dec 1, 2021
80d2984
Merge branch 'simonrozsival/61295-support-process-start-on-mac-cataly…
simonrozsival Dec 1, 2021
02d370c
Remove temporarily enabled test
simonrozsival Dec 1, 2021
4c8d12b
Remove unnecessary attributes
simonrozsival Dec 1, 2021
f2b752b
Replace checking env variable with checking errno in libproc
simonrozsival Dec 1, 2021
ee6dcec
Update docs
simonrozsival Dec 2, 2021
0db6178
Remove unnecessary changes
simonrozsival Dec 2, 2021
dc72f0f
Temporarily enable running System.Diagnostics.Process.Tests for this PR
simonrozsival Dec 3, 2021
efc863c
Revert "Temporarily enable running System.Diagnostics.Process.Tests f…
simonrozsival Dec 3, 2021
dcf8e92
Fix job suffix in runtime-manual
simonrozsival Dec 6, 2021
704e9fa
Remove attributes
simonrozsival Dec 6, 2021
52bfaae
Revert "Remove attributes"
simonrozsival Dec 6, 2021
b3cc2ac
Try changing the order of attributes to please CI
simonrozsival Dec 6, 2021
a2ad032
Update ApiCompat baseline
simonrozsival Dec 6, 2021
be72a3d
ApiCompat step 1: remove all attributes for MaxWorkingSet setter
simonrozsival Dec 7, 2021
9d5e5a9
Revert "Update ApiCompat baseline"
simonrozsival Dec 7, 2021
32f2c6b
Revert "ApiCompat step 1: remove all attributes for MaxWorkingSet set…
simonrozsival Dec 7, 2021
85fa8cf
Update ApiCompat baseline
simonrozsival Dec 7, 2021
e3bf3dc
Merge branch 'main' of github.com:simonrozsival/runtime into simonroz…
simonrozsival Dec 7, 2021
8ac8661
Update ApiCompat baseline after pulling upstream main
simonrozsival Dec 7, 2021
df0ce4e
Merge branch 'main' into simonrozsival/61295-support-process-start-on…
simonrozsival Dec 7, 2021
8206e28
Remove trailing whitespace
simonrozsival Dec 7, 2021
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
4 changes: 4 additions & 0 deletions docs/workflow/testing/libraries/testing-apple.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ To build for AOT only mode, add `/p:RunAOTCompilation=true /p:MonoEnableInterpre

To build for AOT-LLVM mode, add `/p:RunAOTCompilation=true /p:MonoEnableInterpreter=false /p:MonoEnableLLVM=true` to a build command.

4. App Sandbox

To build the test app bundle with the App Sandbox entitlement, add `/p:EnableAppSandbox=true` to a build command.

### Test App Design
iOS/tvOS `*.app` (or `*.ipa`) is basically a simple [ObjC app](https://github.com/dotnet/runtime/blob/main/src/tasks/AppleAppBuilder/Templates/main-console.m) that inits the Mono Runtime. This Mono Runtime starts a simple xunit test
runner called XHarness.TestRunner (see https://github.com/dotnet/xharness) which runs tests for all `*.Tests.dll` libs in the bundle. There is also XHarness.CLI tool to deploy `*.app` and `*.ipa` to a target (device or simulator) and listens for logs via network sockets.
Expand Down
28 changes: 28 additions & 0 deletions eng/pipelines/runtime-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ jobs:
interpreter: true
testRunNamePrefixSuffix: Mono_$(_BuildConfig)

#
# 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
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
# extra steps, run tests
extraStepsTemplate: /eng/pipelines/libraries/helix.yml
extraStepsParameters:
creator: dotnet-bot
interpreter: true
testRunNamePrefixSuffix: Mono_$(_BuildConfig)

#
# iOS/tvOS devices - Full AOT + AggressiveTrimming to reduce size
# Build the whole product using Mono and run libraries tests
Expand Down
45 changes: 45 additions & 0 deletions eng/pipelines/runtime-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,51 @@ jobs:
eq(variables['isManualOrIsNotPR'], 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 $(_runSmokeTestsOnlyArg) /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))

#
# iOS/tvOS devices - Full AOT + AggressiveTrimming to reduce size
# Build the whole product using Mono and run libraries tests
Expand Down
12 changes: 11 additions & 1 deletion src/libraries/Common/src/Interop/OSX/Interop.libproc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand Down Expand Up @@ -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; } }
Expand All @@ -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<string> arguments) { throw null; }
[System.CLSCompliantAttribute(false)]
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
Expand Down Expand Up @@ -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 { } }
Expand All @@ -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() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<DefineConstants>$(DefineConstants);FEATURE_REGISTRY</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent);$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent);$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-MacCatalyst;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS</TargetFrameworks>
<Nullable>enable</Nullable>
<!-- Suppress unused field warnings when using PlatformNotSupportedException stubs -->
</PropertyGroup>
Expand Down Expand Up @@ -306,7 +306,7 @@
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.SchedGetSetAffinity.cs"
Link="Common\Interop\Linux\Interop.SchedGetSetAffinity.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsOSX)' == 'true'">
<ItemGroup Condition=" '$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">
<Compile Include="System\Diagnostics\Process.BSD.cs" />
<Compile Include="System\Diagnostics\Process.OSX.cs" />
<Compile Include="System\Diagnostics\ProcessManager.BSD.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class Process
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public static Process[] GetProcessesByName(string? processName, string machineName)
{
if (processName == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class Process : IDisposable
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public static Process[] GetProcessesByName(string? processName, string machineName)
{
ProcessManager.ThrowIfRemoteMachine(machineName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class Process : IDisposable
{
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public void Kill(bool entireProcessTree)
{
if (!entireProcessTree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public static Process Start(string fileName, string arguments, string userName,
/// <summary>Terminates the associated process immediately.</summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public void Kill()
{
if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS())
if (PlatformDoesNotSupportProcessStartAndKill)
{
throw new PlatformNotSupportedException();
}
Expand Down Expand Up @@ -369,7 +370,7 @@ private SafeProcessHandle GetProcessHandle()
/// <param name="startInfo">The start info with which to start the process.</param>
private bool StartCore(ProcessStartInfo startInfo)
{
if (OperatingSystem.IsIOS() || OperatingSystem.IsTvOS())
if (PlatformDoesNotSupportProcessStartAndKill)
{
throw new PlatformNotSupportedException();
}
Expand Down Expand Up @@ -1123,5 +1124,8 @@ public string ProcessName
return _processInfo!.ProcessName;
}
}

private static bool PlatformDoesNotSupportProcessStartAndKill
=> (OperatingSystem.IsIOS() && !OperatingSystem.IsMacCatalyst()) || OperatingSystem.IsTvOS();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public partial class Process : IDisposable
/// Creates an array of <see cref="Process"/> components that are associated with process resources on a
/// remote computer. These process resources share the specified process name.
/// </summary>
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
[SupportedOSPlatform("maccatalyst")]
public static Process[] GetProcessesByName(string? processName, string machineName)
{
throw new PlatformNotSupportedException();
Expand Down
Loading