| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@MiaRomero, It will cover your contributions to all Microsoft-managed open source projects. |
Sorry, something went wrong.
|
SandeepSutari, Mike Richmond (@mirichmo), Dongbo Wang (@daxian-dbw), Joey Aiello (@joeyaiello): Could you please take a look? Thanks. |
Sorry, something went wrong.
There was a problem hiding this comment.
Why is the private member not camel cased ? Unless Pascal casing is the recommended pattern for C# cmdlets, we should use camel casing
Sorry, something went wrong.
There was a problem hiding this comment.
I mean method name...var name is fine
Sorry, something went wrong.
There was a problem hiding this comment.
I talked to Dongbo Wang (@daxian-dbw) about this, and Pascal casing is the recommended pattern for the cmdlets.
Sorry, something went wrong.
There was a problem hiding this comment.
Looks like you could get the inputBytes out of each of these else if {} blocks and do the convert* at the end if else block. that would prevent 10 uses of convert calls peppered across this method.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
unless this is the pattern or a standard practice to use _ for private members we should avoid it. Also why is the method variable using the private member style...we should stick with camel casing since its a method variable.
Sorry, something went wrong.
There was a problem hiding this comment.
parameter names shouldn't have '_' prefixed to them.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
I would fix indentation here
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed for all error messages.
Sorry, something went wrong.
There was a problem hiding this comment.
i64 should get itself a better var name. currently its a type name.
Sorry, something went wrong.
There was a problem hiding this comment.
You can do something like foreach (Int64 value in inputInts){...}
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
use string constants instead of raw strings
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
here are a few high level comments
Sorry, something went wrong.
There was a problem hiding this comment.
this file shouldn't be part of the PR
Sorry, something went wrong.
There was a problem hiding this comment.
convention is to use automatic properties:
public string[] Path { get; set; }
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
|
Maria Romero (@MiaRomero) Do you use the same e-mail for GitHub and CLA sign? |
Sorry, something went wrong.
|
Add Breaking-Change because -Raw removed. |
Sorry, something went wrong.
|
Maria Romero (@MiaRomero), thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
Sorry, something went wrong.
There was a problem hiding this comment.
The HelpUr should be "http://go.microsoft.com/fwlink/?LinkId=526919". This will fix your failures in the CI test pass.
Sorry, something went wrong.
There was a problem hiding this comment.
Shouldn't this be https?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
As per Dongbo Wang (@daxian-dbw) suggestion, please see if you can reuse some of existing cmdlets' code that support encoding parameters.
You can probably reuse some of this code:
Sorry, something went wrong.
There was a problem hiding this comment.
yes, this should probably be an enum rather than the string set
In reply to: 105936094 [](ancestors = 105936094)
Sorry, something went wrong.
There was a problem hiding this comment.
We have FileSystemCmdletProviderEncoding enum (but in EncodingConversion the same is string constants in the class.
It seems we need to bring this to the common code base.)
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
Please fix the indentation of all the errorrecords.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
You can do something like foreach (Int64 value in inputInts){...}
Sorry, something went wrong.
There was a problem hiding this comment.
This test case could probably be simplified to:
{ Get-Alias fhx } | Should Not Throw
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
Could you please use a more meaningful variable name? E.g., $output, and $errorThrown?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
'expectedError' should be rename to 'expectedFullyQualifiedErrorId'.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
$otherProvider should probably be renamed to '$certificateProvider'.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
Could you please rename this Context to something like "Validate Format-Hex error scenarios" or "Validate negative test cases" or "Validate error scenarios"?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
Should these be ExpectedResult, and ExpectedSecondResult?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
do you need to validate that these paths are filesystem provider paths?
for example, format-hex -literalpath hklm:/software should perhaps produce the same error as format-hex -path hklm:/software
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
it seems like it would be a useful scenario to support multiple files here:
format-hex file*.txt
unless that's an explicit non-supported scenario
Sorry, something went wrong.
There was a problem hiding this comment.
yep - looking below, it appears that it just loops through the provided paths, it seems reasonable to support more than one resolved path
In reply to: 105987086 [](ancestors = 105987086)
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
The file src\Modules\Unix\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1 also needs updating - that should get the tests passing in Travis.
Sorry, something went wrong.
There was a problem hiding this comment.
Please use platform independent [Environment]::NewLine
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
|
Hi SandeepSutari, Francisco Gamino (@Francisco-Gamino), Steve Lee (@SteveL-MSFT), Ilya (@iSazonov), and James Truher (@JamesWTruher), |
Sorry, something went wrong.
|
Ilya (@iSazonov), Joey Aiello (@joeyaiello): I am removing "Breaking-Change" label as the -Raw parameter is still present (is a No-op). |
Sorry, something went wrong.
There was a problem hiding this comment.
My comments have been addressed. Thanks Maria Romero (@MiaRomero) !
Sorry, something went wrong.
|
Francisco Gamino (@Francisco-Gamino) - Even with the noop -Raw parameter - there is a change in behavior we need to document - so please keep the Breaking Change label. |
Sorry, something went wrong.
|
It looks like we are using little-endian, since all windows version are little-endian. But since we are going cross-plat, maybe considering supporting big-endian as well? Or maybe at least document that we use little-endian by default? |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) - I don't think we want to get in the business of dealing with endian-ness in this cmdlet. I think of it as more of a memory dumping tool, and it shouldn't necessarily interpret what it's dumping (even though we could). |
Sorry, something went wrong.
There was a problem hiding this comment.
The test Count == 0 is not necessary if we aren't reporting any errors, the foreach statement handles that case cleanly and efficiently.
That said, should we report an error if there are no files?
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you. Good point, it turns out we do not need this code. It does throw an error if the path does not resolve to a file.
The sample below shows an array of two paths that don't exist. Each will throw a non-terminating error.
fhx -Path "c:\dlfkjasdkfj.txt", "c:\ldkfj.txt"
fhx : Cannot find path 'C:\dlfkjasdkfj.txt' because it does not exist.
At line:1 char:1
+ fhx -Path "c:\dlfkjasdkfj.txt", "c:\ldkfj.txt"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (System.String[]:String[]) [Format-Hex], ItemNotFoundException
+ FullyQualifiedErrorId : FileNotFound,Microsoft.PowerShell.Commands.FormatHex
fhx : Cannot find path 'C:\ldkfj.txt' because it does not exist.
At line:1 char:1
+ fhx -Path "c:\dlfkjasdkfj.txt", "c:\ldkfj.txt"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (System.String[]:String[]) [Format-Hex], ItemNotFoundException
+ FullyQualifiedErrorId : FileNotFound,Microsoft.PowerShell.Commands.FormatHex
Sorry, something went wrong.
There was a problem hiding this comment.
And just to confirm - there is no error if you use a wildcard and there are no matches?
Sorry, something went wrong.
There was a problem hiding this comment.
Clone is copying data needlessly here.
Instead, you could pass buffer to ConvertToHexidecimal, then create a new array that is zero initialized. The zeroing of memory by .Net is going to be more efficient than the Clone (which will have started with zeroed memory anyway).
Sorry, something went wrong.
There was a problem hiding this comment.
I've changed it to copy the buffer into a new array instead of cloning the buffer. If this isn't what you had in mind, please file an issue and Francisco Gamino (@Francisco-Gamino) will follow up. Due to time constraints with my internship, I won't be able to follow up after today.
Sorry, something went wrong.
There was a problem hiding this comment.
I know this is just a translation of the C#, but I don't think this case makes sense.
If I pass an object for Format-Hex, I expect that object to be formatted. I didn't ask for the contents of the file, that's a different parameter set.
Sorry, something went wrong.
There was a problem hiding this comment.
Per committee review/comment below, we'll leave as is for now.
Sorry, something went wrong.
There was a problem hiding this comment.
It would be nice to see all primitive types (including enums) and arrays of these types - instead of this random assortment.
I wrote some code that covers much of what I think is useful and it's a similar number of lines of code, see https://gist.github.com/lzybkr/9940b63c8301c31316bdb3ec6305536f
Sorry, something went wrong.
There was a problem hiding this comment.
It might also be useful to support any value type, not just primitives, but that is a little harder.
Sorry, something went wrong.
There was a problem hiding this comment.
Hi Jason Shirk (@lzybkr), Maria Romero (@MiaRomero) Leap Program assignment/internship ends today, so I will follow-up on this. I have open an issue #3358 to track this. Thanks.
Sorry, something went wrong.
There was a problem hiding this comment.
It doesn't look like there is any file header, so if there are multiple files, it will be difficult to understand the output.
Sorry, something went wrong.
There was a problem hiding this comment.
There is a header for each ByteCollection object, e.g.,
New-Item -Value "foo" -Path foo1.txt -ItemType File
New-Item -Value "foo2" -Path foo2.txt -ItemType File
PS C:\exp> dir foo* | fhx
Path: C:\exp\foo1.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 66 6F 6F foo
Path: C:\exp\foo2.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 66 6F 6F 32 foo2
PS C:\exp> fhx -Path .\foo*
Path: C:\exp\foo1.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 66 6F 6F foo
Path: C:\exp\foo2.txt
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 66 6F 6F 32 foo2
Sorry, something went wrong.
There was a problem hiding this comment.
Great.
Sorry, something went wrong.
|
@PowerShell/powershell-committee reviewed this and agreed on:
|
Sorry, something went wrong.
There was a problem hiding this comment.
It seems like this is unnecessary and should be removed.
Sorry, something went wrong.
There was a problem hiding this comment.
In this scenario we want to test that we get both an error and output.
Sorry, something went wrong.
There was a problem hiding this comment.
Please use the template to check FullyQualifiedErrorId
Sorry, something went wrong.
There was a problem hiding this comment.
I've tried using this but get this error:
The term 'ShouldBeErrorId' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
So for now I'll keep Should Match
Sorry, something went wrong.
There was a problem hiding this comment.
We could call the function with parameter PathCase = $true then PathCase = $false
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, that is true. But I'll leave as is for now.
Sorry, something went wrong.
There was a problem hiding this comment.
Please remove the test because we already have separate files with tests for aliases.
Sorry, something went wrong.
There was a problem hiding this comment.
Removed.
Sorry, something went wrong.
There was a problem hiding this comment.
Is there any chance we could get Count and Offset parameters? I could probably live without Offset but on the PSCX Format-Hex command, I use -Count almost all the time. That's because I use it to see if a text file has a BOM, in which case I only want to see the first 3 characters.
Sorry, something went wrong.
There was a problem hiding this comment.
Those are good suggestions, but out of scope for this PR.
Sorry, something went wrong.
There was a problem hiding this comment.
Keith Hill (@rkeithhill), please open a issue for that suggestion. Thanks.
Sorry, something went wrong.
|
Thank you everyone for your feedback. Jason Shirk (@lzybkr) can you please merge when you have a chance? My internship is over so if there are any questions/concerns please address them to Francisco Gamino (@Francisco-Gamino). Thanks! |
Sorry, something went wrong.
|
It was great working with you Maria Romero (@MiaRomero), thank you! |
Sorry, something went wrong.
There was a problem hiding this comment.
I opened #3382 so we clean up the test a little, but otherwise looks good.
Sorry, something went wrong.
|
Thanks Jason Shirk (@lzybkr)! I will take care of #3382. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Addressing issue #2730 'Rewrite Format-Hex in C#'
Documentation for Format-Hex states both the Path and LiteralPath parameters accept string arrays, though this functionality was not actually present for the cmdlet. This has been corrected so both parameters can accept and process an array of strings. If an invalid path is included in the array, a non-terminating 'FileNotFound' error will be thrown, but the remaining valid paths will be processed and output as usual.
After a discussion with Francisco Gamino (@Francisco-Gamino) and Joey Aiello (@joeyaiello), it was decided to make the Raw parameter No-op. Going forward all of the output will be displayed with a true representation of numbers that includes all of the bytes for its type (what the Raw parameter was formally doing). For example, [Int32]170 passed to Format-Hex would have previously displayed only "AA". Now it will display "AA 00 00 00".
Updated the InputObject parameter to accept an Int32[], in addition to all previously accepted types.
The way Format-Hex processes and displays input from the pipeline has been corrected. Previously, the output for numbers in an array or range would be combined into one as seen below:
PS D:\GitHub\PowerShell> 1,2 | fhx Path: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00000000 01 02 ..Now each number will be displayed as its own input object:
PS D:\GitHub\PowerShell> 1,2 |fhx 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00000000 01 00 00 00 .... 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00000000 02 00 00 00 ....fhx : The given path 'Cert:\CurrentUser\My\' is not supported. This command only supports the FileSystem Provider paths. At line:1 char:1 + fhx -path Cert:\CurrentUser\My\ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Cert:\CurrentUser\My\:String) [Format-Hex], ArgumentException + FullyQualifiedErrorId : FormatHexOnlySupportsFileSystemPaths,Microsoft.PowerShell.Commands.FormatHexCleaned up how we are exposing the Format-Hex error messages. Removed from UtilityCommon.cs and are being accessed through UtilityCommonStrings.resx instead.
Updated and added tests for this cmdlet to validate newly implemented functionality and to be more comprehensive for original functionality.