Conversation
… methods Agent-Logs-Url: https://github.com/Tyrrrz/PolyShim/sessions/5a7623b8-9692-41b7-a49f-61db39e8c7af Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
Tyrrrz
April 18, 2026 10:30
View session
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## prime #123 +/- ##
==========================================
+ Coverage 90.66% 90.70% +0.04%
==========================================
Files 285 285
Lines 4959 4959
Branches 404 404
==========================================
+ Hits 4496 4498 +2
+ Misses 371 369 -2
Partials 92 92 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OperatingSystem.Is*() polyfills to match the platform-guard annotations present on modern .NET, allowing analyzers (e.g., CA1416) to recognize these methods as valid OS guards on older TFMs.
Changes:
- Added
System.Runtime.Versioningimport to the Net50OperatingSystempolyfill file. - Annotated
IsFreeBSD(),IsLinux(),IsMacOS(),IsWindows(), andIsWindowsVersionAtLeast(...)with[SupportedOSPlatformGuard("…")].
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The polyfilled
OperatingSystem.Is*()methods were missing the[SupportedOSPlatformGuard]attributes present on their native .NET 6+ counterparts. Without them, CA1416 doesn't recognize these methods as platform guards on older TFMs, producing spurious warnings for correctly-guarded code:PolyShim/Net50/OperatingSystem.cs— added[SupportedOSPlatformGuard("…")]to each polyfilled method:IsFreeBSD()→"freebsd"IsLinux()→"linux"IsMacOS()→"macos"IsWindows()→"windows"IsWindowsVersionAtLeast(…)→"windows"SupportedOSPlatformGuardAttributeis already polyfilled inPolyShim/Net60/SupportedOSPlatformGuardAttribute.cs, so no new dependency is introduced.