-
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
add IsOSPlatformOrLater and IsOSPlatformEarlierThan methods #39005
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @tommcdon |
.../src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.PlatformVersion.cs
Outdated
Show resolved
Hide resolved
.../src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.PlatformVersion.cs
Show resolved
Hide resolved
.../src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.PlatformVersion.cs
Show resolved
Hide resolved
.../src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.PlatformVersion.cs
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices.RuntimeInformation/tests/PlatformVersionTests.cs
Outdated
Show resolved
Hide resolved
The spec mentions that:
@tannergooding @jkotas could you please point me to some doc|PR that explains|shows how to make JIT recognize given method as a constant? |
I'm not sure the JIT treating them as a constant is necessarily a .NET 5 goal, but rather an eventual goal. I don't think getting the JIT to support Jan or someone else may know better or have a different opinion here, of course 😄 |
I agree with @tannergooding that the design of these APIs is unfriendly to optimizations, and recognizing the complex pattern as constant would be non-trivial. I do not think we should be building one-off optimizations like that. If somebody needs to call this on a hot path, they should cache the result in a static readonly bool. |
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.
I think we should add other new OS versions with this PR EDIT: there is another PR for this. LGTM, thanks!
Contributes to #33331