-
Notifications
You must be signed in to change notification settings - Fork 7.7k
PSVersionTable should have entry for OS #1635
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
Comments
Host sniffing is bad; testing for features is good. Is this something we envisage being useful information in the grand scheme things? Esp. since there's an issue somewhere else tracking a desire for a |
Good point - I was thinking more from a "how can I repro" perspective, but folks would likely start using the property in scripts thinking it's useful. Maybe we need a |
And it might be helpful for such an environment to list loaded module names & version numbers as well. Might also be nice to have list the architecture (x86, x64, ARM32) of the OS and PowerShell (for those cases where x86 PS is running on x64 Windows). |
@oising: testing for features is good, but you don't want to test for features to decide simple things like what library to load. E.g. if I ship System.Data.SqlClient in my module, it has .Net452, .Net46, and separate .NetStandard assemblies for Windows and for Unix. Just to be able to load the right one I need to know OS and Arch. I think it would be enough to know:
|
Just do it. It will make it easier for scripts to know where to look for environmental info and it will make it easier for you to get bug reports with that same environment info. |
Yeah, I used to agree with @oising's opinion here that we shouldn't expose this because it encourages people to "do the wrong thing" when checking for certain kinds of compat at runtime. Until I saw the kind of lengths people will go to in order to check for these sorts of things anyway. They'll do it one way or another, and at least this way it's easier to understand when and why people are checking for OS so we can mitigate it in the future. (E.g. I want to know that @Jaykul is testing for OS because of x-CLR assembly issues, so that I know we need to adopt .NET Standard 2.0). That being said, I still agree that checking for features is generally the right thing to do, and we should absolutely have a PSSA rule to throw warnings on checks against $PSVersionTable.OS at runtime. Oh, and of course, we still need to design this thing. Is it |
But please ... get rid of the top level |
@PowerShell/powershell-committee I agree w/ @Jaykul on this one. We should try and move to CoreFX's The next question is whether or not we should propagate |
@PowerShell/powershell-committee reviewed this, we agree that $psversiontable should use Environment.OSVersion to populate the new OS property. On the topic of $IsWindows/$IsLinux/$IsMac, we agree that the capability to check for the OS via a variable is needed, but should consider implemented in a different way (ie, a prefix to avoid collision or make them members of a feature check variable like $PSFeature.IsWindows). Recommendation is we should have a RFC for the OS check variable. @joeyaiello to author. |
I looked CoreFX and didn't found results of Unix tests for Environment.OSVersion under code coverage. CoreFX parse a kernel's Also we use in |
|
|
taking a look on this |
If the next what we want, then we could ask CoreFX team:
|
I think I know this might be ballooning |
@joeyaiello could you give me a mock information $PSVersionTable.OS should give out? |
@joeyaiello Do we really want |
@chunqingchen Yeah, I guess just make I'm not super sold on |
BTW the longer you wait, the more modules get published that rely on $Is*. :-) posh-git aleady relies on these variables but we could switch to the "preferred way" of testing for the OS platform. |
@joeyaiello did you really mean |
Per our discussion today, I'm on board with the recommendation from @SteveL-MSFT. We also agreed that |
Is |
Steps to reproduce
Expected behavior
Something useful
Actual behavior
empty string
Environment data
The text was updated successfully, but these errors were encountered: