-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
OSDescription: Returns a user-friendly name instead of kernel info on Android & Apple platforms #113041
base: main
Are you sure you want to change the base?
Conversation
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.
PR Overview
This PR updates Android's OS description to return a user-friendly string format instead of the raw Linux kernel information.
- Adds a conditional branch in the Unix runtime information provider to check for Android and format the OS description accordingly.
- Introduces a new test case to verify that the Android OS description contains the expected substring.
Reviewed Changes
File | Description |
---|---|
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Unix.cs | Adds a branch to return "Android (API {version})" for Android OS. |
src/libraries/System.Runtime/tests/System.Runtime.InteropServices.RuntimeInformation.Tests/DescriptionNameTests.cs | Adds a test to check the Android OS description behavior. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
I think it should align with what other platforms (including e.g. iOS) return from OSDescription instead, as it's happening right now. We had some discussion about it in #37923 and there is no concrete proposal yet. It would be better to work out the proposal and have this breaking change for all platforms once. |
Since #37923 was raised, the output of OSDescription has undergone significant changes. So I believe that in the five years since #37923 was raised, with no concrete proposal yet, it still makes sense for us to continue optimizing |
It was for all linux based systems and still a broader change. The preferred way for OS detection is to use targeted APIs such as https://learn.microsoft.com/dotnet/api/system.operatingsystem.isandroid and https://learn.microsoft.com/dotnet/api/system.operatingsystem.isandroidversionatleast based on the discussion which transpired during those APIs review process. |
Should this be labeled as a breaking change? |
I do not think that this is a breaking change. This property is documented as opaque string that should not be parsed. It comes down to whether we like the new description. |
I don't have a strong opinion but I'm in favor of the change, the new string is much more useful than the kernel version. It'd be nice to do the same for iOS/tvOS (and maybe macOS?) too. |
I'm not opposed to this change as i think it's better than what we have currently. |
Tagging subscribers to 'os-maccatalyst': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger |
@akoeplinger @am11 @steveisok @jkotas I pushed a new commit that does the same to Apple platforms. Question: for Apple platforms, which description do you think is better?
|
When running on Android,
RuntimeInformation.OSDescription
returns:Before:
Linux 6.6.30-android15-8-gdd9c02ccfe27-ab11987101 #1 SMP PREEMPT Tue Jun 18 20:50:32 UTC 2024
After:
Android (API level 35)
When running on macOS:
Before:
Darwin 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:06:23 PDT 2024; root:xnu-11215.41.3~3/RELEASE_ARM64_T8132
After:
macOS 15.1.0
This aligns with the OSVersion:
runtime/src/native/libs/System.Native/pal_runtimeinformation.c
Lines 21 to 27 in 12bf864
and
runtime/src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Lines 208 to 212 in 12bf864