Open rolfbjarne opened 1 month ago
From @drasticactions on Wed, 09 Oct 2024 05:31:59 GMT
TL;DR macOS reports 18.0
, SDK parses it as a Version
which is where the -1
comes from, Runtime check will always report it as below.
https://github.com/drasticactions/MauiRepoRedux/tree/MacCatalystVersion
That value is coming from SystemVersion.plist
, which is 18.0
, hence why it would get -1
, since it's Version.Parse
ed and it doesn't have the Build number that it may have had in the past.
It may be that this needed that the -1
check needs to also be added to build for the same reason as revision, since it can't be assumed that build will be there. Or the SDK code above that fetches the version should always include the build even if the system doesn't provide it.
To work around it, checking against18
0
-1
should work
Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.
cc @akoeplinger, perhaps we can simplify the parsing something like this https://github.com/dotnet/runtime/compare/main...am11:runtime:patch-15, i.e. only require major version and make other optional (base on -1 val)?
@am11 I think we should fix this in Environment.OSVersion.MacCatalyst.cs instead and default the patch/build version to 0. We already do that for iOS/macOS in GetOperatingSystemVersion
in Interop.libobjc.cs
That said, I wonder how this ever worked since e.g. I also don't have a three-part version in /System/Library/CoreServices/SystemVersion.plist
on my macOS 14.7 machine and from some quick googling it seems to always have been a two-part string?
Tagging subscribers to 'os-maccatalyst': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.
@vitek-karas we probably need to backport this.
Yup, whichever solution makes sense. If it's a bit more general, may just cover more platforms. Version.Parse
requires two parts (major and minor) at minimum, everything else is optional and result in -1.
The IsOSVersionAtLeast
fix will be backported to .NET 9 in a servicing release without the breaking change once the release/9.0-staging
becomes available.
From @PureWeen on Tue, 08 Oct 2024 20:22:20 GMT
Description
It looks like on MacCatalyst the Build on the
Environment.OSVersion.Version
is set to "-1" so when you callif (OperatingSystem.IsMacCatalystVersionAtLeast(18,0))
it resolves to false. This works fine on iOS just not MacCatalyst
Reproduction
aoperatingsystem.zip
Just run the app and I've set a label on the screen to output the value of
OSVersion.Version
. I've also included some if statements in the main page you can break pointCatalyst
iOS
Copied from original issue xamarin/xamarin-macios#21390