Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Get OS information #1

Open
Open
@bruno-garcia

Description

@bruno-garcia

Define an API to get the OS name, version, kernel, etc.

Ideally the NETStandard targets would work on Xamarin.iOS, Xamarin.Android, Unity (including IL2CPP, although it might not be possible) as well as .NET Core, .NET Framework and Mono on Windows, Linux and macOS.

Windows 10

RuntimeInformation.OSDecription: On Windows 10 returns: 10.0.17134
Now when I read this Microsoft announcement they talk about "Windows 10, version 1803". This library shall report the latter version which is what is used to talk about Windows versions.

Differentiating between Windows Server and Desktop edition.

It'll need some IsServer field but, how is this going to work on Linux? What defines Linux desktop or server?

On macOS, iOS, iPad and Linux it returns: Unix. on Xamarin, Mono and for compatibility reasons, also on CoreCLR.

On Mono, to know whether you are on Unix or not, is straightforward. But finding out which distribution on Linux (something like this) and which macOS version, is not.

Differentiating between iPad, iOS and macOS?

Mono has some code that perhaps could be used when runtime is Mono.

Consider the approached used by Pkcs11Interop

Differentiating between different Linux distributions.

To consider:
Environment.OSVersion calls under the hood GetVersionEx, deprecated since Windows 8.1
That means that calling it from a .NET Core app 2.0 on a Windows 10 will return: 6.2.9200.0
That is the Windows 8 version! Super confusing stuff.

On .NET 4.0 target. There’s no RuntimeInformation.OSDescription so how to get the OS Version? Environment.OSVersion gives you potential wrong data. Take some examples from CoreCLR 2.0:

macOS:
Environment.OSVersion:                                  Unix 17.5.0.0
Environment.OSVersion.Platform:                         Unix
Environment.OSVersion.VersionString:                    Unix 17.5.0.0
Environment.OSVersion.Version.Build:                    0
Environment.OSVersion.Version:                          17.5.0.0
RuntimeInformation.OSDescription:                       Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64

Kali WSL:
Environment.OSVersion:                                  Unix 4.4.0.43
Environment.OSVersion.Platform:                         Unix
Environment.OSVersion.VersionString:                    Unix 4.4.0.43
Environment.OSVersion.Version.Build:                    0
Environment.OSVersion.Version:                          4.4.0.43
RuntimeInformation.OSDescription:                       Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014

CentOS
Environment.OSVersion:                                  Unix 3.10.0.693
Environment.OSVersion.Platform:                         Unix
Environment.OSVersion.VersionString:                    Unix 3.10.0.693
Environment.OSVersion.Version.Build:                    0
Environment.OSVersion.Version:                          3.10.0.693
RuntimeInformation.OSDescription:                       Linux 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018

Windows 10 Pro:
Environment.OSVersion:                                  Microsoft Windows NT 6.2.9200.0
Environment.OSVersion.Platform:                         Win32NT
Environment.OSVersion.VersionString:                    Microsoft Windows NT 6.2.9200.0
Environment.OSVersion.Version.Build:                    9200
Environment.OSVersion.Version:                          6.2.9200.0
RuntimeInformation.OSDescription:                       Microsoft Windows 10.0.16299         

Consider the current implementation on SharpRaven

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions