Bug 13345 - Environment.OSVersion.Version on macOS should print OSVersion
Summary: Environment.OSVersion.Version on macOS should print OSVersion
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
Depends on:
Reported: 2013-07-19 13:23 UTC by Shmueli Englard
Modified: 2017-10-12 13:05 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Shmueli Englard 2013-07-19 13:23:14 UTC
System.Environment.OSVersion.Platform == System.PlatformID.Unix on Mac OSX as well as the OS version that's reported is the BSD kernel version, not the Mac OSX version.
Comment 1 Jonathan Pryor 2013-07-19 15:15:51 UTC
PlatformID.Unix is reported on Mac OS X because it broke too much stuff when it returned PlatformID.MacOSX:


See also the "How to detect the execution platform ?" section at: http://mono-project.com/FAQ%3a_Technical#Mono_Platforms
> Notice that as of Mono 2.2 the version returned on MacOS X is still 4 for legacy reasons, 
> too much code was written between the time that the MacOSX value was introduced and 
> the time that we wrote this text which has lead to a lot of user code in the wild to not 
> cope with the newly introduced value.

> the OS version that's reported is the BSD kernel version, not the Mac OSX version.

I don't understand what you're asking with this; do you want Environment.OSVersion.Version to return the BSD kernel version, or the Mac OS X version?

To me, returning the BSD kernel version makes no sense; why would I care?

Returning the Mac OS X version makes considerably more sense, and is what is currently returned:

> $ uname -a
> Darwin penpen.home 12.4.1 Darwin Kernel Version 12.4.1: Tue May 21 17:04:50 PDT 2013; root:xnu-2050.40.51~1/RELEASE_X86_64 x86_64
> $ echo Environment.OSVersion.Version | csharp

The versions match; 12.4.1 is
Comment 2 Shmueli Englard 2013-07-19 15:42:38 UTC
I concede on the PlatformID and that does make sense.

What I want is the OS version. I did misspeak in that its the Darwin Kernel that's reported not OSX. I would expect something more like 10.8.x.
Comment 3 Jonathan Pryor 2013-07-19 15:52:06 UTC
So you want Environment.OSVersion.Version to print `sw_vers | grep ProductVersion`:

    $ sw_vers 
    ProductName:	Mac OS X
    ProductVersion:	10.8.4
    BuildVersion:	12E55

or `system_profiler SPSoftwareDataType`.

(Both commands from: http://hintsforums.macworld.com/archive/index.php/t-60607.html )
Comment 4 Shmueli Englard 2013-07-19 19:43:40 UTC
Yes please :)
Comment 5 shana@spoiledcat.net 2013-07-20 07:00:30 UTC
+1 on this change.

On windows, this property reports the system version and not the "marketing" version because, well, that's what .net reports, and users know how to map those values to what they need to know (if they're running on xp, vista, 7, whatever), and mono follows the 99% compatibility rule there ;)
On OSX this relation is not a known quantity for users (who the heck knows which kernel versions map to the OS version or when they change?), and what the user needs to know is the version of the OS they're running on so they can make decisions on system behaviour, and this information is publicly available for the "marketing" version of OSX.

</my 2 cents>
Comment 6 Marek Safar 2017-10-12 13:05:58 UTC
Environment.OSVersion.Version on macOS should print macOS version not Darwin release version

See https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history

Note You need to log in before you can comment on or make changes to this bug.