Skip to content

Conversation

@vexx32
Copy link
Collaborator

@vexx32 vexx32 commented Jan 6, 2019

PR Summary

Fixes #3358

Adds support to Format-Hex for any primitive type, along with strings and direct file input.

Notes:

Behaviour change

Cmdlet now treats a homogenous piped input array as a single item, so that pipeline input behaviour should mirror directly presented -InputObject behaviour. In other words, [byte[]](1, 2, 3) | fhx will be treated as a single array and displayed in a single line, instead of being treated as completely separate items.

When a similar jagged array is presented, however, the cmdlet will notice and output each pipeline item as a separate display. This should have pretty high consistency in terms of handling string input mixed with other things, as well as just handling jagged input with pretty good consistency with how it would handle standalone input.

Enums are supported and will be processed according to their base type (int32 for PowerShell-native enums, all valid base primitives from C#).

Kinda fun to work with, now. 😄

PR Checklist

vexx32 added 2 commits January 5, 2019 22:24
- Enums of primitive types are supported
- Heterogenous arrays are handled properly
- Homogenous piped input is handled as a single array
@vexx32 vexx32 changed the title Format hex improvements Format-Hex: Handle all primitive types & better array input handling Jan 6, 2019
vexx32 added 2 commits January 5, 2019 22:59
⚠️ Tests were failing due to difference in line endings on Unix
@vexx32
Copy link
Collaborator Author

vexx32 commented Jan 6, 2019

Test failure looks... Yeah, I'm not sure what that is. Doesn't look like what I've been touching, though? Possibly a race condition or something... weird. Think I've seen it in at least one other PR, though, so I'm pretty sure it's not my doing. 😄

[OutputType(typeof(Microsoft.PowerShell.Commands.ByteCollection))]
[Alias("fhx")]
public sealed class FormatHex : PSCmdlet
public sealed class FormatHexCommand : PSCmdlet
Copy link
Member

Choose a reason for hiding this comment

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

Agree it's inconsistent, but since this class is public, we shouldn't rename it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vexx32 Your PR contains many style and unrelated fixes so I'd prefer to merge my #8191 at first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@iSazonov go for it!

It'll be a bit easier for me to do a thorough diff between my changes and yours once #8191 is merged. I don't mind figuring out the merge after yours is done. 😄

@iSazonov
Copy link
Collaborator

@vexx32 Perhaps move to new PR would be better.

@vexx32
Copy link
Collaborator Author

vexx32 commented Jan 17, 2019

@iSazonov you may be right. I'll pull down a new branch and see what I can do. 😄

@vexx32 vexx32 closed this Jan 17, 2019
@vexx32 vexx32 deleted the FormatHexImprovements branch January 22, 2019 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format-Hex should support all primitive types (including enums) and arrays of these types - instead of this random assortment.

3 participants