Feat/add binary comparison#1
Conversation
Michal-MK
commented
Jan 26, 2023
- added net7.0 target
- added CheckBinary function to well... check binary content
- added GetOldBinaryContent which avoids the terminal and string.Join("\n")
- added CheckOutputBinaryCore which avoids string.Replace and other undesirable operations on binary files
- added net7.0 target
- added CheckBinary function to well... check binary content
- added GetOldBinaryContent which avoids the terminal and string.Join("\n")
- added CheckOutputBinaryCore which avoids string.Replace and other undesirable operations on binary files
exyi
left a comment
There was a problem hiding this comment.
Cool, thank you, this feature makes sense to me. I think I found a mistake GetOldBinaryContent, other than that it's ok.
Could you maybe add a unit test demonstrating that it works? (in the exampleTest folder, nothing complex, just new byte[] { 0, 1, 2 } or something)
|
|
||
| private byte[] GetOldBinaryContent(string file) | ||
| { | ||
| return File.ReadAllBytes(file); |
There was a problem hiding this comment.
This has to take the staged value from git (same as the GetOldContent function does it). Otherwise, on the first run the test will fail, but overwrite the file with the new (probably broken) value. Next run will read the already broken file, and pass. If we read the file from git stage, the user has to explicitly use git add to overwrite the file, so just running the tests mutliple times won't fix the test failure.
There was a problem hiding this comment.
git cat-file should just return the binary data to stdout, these low level git commands usually don't care about text/binary distinctions
- added BinaryTests to varify functionality - added test Image.png as the base file and respective test outputs for each function
|
I had to restructure the code a bit as |
|
Oh, I didn't anticipate .NET Process only allows reading through the StreamReader 🤦 I think reading it using ASCII encoding into chars is also going to cause problems (like interpreting all >127 bytes as
I think it's because we always load the byte array full of |
- added more tests to check characters converted to bytes with different encoding
|
Right, I reverted the encoding change and added two more tests to check how it will behave with UTF-8 and ASCII. Seems good from the very limited test suite ;) Also the popup went away after restarting VS, so I do not know if/when it will come back. |
|
The popup only shows when I have the file in question open in VS. So that is not an issue as it would popup regardless. I also forgot to revert the file back to the original content so that is fixed now. |
|
Great, thank you! I'm just wondering why I can't run github Actions on the PR. I will "solve" the issue by merging it, but if you'd know by chance, let me know.
Ok then, I guess that's expected when the file changes.
I'm afraid you added more tests than I had for the string comparisons 😁 |