Repository navigation
Closed
Labels
Resolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.The issue won't be fixed, possibly due to compatibility reason.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Get-Content with -AsByteStream, -Raw and -ReadCount should return list of byte []
Simple script below
Set-Content -LiteralPath 'foo.bar' -Value 'foobar' -NoNewLine
Get-ChildItem -LiteralPath 'foo.bar'
$foo = Get-Content -LiteralPath 'foo.bar' -AsByteStream
$foo.GetType().Name
$foo[0].GetType().Name
$foo.Count
$foo[0].Count
$foo = Get-Content -LiteralPath 'foo.bar' -AsByteStream -ReadCount 3
$foo.GetType().Name
$foo[0].GetType().Name
$foo.Count
$foo[0].Count
$foo[1].Count
$foo = Get-Content -LiteralPath 'foo.bar' -AsByteStream -ReadCount 3 -Raw
$foo.GetType().Name
$foo[0].GetType().Name
$foo.Count
$foo[0].Count
$foo[1].Count
Expected behavior
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 21/04/2024 03:03 6 foo.bar
Object[]
Byte
6
1
Object[]
Object[]
2
3
3
Object[]
Byte[]
2
3
3Actual behavior
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 21/04/2024 03:03 6 foo.bar
Object[]
Byte
6
1
Object[]
Object[]
2
3
3
Object[]
Byte[]
1
6
0Error details
no errorsEnvironment data
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
just the above text will suffice
Reacted by Michael Klement
Metadata
Metadata
Assignees
Labels
Resolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.The issue won't be fixed, possibly due to compatibility reason.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Activity
mklement0 commentedon Apr 21, 2024
I support this feature request, but let me add some context:
If
-ReadCountis specified,-Rawis ignored (which is unfortunate, and arguably a bug).-Rawin combination with-AsByteStream- but without-ReadCount- does emit a[byte[]]array, but it invariably means reading the whole input file into memory.-ReadCount- wich currently emits[object[]]arrays - should:[string[]]arrays by default-AsByteStreamis also specified, should emit[byte[]]arraysIn other words: when "chunking" is requested via
-ReadCounta strongly typed array should be returned, which helps performance, especially in v7.4+ with-AsByeStream, which then allows directly outputting chunked byte data to an external (native) program (which only works with[byte[]]arrays, not with[object[]]arrays).This is technically a breaking change, but most likely one that falls into bucket 3.
jdhitsolutions commentedon Aug 8, 2024
Added for the Cmdlet WG to review
JamesWTruher commentedon Sep 4, 2024
The WG discussed this and while we recognize this behavior may not be consistent with expectations, we believe that this does not meet the bar for return on engineering investment to make any changes.
mklement0 commentedon Sep 4, 2024
Isn't the proper resolution then to assign the
Up-for-grabslabel?microsoft-github-policy-service commentedon Sep 5, 2024
This issue has been marked as won't fix and has not had any activity for 1 day. It has been closed for housekeeping purposes.
microsoft-github-policy-service commentedon Sep 5, 2024
📣 Hey rhubarb-geek-nz, how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback