-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtimeneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Description
Background and motivation
The Proposal is the addition of an IsNetBSD, IsIllumos and IsSolaris methods to the OperatingSystem class.
The OperatingSystem class is already able to identify the following platforms through its IsOSPlatform method.
| Platform | IsPlatform method available |
|---|---|
| BROWSER | ✔️ |
| WASI | ✔️ |
| WINDOWS | ✔️ |
| OSX | ✔️ |
| MACCATALYST | ✔️ |
| IOS | ✔️ |
| TVOS | ✔️ |
| ANDROID | ✔️ |
| LINUX | ✔️ |
| FREEBSD | ✔️ |
| NETBSD | ❌ |
| ILLUMOS | ❌ |
| SOLARIS | ❌ |
API Proposal
namespace System
{
public sealed class OperatingSystem : ISerializable, ICloneable
{
/// <summary>
/// Indicates whether the current application is running on NetBSD.
/// </summary>
[NonVersionable]
public static bool IsNetBSD()
/// <summary>
/// Indicates whether the current application is running on Illumos.
/// </summary>
[NonVersionable]
public static bool IsIllumos()
/// <summary>
/// Indicates whether the current application is running on Solaris.
/// </summary>
[NonVersionable]
public static bool IsSolaris()
}
}API Usage
if (OperatingSystem.IsNetBSD())
{
Console.WriteLine("Running on NetBSD");
}
else if (OperatingSystem.IsIllumos())
{
Console.WriteLine("Running on Illumos");
}
else if (OperatingSystem.IsSolaris())
{
Console.WriteLine("Running on Solaris");
}Alternative Designs
The proposed feature can already be accomplished with OperatingSystem.IsOSPlatform("NETBSD"), OperatingSystem.IsOSPlatform("ILLUMOS") and OperatingSystem.IsOSPlatform("SOLARIS"), but having an IsPlatform method available for each supported platform would make the overall API of the OperatingSystem class more consistent and predictable.
Risks
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtimeneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration