Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Cleanup PlatformID and PlatformDetection usage #1578

Merged
merged 2 commits into from
Apr 30, 2015

Conversation

stephentoub
Copy link
Member

Primarily a search-and-replace change. Two parts:

  1. Added a PlatformID.AnyUnix to the XunitTraitsDiscoverers, and replaced the ~110 occurrences of [ActiveIssue(..., PlatformID.Linux | PlatformID.OSX)] with [ActiveIssue(..., PlatformID.AnyUnix)]. This will make it easier to add new Unix platforms and have most of the affected tests automatically disabled.
  2. Replaced usage of Interop.PlatformDetection.OperatingSystem == Interop.OperatingSystem.Windows with Interop.IsWindows.

There are ~110 tests that have been disabled with an ActiveIssue for PlatformID.Linux | PlatformID.OSX.  To simplify this and to avoid lots of additional churn when additional Unix-based platforms are added, I've added PlatformID.AnyUnix = Linux | OSX, and replaced all usage of Linux | OSX with just AnyUnix.  When new platforms are added, we can simply add to the enum, expand the meaning of AnyUnix, and most tests meant to be disabled for Unix will automatically be disabled.
When I first added Interop.PlatformDetection while cleaning up tests for Linux, I'd added an OperatingSystem property, and the typical pattern was to compare against an enum, e.g.
```
if (Interop.PlatformDetection.OperatingSystem == Interop.OperatingSystem.Windows)
{
...
}
```
We subsequently added helper Is* properties, e.g. IsWindows, but never went back and substituted into the previous uses.  This cleans that up, such that usage like the above instead becomes:
```
if (Interop.IsWindows)
{
    ...
}
```
@ellismg
Copy link
Contributor

ellismg commented Apr 30, 2015

LGTM

ellismg added a commit that referenced this pull request Apr 30, 2015
Cleanup PlatformID and PlatformDetection usage
@ellismg ellismg merged commit 131b26f into dotnet:master Apr 30, 2015
@@ -12,6 +12,7 @@ public enum PlatformID
Windows = 1,
Linux = 2,
OSX = 4,
AnyUnix = Linux | OSX,
Any = Windows | Linux | OSX
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have Any on top with value ~0 (so to depict the true meaning of "any"), or is it intentional to confine the OS set?

@stephentoub stephentoub deleted the cleanup_os_tests branch May 1, 2015 11:12
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Cleanup PlatformID and PlatformDetection usage

Commit migrated from dotnet/corefx@131b26f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants