dotnet / platform-compat

Roslyn analyzer that finds usages of APIs that will throw PlatformNotSupportedException on certain platforms.
MIT License
278 stars 43 forks source link

PC001: Process.ExitCode isn't supported on Linux, MacOSX #72

Closed bradwilson closed 6 years ago

bradwilson commented 6 years ago

This does not appear correct. dotnet xunit uses Process.ExitCode successfully on Linux and macOS via .NET Core.

pjanotti commented 6 years ago

The issue with this one is that it will throw if the instance is a remote process, which is not the typical case. While ideally we need a better handling for the cases depending on usage context for now we will decide such cases based on what we think is the typical usage. In this case this should be suppressed (there a bunch of related ones).

pjanotti commented 6 years ago

Actually there is no way to create a Process associated to a remote machine on any Unix. So this one and many others for Process are really false positives. We should have a rule to have a warning for the methods below on any Unix:

public static Process GetProcessById(int processId, string machineName)
public static Process[] GetProcesses(string machineName)
public static Process[] GetProcessesByName(string processName, string machineName)
springy76 commented 6 years ago

HasExited is also being reported but works.

pjanotti commented 6 years ago

Thanks @springy76. Just for the record HasExited was part of PR #82 and it is fixed now.