Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I got this code...
On my Mac when I'm building with Mono (not monotouch) it returns:
When I look in the PlatformID in the object browser the MacOsx platform is defined so is XBox as well as a large number of native Windows IDs....
This isn't working correctly it shouldn't currently return the Platform as UNIX but MacOsx.
Also it would be really great if it was expanded to include iOS and Android.
The enumeration type (and values) comes from Microsoft. The Mono project added a "special" value (128) to represent Unic back in the .NET 1.x days (when Unix was not defined). It was very helpful at the time.
That turned out, later, to be a mixed blessing since MS added Unix later (value 6) along with other values, e.g. Mac. Backward compatibility requires us to still support 128 (along with 6) which is not a big issue.
However supporting 'Mac' (which is Unix too) turned out to regress quite a bit of code (including a lot of 3rd party code and common, reusable, libraries). As such it is unlikely that we'll add more of our own values *directly* in this enumeration.
*** Bug 6153 has been marked as a duplicate of this bug. ***
Makes sense for not extending what Microsoft is not extending to keep compatibility. And what about extending Mono.Unix.UnixEnvironment?
@Attila: We could certainly add something to UnixEnvironment, though:
1. I'm not sure what you're thinking of adding. Feature checks (e.g. does this file/export exist?) would still be better, even on OS X, because history has shown that platform version checks are brittle and easy to get wrong. Knowing that you're on OS X doesn't necessarily help, as the given functionality you want may require Lion, now Snow Leopard, etc. If you need to check for platform + version, you might as well use feature checks instead.
2. If you really want a platform check, there's always Mono.Unix.Native.Syscall.uname()...
3. Using UnixEnvironment would require referencing Mono.Posix.dll, which is less than ideal in a variety of circumstances. For example, none of Mono's BCL code could use it.
I'm thinking to add a correct OSVersion property to the UnixEnvironment which contains those functionalities that makes sense to Mono but maybe not making sense to .NET and are not available on Microsoft's platform. That way we could keep the compatilibility.
For platform version check, I found an article that describes the correct method (http://cocoadev.com/wiki/DeterminingOSVersion), but had no time to check it yet. I agree that if it is extended it should be done correctly and report correct OS versions too. Anyway my problem when I found out that MacOSX was not reported correctly was that I tried to implement a warning for myself that MacOSX's syslog does not support LOG_DEBUG and LOG_NOTICE (see bug 6125). In this case it is completly enough to know that the OS is MacOSX.
I don't know what BCL stands for but if you would like to use any of the Unix specific functionality like directory right management and so on, you should have a reference to Mono.Posix.dll anyway, so if you're doing low level fun I think that could be no problem from the code depending on the framework (or if it is I think the user of the dll should dependency inject it). From the point of the code inside the framework, I don't know if it is a problem or not.