Skip to content

Proposal: extend platform information in RuntimeInformation.OSDescription #37923

Open
@am11

Description

@am11

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:

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 [email protected]:/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 [email protected]:/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtimedesign-discussionOngoing discussion about design without consensusenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions