Skip to content

Change Environment.OSVersion to return actual OS version on macOS #34977

Closed

Description

@eerhardt

Similar to #33643, but for macOS (or OSX). We are now returning an understandable version for Windows 10 (ex. 10.0.18363.0), we should start returning understandable versions for macOS.

Today if I run:

Console.WriteLine(System.Environment.OSVersion.Version.ToString());

On my macOS Mojave computer it says 18.7.0.0. But the "About This Mac" window says 10.14.6.

We should change OSVersion.Version to return 10.14.6 instead.

Activity

  1. added
    untriaged
    on Apr 14, 2020
  2. added
    breaking-change
    on Apr 14, 2020
  3. spouliot commented on Apr 15, 2020

    @spouliot
    Contributor

    I don' know (or recall) why mono returns the Darwin kernel version number (and did not know this was the same for dotnet).

    It is not very user/developer friendly. However the runtime code is identical for macOS, iOS, tvOS and watchOS. If we break this to return the macOS version (like 10.15.4.0) then a different implementation will be needed for iOS, tvOS and watchOS runtimes

  4. wfurt commented on Apr 16, 2020

    @wfurt
    Member

    My guess we tried to match Apple's terminoplogy:

    Shining:FunctionalTests furt$ sysctl -a| grep -e release -e version
    kern.osrelease: 19.3.0
    kern.version: Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64
    kern.posix1version: 200112
    kern.osversion: 19D76
    kern.osproductversion: 10.15.3
    kern.iossupportversion: 13.0
    

    In this case, osversion seems completely bogus so we picked up osrelease.
    Do you know @spouliot what we return for various *OS flavors? It would be also nice to return user visible string like 13.3.1 and not underlying kernel.

  5. spouliot commented on Apr 16, 2020

    @spouliot
    Contributor

    @wfurt 19.4.0.0 (the kernel version) comes out of my iOS phone - which is what I expected since it's the same (Darwin-based) code from mono.

    The SDK themselves do offer other API to get and compare the "marketing" versions.

  6. eerhardt commented on Apr 16, 2020

    @eerhardt
    MemberAuthor

    With the proposal #33331, it is going to be super inconsistent if Environment.OSVersion.Version is returning 19.4.0.0, but RuntimeInformation is returning false for IsOSPlatformOrLater(OSPlatform.iOS, 13, 5).

  7. spouliot commented on Apr 24, 2020

    @spouliot
    Contributor

    I think it's better (and a good time) to fix this inconsistency :)

    But TBH this situation has existed since forever and rarely comes up in issues (I can't recall any for iOS/macOS SDK). I think the existing API (similar to the proposed ones) makes it easy to check for features/API that (almost) no one ever used Environment.OSVersion on the mobile SDK.

  8. eerhardt commented on Apr 24, 2020

    @eerhardt
    MemberAuthor

    Note that this issue isn't just about mobile. In the dotnet/sdk we have to work around this issue in order to return the actual OS version when running dotnet --info. It would be super confusing to users to report that they are running on OS Version 19.4.0.0.

    See

    https://github.com/dotnet/sdk/blob/ac704f6190eb2a10c768f188ac57fc139b7e0aac/src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs#L68-L86

  9. self-assigned this
    on May 7, 2020
  10. added 2 commits that reference this issue on May 11, 2020
    2d4acbd
    eb6ba90
  11. ghost added a commit that references this issue on May 14, 2020
  12. ghost locked as resolved and limited conversation to collaborators on Dec 9, 2020
  13. removed
    untriaged
    on Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Runtimebreaking-change

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions