Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eerhardt opened this issue Apr 14, 2020 · 6 comments · Fixed by #36029
Closed

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

eerhardt opened this issue Apr 14, 2020 · 6 comments · Fixed by #36029
Assignees
Labels
area-System.Runtime breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.

Comments

@eerhardt
Copy link
Member

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.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Runtime untriaged New issue has not been triaged by the area owner labels Apr 14, 2020
@eerhardt eerhardt added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Apr 14, 2020
@spouliot
Copy link
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

@wfurt
Copy link
Member

wfurt commented Apr 16, 2020

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.

@spouliot
Copy link
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.

@eerhardt
Copy link
Member Author

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).

@spouliot
Copy link
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.

@eerhardt
Copy link
Member Author

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

@eerhardt eerhardt self-assigned this May 7, 2020
eerhardt added a commit to eerhardt/runtime that referenced this issue May 7, 2020
eerhardt added a commit that referenced this issue May 11, 2020
* Return the correct OSVersion on OSX like systems.

Fix #34977

* Rename files to not have Linux when they aren't Linux specific.

* Assert OSVersion Build number is valid.

* PR feedback

Move interop code to Common\src\Interop.
Specify the full path to libobjc.dylib.
Fix objc_msgSend_stret for ARM64.

* Specify full path to libproc.dylib.

Fix #24095
dotnet-maestro bot added a commit to dotnet/sdk that referenced this issue May 13, 2020
* Update dependencies from https://github.com/dotnet/runtime build 20200507.11

- System.CodeDom: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- Microsoft.NET.HostModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- Microsoft.Extensions.DependencyModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- Microsoft.NETCore.App.Runtime.win-x64: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- Microsoft.NETCore.DotNetHostResolver: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- Microsoft.NETCore.App.Ref: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- System.Security.Cryptography.ProtectedData: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- System.Text.Encoding.CodePages: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11
- System.Resources.Extensions: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20257.11

* Update dependencies from https://github.com/dotnet/runtime build 20200508.3

- System.CodeDom: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- Microsoft.NET.HostModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- Microsoft.Extensions.DependencyModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- Microsoft.NETCore.App.Runtime.win-x64: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- Microsoft.NETCore.DotNetHostResolver: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- Microsoft.NETCore.App.Ref: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- System.Security.Cryptography.ProtectedData: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- System.Text.Encoding.CodePages: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3
- System.Resources.Extensions: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20258.3

* Update dependencies from https://github.com/dotnet/runtime build 20200509.5

- System.CodeDom: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- Microsoft.NET.HostModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- Microsoft.Extensions.DependencyModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- Microsoft.NETCore.App.Runtime.win-x64: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- Microsoft.NETCore.DotNetHostResolver: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- Microsoft.NETCore.App.Ref: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- System.Security.Cryptography.ProtectedData: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- System.Text.Encoding.CodePages: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5
- System.Resources.Extensions: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20259.5

* Update dependencies from https://github.com/dotnet/runtime build 20200510.5

- System.CodeDom: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- Microsoft.NET.HostModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- Microsoft.Extensions.DependencyModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- Microsoft.NETCore.App.Runtime.win-x64: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- Microsoft.NETCore.DotNetHostResolver: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- Microsoft.NETCore.App.Ref: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- System.Security.Cryptography.ProtectedData: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- System.Text.Encoding.CodePages: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5
- System.Resources.Extensions: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20260.5

* Migrate netcoreapp5.0 => net5.0

* Update stage 0

Should support net5.0 TargetFramework

* Update dependencies from https://github.com/dotnet/runtime build 20200511.9

- System.CodeDom: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- Microsoft.NET.HostModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- Microsoft.Extensions.DependencyModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- Microsoft.NETCore.App.Runtime.win-x64: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- Microsoft.NETCore.DotNetHostResolver: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- Microsoft.NETCore.App.Ref: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- System.Security.Cryptography.ProtectedData: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- System.Text.Encoding.CodePages: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9
- System.Resources.Extensions: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.5.20261.9

* Update dependencies from https://github.com/dotnet/runtime build 20200512.14

- System.CodeDom: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- Microsoft.NET.HostModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- Microsoft.Extensions.DependencyModel: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- Microsoft.NETCore.App.Runtime.win-x64: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- Microsoft.NETCore.DotNetHostResolver: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- Microsoft.NETCore.App.Ref: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- System.Security.Cryptography.ProtectedData: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- System.Text.Encoding.CodePages: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14
- System.Resources.Extensions: 5.0.0-preview.5.20253.7 -> 5.0.0-preview.6.20262.14

* Fix macOS version test, now that dotnet/runtime#34977 is fixed.

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
ghost pushed a commit to dotnet/sdk that referenced this issue May 14, 2020
Now that dotnet/runtime#34977 and dotnet/runtime#33643 are fixed, Environment.OSVersion returns the correct version for Windows and macOS.
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants