Repository navigation
Closed
Labels
area-System.Runtimecode-analyzerMarks an issue that suggests a Roslyn analyzerMarks an issue that suggests a Roslyn analyzer
Milestone
Description
We decided in #40111 (comment) to expose OS checks as static helpers on OperatingSystem. We need to implement those:
namespace System
{
public partial class OperatingSystem
{
// Primary
public static bool IsOSPlatform(string platform);
public static bool IsOSPlatformVersionAtLeast(string platform, int major, int minor = 0, int build = 0, int revision = 0);
// Accelerators for platforms where versions don't make sense
public static bool IsBrowser();
public static bool IsLinux();
// Accelerators with version checks
public static bool IsFreeBSD();
public static bool IsFreeBSDVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
public static bool IsAndroid();
public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
public static bool IsIOS();
public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
public static bool IsMacOS();
public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
public static bool IsTvOS();
public static bool IsTvOSVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
public static bool IsWatchOS();
public static bool IsWatchOSVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
public static bool IsWindows();
public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);
}
}/cc @jeffhandley @buyaa-n
Metadata
Metadata
Assignees
Labels
area-System.Runtimecode-analyzerMarks an issue that suggests a Roslyn analyzerMarks an issue that suggests a Roslyn analyzer
Activity
akoeplinger commentedon Aug 5, 2020
Do we want to implement them using the same underlying
RuntimeInformationarchitecture?So running
RuntimeInformation.IsOSPlatform(OSPlatform.Create("iOS"))would return true because it just forwards toOperatingSystem.IsOSPlatform()?terrajobst commentedon Aug 6, 2020
I consider that an implementation detail. In my head, the impl looked something like this:
akoeplinger commentedon Aug 6, 2020
Ok yeah I agree it is an implementation detail but ideally the two APIs should align like in your example.
It'd be bad if in the future when we add a new platform we'd need to add it in two places or worse if
RuntimeInformation.IsOSPlatform(OSPlatform.Create("AppleWashingMachine")returned a different value thanOperatingSystem.IsOSPlatform("AppleWashingMachine")