Based on the discussion thread #37831, this proposal is to extend the output of RuntimeInformation.OSDescription string and include more information about the current platform.
The purpose is to let consumer obtained a more identifiable information about the platform from an existing OSDescription API in a consistent manner, for analytics and logging like scenarios.
For example, dotnet-sdk uses such information for dotnet --info and telemetry (src: https://github.com/dotnet/sdk/blob/3595e2a/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs). Most of that code is also replicated in a test utility method in runtime repo:
|
private static DistroInfo GetDistroInfo() |
Currently, the output string on various platforms look like this:
| Platform |
RuntimeInformation.OSDescription |
| FreeBSD 11 |
FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC |
| Gentoo |
Linux 4.19.104-gentoo #1 SMP Wed Feb 19 06:37:35 UTC 2020 |
| macOS 10.14.6 |
Darwin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:05 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 |
| SmartOS 2020 |
SunOS 5.11 joyent_20200408T231825Z |
| Solaris 11.3 |
SunOS 5.11 11.3 |
| Ubuntu 18.04 |
Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020 |
| Windows 10 |
Microsoft Windows 10.0.19635 |
This proposal is about adding a few more bits of information: name (value of PAL_UNIX_NAME or Windows), version and distro ID. For example, in some cases runtime/hosts only care about major version, so we can just use that. Expected output for the above list is:
| Platform |
RuntimeInformation.OSDescription |
| FreeBSD 11 |
FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC. Platform: FreeBSD, Version 11 |
| Gentoo |
Linux 4.19.104-gentoo #1 SMP Wed Feb 19 06:37:35 UTC 2020. Platform: Linux, ID: gentoo
(distro does not provide version information) |
| macOS 10.14.6 |
Darwin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:05 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64. Platform: OSX, Version: 10.14, ID: Mac OS X
(this version and ID information can be obtained by invoking sw_vers -productVersion and sw_vers -productName respectively, or by reading the XML file directly, which sw_vers uses: /System/Library/CoreServices/SystemVersion.plist) |
| SmartOS 2020 |
SunOS 5.11 joyent_20200408T231825Z. Platform: illumos, Version 2020, ID: SmartOS |
| Solaris 11.3 |
SunOS 5.11 11.3. Platform: Solaris, Version 11 |
| Ubuntu 18.04 |
Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020. Platform: Linux, Version: 18.04, ID: ubuntu |
| Windows 10 |
Microsoft Windows 10.0.19635. Platform: Windows, Version: 10.0.19635 |
Based on the discussion thread #37831, this proposal is to extend the output of
RuntimeInformation.OSDescriptionstring and include more information about the current platform.The purpose is to let consumer obtained a more identifiable information about the platform from an existing
OSDescriptionAPI in a consistent manner, for analytics and logging like scenarios.For example, dotnet-sdk uses such information for
dotnet --infoand telemetry (src: https://github.com/dotnet/sdk/blob/3595e2a/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs). Most of that code is also replicated in a test utility method in runtime repo:runtime/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs
Line 155 in 579d883
Currently, the output string on various platforms look like this:
RuntimeInformation.OSDescriptionFreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERICLinux 4.19.104-gentoo #1 SMP Wed Feb 19 06:37:35 UTC 2020Darwin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:05 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64SunOS 5.11 joyent_20200408T231825ZSunOS 5.11 11.3Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020Microsoft Windows 10.0.19635This proposal is about adding a few more bits of information: name (value of
PAL_UNIX_NAMEorWindows), version and distro ID. For example, in some cases runtime/hosts only care about major version, so we can just use that. Expected output for the above list is:RuntimeInformation.OSDescriptionFreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC. Platform: FreeBSD, Version 11Linux 4.19.104-gentoo #1 SMP Wed Feb 19 06:37:35 UTC 2020. Platform: Linux, ID: gentoo(distro does not provide version information)
Darwin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:05 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64. Platform: OSX, Version: 10.14, ID: Mac OS X(this version and ID information can be obtained by invoking
sw_vers -productVersionandsw_vers -productNamerespectively, or by reading the XML file directly, whichsw_versuses:/System/Library/CoreServices/SystemVersion.plist)SunOS 5.11 joyent_20200408T231825Z. Platform: illumos, Version 2020, ID: SmartOSSunOS 5.11 11.3. Platform: Solaris, Version 11Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020. Platform: Linux, Version: 18.04, ID: ubuntuMicrosoft Windows 10.0.19635. Platform: Windows, Version: 10.0.19635