You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IDE/Tooling: Visual Studio 2022 (or CLI with dotnet commands)
Platform: Windows/Linux/macOS (as applicable)
Describe the bug
Problem became visible from the introduction of this change Support Process.Start() on MacCatalystdotnet/runtime#61507
When using Process.Start in a project targeting net8.0, the platform compatibility analyzer (CA1416) incorrectly emits a warning that the method is only supported on maccatalyst, even though it works on Windows, Linux, and macOS. This behavior seems to misinterpret the [SupportedOSPlatform("maccatalyst")] attribute as a restriction rather than an indication of additional support.
Steps To Reproduce
Create a new .NET 8 project targeting net8.0.
Add code to call Process.Start, e.g.:
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
Process.Start("your_program");
}
Build the project and observe the CA1416 warning.
Reproducible Code:
using System.Diagnostics;
class Program
{
static void Main()
{
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
Process.Start("notepad");
}
}
}
.csproj Configuration:
net8.0
win-x64;linux-x64;osx-x64
Expected behavior
The analyzer should not emit warnings for Process.Start when:
The runtime platform is explicitly checked (e.g., OperatingSystem.IsWindows()).
A method guarded with [SupportedOSPlatformGuard] is used.
The target framework is net8.0 with runtime identifiers for win, linux, and osx.
Actual behavior
The analyzer emits the following warning:
CA1416: This call site is reachable on all platforms. 'Process.Start(string)' is only supported on: 'maccatalyst'.
Even after:
Adding explicit runtime checks (e.g., if (OperatingSystem.IsWindows()) { Process.Start(...) }).
Using a SupportedOSPlatformGuard method.
Ensuring correct runtime identifiers (win, linux, osx) in the project configuration.
This prevents Process.Start from being used without suppressing the warning manually.
Additional context
Additional Context
This misalignment forces developers to either suppress warnings manually or avoid using Process.Start altogether, despite its functional support across platforms. The expected behavior is for the analyzer to respect runtime checks or platform guards.
Analyzer
Diagnostic ID: CA1416:
Validate platform compatibility
Analyzer source
Environment Details
.NET SDK Version: 8.0.x
Target Framework: net8.0
IDE/Tooling: Visual Studio 2022 (or CLI with dotnet commands)
Platform: Windows/Linux/macOS (as applicable)
Describe the bug
Problem became visible from the introduction of this change
Support Process.Start() on MacCatalyst dotnet/runtime#61507
When using Process.Start in a project targeting net8.0, the platform compatibility analyzer (CA1416) incorrectly emits a warning that the method is only supported on maccatalyst, even though it works on Windows, Linux, and macOS. This behavior seems to misinterpret the [SupportedOSPlatform("maccatalyst")] attribute as a restriction rather than an indication of additional support.
Steps To Reproduce
Create a new .NET 8 project targeting net8.0.
Add code to call Process.Start, e.g.:
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
Process.Start("your_program");
}
Reproducible Code:
using System.Diagnostics;
class Program
{
static void Main()
{
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
Process.Start("notepad");
}
}
}
.csproj Configuration:
net8.0 win-x64;linux-x64;osx-x64Expected behavior
The analyzer should not emit warnings for Process.Start when:
Actual behavior
The analyzer emits the following warning:
CA1416: This call site is reachable on all platforms. 'Process.Start(string)' is only supported on: 'maccatalyst'.
Even after:
This prevents Process.Start from being used without suppressing the warning manually.
Additional context
Additional Context
This misalignment forces developers to either suppress warnings manually or avoid using Process.Start altogether, despite its functional support across platforms. The expected behavior is for the analyzer to respect runtime checks or platform guards.
Similar Issues or Documentation:
Link to the documentation on [SupportedOSPlatform]: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.supportedosplatformattribute
Link to the documentation on [SupportedOSPlatformGuard]: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.supportedosplatformguardattribute
The text was updated successfully, but these errors were encountered: