-
Notifications
You must be signed in to change notification settings - Fork 5k
throw exception when creating an entry name that already exists in ZipArchive #60973
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
Conversation
Tagging subscribers to this area: @dotnet/area-system-io-compression Issue DetailsFixes #51051
|
@@ -308,4 +308,7 @@ | |||
<data name="Zip64EOCDNotWhereExpected" xml:space="preserve"> | |||
<value>Zip 64 End of Central Directory Record not where indicated.</value> | |||
</data> | |||
<data name="EntryNameAlreadyExists" xml:space="preserve"> | |||
<value>The entry name already exists in the archive.</value> |
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.
is the entryname a reasonable length? if so I suggest to include in the message ie
<value>The entry name already exists in the archive.</value> | |
<value>The entry name '{0}' already exists in the archive.</value> |
whenever an exception refers to a named thing (like a path, etc) it can be helpful to include what the thing is.
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.
if you did this, you'd use AssertExtensions.ThrowsContains to verify it's present.
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 think the entry name would have reasonable length because it's just a file name
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.
Thanks for your contribution, @pedrobsaila , and thank you for your patience.
I left some suggestions for you to consider.
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression/tests/ZipArchive/zip_CreateTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Compression/tests/ZipArchive/zip_UpdateTests.cs
Outdated
Show resolved
Hide resolved
…sue with globalization
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.
Looks great, @pedrobsaila. Thanks for your contribution!
if (_entriesDictionary.ContainsKey(entryName)) | ||
{ | ||
throw new InvalidOperationException(string.Format(SR.EntryNameAlreadyExists, entryName)); | ||
} |
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'm working on getting various MAUI workloads running on .NET 7. One of our tests hit an issue due to this change.
An MSBuild task inside a NuGet package has the following call:
Previously the code was creating a new entry then removing the old one afterward. (Code is old, it may indeed be incorrect)
Is the new exception intentional? Is it something that needs to be on a "breaking changes" list somewhere?
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 filed an issue; it seems I can reproduce in a smaller example: #68734
Fixes #51051