Problem
The Get-SodiumPublicKey function has a [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', ...)] attribute with the justification: "The unary comma preserves the byte array as one pipeline object."
However, the unary comma does not prevent ForEach-Object (or similar pipeline consumers) from enumerating the byte array. Piping the output enumerates it into 32 individual bytes:
$kp = New-SodiumKeyPair
$piped = Get-SodiumPublicKey -PrivateKey $kp.PrivateKey -AsByteArray | ForEach-Object { $_ }
$piped.Count # 32
This makes the justification misleading and the suppression potentially unnecessary.
Suggested fix
Either:
- Remove the misleading
SuppressMessageAttribute justification and let the byte array enumerate naturally (current actual behavior), or
- Actually preserve the byte array as a single pipeline object, e.g. by wrapping it with
Write-Output -NoEnumerate or PSObject.AsPSObject(...).
Related code
src/functions/public/Get-SodiumPublicKey.ps1
Notes
Direct assignment already returns a [byte[]], so the -AsByteArray switch is useful for assignment scenarios. The issue is specifically the documented/pipeline-preservation claim.
Problem
The
Get-SodiumPublicKeyfunction has a[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', ...)]attribute with the justification: "The unary comma preserves the byte array as one pipeline object."However, the unary comma does not prevent
ForEach-Object(or similar pipeline consumers) from enumerating the byte array. Piping the output enumerates it into 32 individual bytes:This makes the justification misleading and the suppression potentially unnecessary.
Suggested fix
Either:
SuppressMessageAttributejustification and let the byte array enumerate naturally (current actual behavior), orWrite-Output -NoEnumerateorPSObject.AsPSObject(...).Related code
src/functions/public/Get-SodiumPublicKey.ps1Notes
Direct assignment already returns a
[byte[]], so the-AsByteArrayswitch is useful for assignment scenarios. The issue is specifically the documented/pipeline-preservation claim.