-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expose Comment in ZipArchive and ZipArchiveEntry #59442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 23 commits
08f2a8b
973fc8c
be54e4a
28467ae
297b9e5
338b184
31a2227
78d7e37
0a29149
b93305b
7496628
a949883
9738c30
5179ea2
0e47de4
18bbcd4
31602b3
0ae8a64
e9d5b67
77b6ee5
8daedcf
1596bb3
3444631
0749c84
b08f0ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -383,5 +383,57 @@ internal static void AddEntry(ZipArchive archive, string name, string contents, | |||||||||
| w.WriteLine(contents); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| protected const string SmileyEmoji = "\ud83d\ude04"; | ||||||||||
| protected const string LowerCaseOUmlautChar = "\u00F6"; | ||||||||||
| protected const string CopyrightChar = "\u00A9"; | ||||||||||
|
||||||||||
|
|
||||||||||
| // Returns pairs that are returned the same way by Utf8 and Latin1 | ||||||||||
| // Returns: originalComment, expectedComment | ||||||||||
| private static IEnumerable<object[]> SharedComment_Data() | ||||||||||
| { | ||||||||||
| yield return new object[] { null, string.Empty }; | ||||||||||
| yield return new object[] { string.Empty, string.Empty }; | ||||||||||
| yield return new object[] { "a", "a" }; | ||||||||||
| yield return new object[] { LowerCaseOUmlautChar, LowerCaseOUmlautChar }; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Returns pairs as expected by Utf8 | ||||||||||
| // Returns: originalComment, expectedComment | ||||||||||
| public static IEnumerable<object[]> Utf8Comment_Data() | ||||||||||
| { | ||||||||||
| string asciiExpectedExactMaxLength = new('a', ushort.MaxValue); | ||||||||||
| string asciiOriginalOverMaxLength = asciiExpectedExactMaxLength + "aaa"; | ||||||||||
|
||||||||||
| string asciiExpectedExactMaxLength = new('a', ushort.MaxValue); | |
| string asciiOriginalOverMaxLength = asciiExpectedExactMaxLength + "aaa"; | |
| string utf8ExpectedExactMaxLength = new('a', ushort.MaxValue); | |
| string utf8OriginalOverMaxLength = asciiExpectedExactMaxLength + "aaa"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's test data. This method return test cases for both ASCII and UTF8. Renaming these variables would be incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a case where the emoji does not get truncated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only case where the string is truncated is when it's length is greater than expected. The contents don't matter. So if a string is smaller than the max length, it should remain untouched, regardless of its contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the end of the method to avoid mixing what is being reused from what is unique to this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to yield the shared cases first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be in
testsfolder.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I don't know why it was created there. Maybe we used to share something with another assembly, but it got removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah search didn't return the other file that consumes ZipTestHelper. It's the ZipFile.csproj. I'll revert the move of this file.