-
Notifications
You must be signed in to change notification settings - Fork 8.1k
In local invocations, do not require -PowerShellVersion 5.1 for Get-FormatData in order to see all format data. #11270
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
In local invocations, do not require -PowerShellVersion 5.1 for Get-FormatData in order to see all format data. #11270
Conversation
In local invocations, do not require -PowerShellVersion 5.1 in order to see all format data.
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-FormatData.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-FormatData.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-FormatData.Tests.ps1
Outdated
Show resolved
Hide resolved
vexx32
left a comment
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.
Just some minor style comments. Looking food so far, thanks for PRing this one @mklement0! 💖 😊
....PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-FormatData.Tests.ps1
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-FormatData.Tests.ps1
Outdated
Show resolved
Hide resolved
|
@mklement0 can you look at the test failures? |
....PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs
Outdated
Show resolved
Hide resolved
|
@SteveL-MSFT, I'll focus on fixing the fundamental problem first. A preliminary investigation showed that the problem was just one of duplicates in the output, strangely; applying |
src/System.Management.Automation/engine/remoting/fanin/PSPrincipal.cs
Outdated
Show resolved
Hide resolved
Revert making internal ApplicationArguments setter public.
Revert accidental `launch.json` change.
|
@SteveL-MSFT, looking into this further my conclusion is that this PR has simply unmasked an unrelated problem that should be investigated separately. For now, I've restored the semantics of the original test by passing As for what may be going on: The current format-data definitions contain duplicates: Some types are covered both by a dedicated definition (where $dataWithMultipleTypes = Get-FormatData -PowerShellVersion 5.1 | Where { $_.TypeNames.Count -gt 1 }
$dataWithSingleType = Get-FormatData -PowerShellVersion 5.1 | Where { $_.TypeNames.Count -eq 1 }
# Find all single-type definitions also covered by multiple-type definitions.
$dataWithSingleType | ? { foreach ($fd in $dataWithMultipleTypes) { if ($fd.TypeNames -contains $_) { return $true } } }This currently yields:
|
|
@mklement0 adding |
PaulHigin
left a comment
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.
LGTM
|
@SteveL-MSFT, are there concerns around the public method added to |
SteveL-MSFT
left a comment
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.
The test hooks have to be public so that the tests can call them. They are in the internal namespace so users should not use them. Since they run in the context of the user, they are effectively no different than if the user did reflection anyways.
|
@mklement0 Please have a look at the merge conflicts |
|
@adityapatwardhan, I've resolved the merge conflict. The PowerShell-CI-static-analysis failure seems like a transient one ("SocketException: Network is unreachable") - not sure how to restart the test. |
|
@PoshChan please retry static |
|
@SteveL-MSFT, successfully started retry of |
|
@mklement0 There seems to be another merge conflict. Please have a look. |
|
@adityapatwardhan , I've resolved the (trivial) conflict in favor of preferring a whitespace after the unary form of the |
|
@mklement0 Thanks for your contribution! |
|
🎉 Handy links: |
|
Please see the update I posted yesterday that still exists in PS 7.2.0 to an issue I previously reported about issues with Get-FormatData / Export-FormatData / Update-FormatData. Here's the link with a detailed example that is 100% reproducible with PS 7.2.0 A quick summary would be that: A roundtrip of format data using Get-FormatData / Export-FormatData / Update-FormatData results in broken output. The 2 main issues are: When format data has a custom control it is not returned by Get-FormatData and therefore is lost on the roundtrip. When format data contains more than 1 TypeName, Get-FormatData seems to get both but ExportFormat data only exports the first 1 so additional types are lost in the roundtrip. This can be seen in the PS source code PowerShell-7.2.0/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/FileSystem_format_ps1xml.cs where the custom control is created and shared between views and where a view has more than 1 TypeName. It is frustrating to see these problems still exist in the latest PS when they have existed and reported so long ago. Get-FormatData / Export-FormatData / Update-FormatData are GREAT feaures but the *.format.ps1xml files should never have been removed until the replace actually was fully functional. Fixing Export-FormatData to include all TypeNames seems like it should be a fairly easy fix since Get-FormatData appears to have them. Fixing the CustomControl situation seems more complicated since it is shared. Here's a thought: DirectoryInfo / FileInfo objects have the PSParentPath note property which looks like this: Add a new note property ParentPath Then all of the places that are using the shared custom control for their GroupBy could just be changed to reference ParentPath and there would no longer be a need for the custom control! This seems like a fairly easy change and by eliminating the shared custom control you remove the more difficult situation to fix. What do you think? Joe |
PR Summary
Fix #4237
PR Context
In order to support older remoting clients, certain format data that requires v5.1+ is not returned from
Get-FormatDataby default (only if-PowerShellVersion 5.1is passed).In local invocations, this behavior is unexpected: all available format data should be returned.
This PR fixes that, both for direct local invocations and for invocations in background jobs.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.