-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix IsOSVersionAtLeast
when build or revision are not provided
#108748
base: main
Are you sure you want to change the base?
Fix IsOSVersionAtLeast
when build or revision are not provided
#108748
Conversation
src/libraries/System.Private.CoreLib/src/System/Environment.OSVersion.MacCatalyst.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Environment.OSVersion.MacCatalyst.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
It's not a regression so not sure if it is eligible for backport.
…Version.MacCatalyst.cs Co-authored-by: Adeel Mujahid <[email protected]>
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Private.CoreLib/src/System/Environment.OSVersion.MacCatalyst.cs
Outdated
Show resolved
Hide resolved
GetOSVersion
on MacCatalyst when build or revision are not providedIsOSVersionAtLeast
when build or revision are not provided
IsOSVersionAtLeast
when build or revision are not providedIsOSVersionAtLeast
when minor/build/revision are not provided
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Outdated
Show resolved
Hide resolved
IsOSVersionAtLeast
when minor/build/revision are not providedIsOSVersionAtLeast
when build or revision are not provided
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Outdated
Show resolved
Hide resolved
…m.cs Co-authored-by: Jan Kotas <[email protected]>
…m.cs Co-authored-by: Jan Kotas <[email protected]>
Do the version checks in https://github.com/dotnet/roslyn-analyzers/blob/main/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/InteropServices/PlatformCompatibilityAnalyzer.cs need updating to match? |
The current changes ensure that an unspecified build or revision component is treated as zero and introduce additional test cases. I still need to confirm whether |
I don't think so, not provided version parts always defaulted to 0 for |
I confirmed that normalizing the build component on MacCatalys will affect the value of |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
I still think that's a change that we should make, but I don't feel too strongly about it. The rationale is that it would align the behavior between iOS and Mac Catalyst. The apps are often built from the same source tree just with different TFM, so I would expect the APIs to behave as close as possible. Internally, LLVM version checks are also normalizing the values but I cannot think of any way that would be user exposed. |
@jkotas What is the cost of filling a breaking change notice? Not related to this PR, but something that seems a bit inconsistent. When using the full constructor overload, it requires the build and revision components to be >= 0, otherwise they are unspecified. This causes an issue on MacCatalyst with the following code: Version current = Environment.OSVersion.Version;
Version newVersion = new Version(current.Major, current.Minor, current.Build, current.Revision); // This will throw ArgumentOutOfRange exception |
src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Outdated
Show resolved
Hide resolved
I think user should check the values in this case, or they can use |
…m.cs Co-authored-by: Adeel Mujahid <[email protected]>
…m.cs Co-authored-by: Adeel Mujahid <[email protected]>
https://github.com/dotnet/runtime/blob/main/docs/project/breaking-change-process.md has the instructions |
Why is the behavior between iOS and Mac Catalyst different at the OS level? |
It’s really not different but the version values are retrieved in a different way. Both iOS and macOS use version numbers with 2 or 3 components and we were always normalizing that to 3 (by retrieving the version as Mac Catalyst is just macOS app like any other calling the same macOS libraries like a normal Mac app would and having the same structure. The principal difference is that the SDK exposes different parts of the API surface but at the end of the day it still calls the same libraries. There are some quirk flags to make some APIs behave like iOS but that mostly appeared when Apple added support for running unmodified iOS apps on ARM macOS. When it comes to Mac Catalyst versioning there is a mapping between a macOS version and the supported iOS API surface version. Retrieving |
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
Description
This PR fixes #108694 by updating
IsOSVersionAtLeast
to treat unspecified build or revision components as zero.